babylon.module.d.ts 4.9 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275
  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. * Moves the observable to the top of the observer list making it get called first when notified
  4356. * @param observer the observer to move
  4357. */
  4358. makeObserverTopPriority(observer: Observer<T>): void;
  4359. /**
  4360. * Moves the observable to the bottom of the observer list making it get called last when notified
  4361. * @param observer the observer to move
  4362. */
  4363. makeObserverBottomPriority(observer: Observer<T>): void;
  4364. /**
  4365. * Notify all Observers by calling their respective callback with the given data
  4366. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4367. * @param eventData defines the data to send to all observers
  4368. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4369. * @param target defines the original target of the state
  4370. * @param currentTarget defines the current target of the state
  4371. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4372. */
  4373. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4374. /**
  4375. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4376. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4377. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4378. * and it is crucial that all callbacks will be executed.
  4379. * The order of the callbacks is kept, callbacks are not executed parallel.
  4380. *
  4381. * @param eventData The data to be sent to each callback
  4382. * @param mask is used to filter observers defaults to -1
  4383. * @param target defines the callback target (see EventState)
  4384. * @param currentTarget defines he current object in the bubbling phase
  4385. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4386. */
  4387. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4388. /**
  4389. * Notify a specific observer
  4390. * @param observer defines the observer to notify
  4391. * @param eventData defines the data to be sent to each callback
  4392. * @param mask is used to filter observers defaults to -1
  4393. */
  4394. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4395. /**
  4396. * Gets a boolean indicating if the observable has at least one observer
  4397. * @returns true is the Observable has at least one Observer registered
  4398. */
  4399. hasObservers(): boolean;
  4400. /**
  4401. * Clear the list of observers
  4402. */
  4403. clear(): void;
  4404. /**
  4405. * Clone the current observable
  4406. * @returns a new observable
  4407. */
  4408. clone(): Observable<T>;
  4409. /**
  4410. * Does this observable handles observer registered with a given mask
  4411. * @param mask defines the mask to be tested
  4412. * @return whether or not one observer registered with the given mask is handeled
  4413. **/
  4414. hasSpecificMask(mask?: number): boolean;
  4415. }
  4416. }
  4417. declare module "babylonjs/Misc/filesInputStore" {
  4418. /**
  4419. * Class used to help managing file picking and drag'n'drop
  4420. * File Storage
  4421. */
  4422. export class FilesInputStore {
  4423. /**
  4424. * List of files ready to be loaded
  4425. */
  4426. static FilesToLoad: {
  4427. [key: string]: File;
  4428. };
  4429. }
  4430. }
  4431. declare module "babylonjs/Engines/constants" {
  4432. /** Defines the cross module used constants to avoid circular dependncies */
  4433. export class Constants {
  4434. /** Defines that alpha blending is disabled */
  4435. static readonly ALPHA_DISABLE: number;
  4436. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4437. static readonly ALPHA_ADD: number;
  4438. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4439. static readonly ALPHA_COMBINE: number;
  4440. /** Defines that alpha blending to DEST - SRC * DEST */
  4441. static readonly ALPHA_SUBTRACT: number;
  4442. /** Defines that alpha blending to SRC * DEST */
  4443. static readonly ALPHA_MULTIPLY: number;
  4444. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4445. static readonly ALPHA_MAXIMIZED: number;
  4446. /** Defines that alpha blending to SRC + DEST */
  4447. static readonly ALPHA_ONEONE: number;
  4448. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4449. static readonly ALPHA_PREMULTIPLIED: number;
  4450. /**
  4451. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4452. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4453. */
  4454. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4455. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4456. static readonly ALPHA_INTERPOLATE: number;
  4457. /**
  4458. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4459. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4460. */
  4461. static readonly ALPHA_SCREENMODE: number;
  4462. /** Defines that the ressource is not delayed*/
  4463. static readonly DELAYLOADSTATE_NONE: number;
  4464. /** Defines that the ressource was successfully delay loaded */
  4465. static readonly DELAYLOADSTATE_LOADED: number;
  4466. /** Defines that the ressource is currently delay loading */
  4467. static readonly DELAYLOADSTATE_LOADING: number;
  4468. /** Defines that the ressource is delayed and has not started loading */
  4469. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4470. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4471. static readonly NEVER: number;
  4472. /** 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 */
  4473. static readonly ALWAYS: number;
  4474. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4475. static readonly LESS: number;
  4476. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4477. static readonly EQUAL: number;
  4478. /** 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 */
  4479. static readonly LEQUAL: number;
  4480. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4481. static readonly GREATER: number;
  4482. /** 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 */
  4483. static readonly GEQUAL: number;
  4484. /** 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 */
  4485. static readonly NOTEQUAL: number;
  4486. /** Passed to stencilOperation to specify that stencil value must be kept */
  4487. static readonly KEEP: number;
  4488. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4489. static readonly REPLACE: number;
  4490. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4491. static readonly INCR: number;
  4492. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4493. static readonly DECR: number;
  4494. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4495. static readonly INVERT: number;
  4496. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4497. static readonly INCR_WRAP: number;
  4498. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4499. static readonly DECR_WRAP: number;
  4500. /** Texture is not repeating outside of 0..1 UVs */
  4501. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4502. /** Texture is repeating outside of 0..1 UVs */
  4503. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4504. /** Texture is repeating and mirrored */
  4505. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4506. /** ALPHA */
  4507. static readonly TEXTUREFORMAT_ALPHA: number;
  4508. /** LUMINANCE */
  4509. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4510. /** LUMINANCE_ALPHA */
  4511. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4512. /** RGB */
  4513. static readonly TEXTUREFORMAT_RGB: number;
  4514. /** RGBA */
  4515. static readonly TEXTUREFORMAT_RGBA: number;
  4516. /** RED */
  4517. static readonly TEXTUREFORMAT_RED: number;
  4518. /** RED (2nd reference) */
  4519. static readonly TEXTUREFORMAT_R: number;
  4520. /** RG */
  4521. static readonly TEXTUREFORMAT_RG: number;
  4522. /** RED_INTEGER */
  4523. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4524. /** RED_INTEGER (2nd reference) */
  4525. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4526. /** RG_INTEGER */
  4527. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4528. /** RGB_INTEGER */
  4529. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4530. /** RGBA_INTEGER */
  4531. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4532. /** UNSIGNED_BYTE */
  4533. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4534. /** UNSIGNED_BYTE (2nd reference) */
  4535. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4536. /** FLOAT */
  4537. static readonly TEXTURETYPE_FLOAT: number;
  4538. /** HALF_FLOAT */
  4539. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4540. /** BYTE */
  4541. static readonly TEXTURETYPE_BYTE: number;
  4542. /** SHORT */
  4543. static readonly TEXTURETYPE_SHORT: number;
  4544. /** UNSIGNED_SHORT */
  4545. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4546. /** INT */
  4547. static readonly TEXTURETYPE_INT: number;
  4548. /** UNSIGNED_INT */
  4549. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4550. /** UNSIGNED_SHORT_4_4_4_4 */
  4551. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4552. /** UNSIGNED_SHORT_5_5_5_1 */
  4553. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4554. /** UNSIGNED_SHORT_5_6_5 */
  4555. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4556. /** UNSIGNED_INT_2_10_10_10_REV */
  4557. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4558. /** UNSIGNED_INT_24_8 */
  4559. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4560. /** UNSIGNED_INT_10F_11F_11F_REV */
  4561. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4562. /** UNSIGNED_INT_5_9_9_9_REV */
  4563. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4564. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4565. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4566. /** nearest is mag = nearest and min = nearest and mip = linear */
  4567. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4568. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4569. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4570. /** Trilinear is mag = linear and min = linear and mip = linear */
  4571. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4572. /** nearest is mag = nearest and min = nearest and mip = linear */
  4573. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4574. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4575. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4576. /** Trilinear is mag = linear and min = linear and mip = linear */
  4577. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4578. /** mag = nearest and min = nearest and mip = nearest */
  4579. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4580. /** mag = nearest and min = linear and mip = nearest */
  4581. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4582. /** mag = nearest and min = linear and mip = linear */
  4583. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4584. /** mag = nearest and min = linear and mip = none */
  4585. static readonly TEXTURE_NEAREST_LINEAR: number;
  4586. /** mag = nearest and min = nearest and mip = none */
  4587. static readonly TEXTURE_NEAREST_NEAREST: number;
  4588. /** mag = linear and min = nearest and mip = nearest */
  4589. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4590. /** mag = linear and min = nearest and mip = linear */
  4591. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4592. /** mag = linear and min = linear and mip = none */
  4593. static readonly TEXTURE_LINEAR_LINEAR: number;
  4594. /** mag = linear and min = nearest and mip = none */
  4595. static readonly TEXTURE_LINEAR_NEAREST: number;
  4596. /** Explicit coordinates mode */
  4597. static readonly TEXTURE_EXPLICIT_MODE: number;
  4598. /** Spherical coordinates mode */
  4599. static readonly TEXTURE_SPHERICAL_MODE: number;
  4600. /** Planar coordinates mode */
  4601. static readonly TEXTURE_PLANAR_MODE: number;
  4602. /** Cubic coordinates mode */
  4603. static readonly TEXTURE_CUBIC_MODE: number;
  4604. /** Projection coordinates mode */
  4605. static readonly TEXTURE_PROJECTION_MODE: number;
  4606. /** Skybox coordinates mode */
  4607. static readonly TEXTURE_SKYBOX_MODE: number;
  4608. /** Inverse Cubic coordinates mode */
  4609. static readonly TEXTURE_INVCUBIC_MODE: number;
  4610. /** Equirectangular coordinates mode */
  4611. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4612. /** Equirectangular Fixed coordinates mode */
  4613. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4614. /** Equirectangular Fixed Mirrored coordinates mode */
  4615. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4616. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4617. static readonly SCALEMODE_FLOOR: number;
  4618. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4619. static readonly SCALEMODE_NEAREST: number;
  4620. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4621. static readonly SCALEMODE_CEILING: number;
  4622. /**
  4623. * The dirty texture flag value
  4624. */
  4625. static readonly MATERIAL_TextureDirtyFlag: number;
  4626. /**
  4627. * The dirty light flag value
  4628. */
  4629. static readonly MATERIAL_LightDirtyFlag: number;
  4630. /**
  4631. * The dirty fresnel flag value
  4632. */
  4633. static readonly MATERIAL_FresnelDirtyFlag: number;
  4634. /**
  4635. * The dirty attribute flag value
  4636. */
  4637. static readonly MATERIAL_AttributesDirtyFlag: number;
  4638. /**
  4639. * The dirty misc flag value
  4640. */
  4641. static readonly MATERIAL_MiscDirtyFlag: number;
  4642. /**
  4643. * The all dirty flag value
  4644. */
  4645. static readonly MATERIAL_AllDirtyFlag: number;
  4646. /**
  4647. * Returns the triangle fill mode
  4648. */
  4649. static readonly MATERIAL_TriangleFillMode: number;
  4650. /**
  4651. * Returns the wireframe mode
  4652. */
  4653. static readonly MATERIAL_WireFrameFillMode: number;
  4654. /**
  4655. * Returns the point fill mode
  4656. */
  4657. static readonly MATERIAL_PointFillMode: number;
  4658. /**
  4659. * Returns the point list draw mode
  4660. */
  4661. static readonly MATERIAL_PointListDrawMode: number;
  4662. /**
  4663. * Returns the line list draw mode
  4664. */
  4665. static readonly MATERIAL_LineListDrawMode: number;
  4666. /**
  4667. * Returns the line loop draw mode
  4668. */
  4669. static readonly MATERIAL_LineLoopDrawMode: number;
  4670. /**
  4671. * Returns the line strip draw mode
  4672. */
  4673. static readonly MATERIAL_LineStripDrawMode: number;
  4674. /**
  4675. * Returns the triangle strip draw mode
  4676. */
  4677. static readonly MATERIAL_TriangleStripDrawMode: number;
  4678. /**
  4679. * Returns the triangle fan draw mode
  4680. */
  4681. static readonly MATERIAL_TriangleFanDrawMode: number;
  4682. /**
  4683. * Stores the clock-wise side orientation
  4684. */
  4685. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4686. /**
  4687. * Stores the counter clock-wise side orientation
  4688. */
  4689. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4690. /**
  4691. * Nothing
  4692. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4693. */
  4694. static readonly ACTION_NothingTrigger: number;
  4695. /**
  4696. * On pick
  4697. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4698. */
  4699. static readonly ACTION_OnPickTrigger: number;
  4700. /**
  4701. * On left pick
  4702. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4703. */
  4704. static readonly ACTION_OnLeftPickTrigger: number;
  4705. /**
  4706. * On right pick
  4707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4708. */
  4709. static readonly ACTION_OnRightPickTrigger: number;
  4710. /**
  4711. * On center pick
  4712. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4713. */
  4714. static readonly ACTION_OnCenterPickTrigger: number;
  4715. /**
  4716. * On pick down
  4717. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4718. */
  4719. static readonly ACTION_OnPickDownTrigger: number;
  4720. /**
  4721. * On double pick
  4722. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4723. */
  4724. static readonly ACTION_OnDoublePickTrigger: number;
  4725. /**
  4726. * On pick up
  4727. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4728. */
  4729. static readonly ACTION_OnPickUpTrigger: number;
  4730. /**
  4731. * On pick out.
  4732. * This trigger will only be raised if you also declared a OnPickDown
  4733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4734. */
  4735. static readonly ACTION_OnPickOutTrigger: number;
  4736. /**
  4737. * On long press
  4738. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4739. */
  4740. static readonly ACTION_OnLongPressTrigger: number;
  4741. /**
  4742. * On pointer over
  4743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4744. */
  4745. static readonly ACTION_OnPointerOverTrigger: number;
  4746. /**
  4747. * On pointer out
  4748. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4749. */
  4750. static readonly ACTION_OnPointerOutTrigger: number;
  4751. /**
  4752. * On every frame
  4753. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4754. */
  4755. static readonly ACTION_OnEveryFrameTrigger: number;
  4756. /**
  4757. * On intersection enter
  4758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4759. */
  4760. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4761. /**
  4762. * On intersection exit
  4763. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4764. */
  4765. static readonly ACTION_OnIntersectionExitTrigger: number;
  4766. /**
  4767. * On key down
  4768. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4769. */
  4770. static readonly ACTION_OnKeyDownTrigger: number;
  4771. /**
  4772. * On key up
  4773. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4774. */
  4775. static readonly ACTION_OnKeyUpTrigger: number;
  4776. /**
  4777. * Billboard mode will only apply to Y axis
  4778. */
  4779. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4780. /**
  4781. * Billboard mode will apply to all axes
  4782. */
  4783. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4784. /**
  4785. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4786. */
  4787. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4788. /**
  4789. * Gets or sets base Assets URL
  4790. */
  4791. static readonly PARTICLES_BaseAssetsUrl: string;
  4792. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4793. * Test order :
  4794. * Is the bounding sphere outside the frustum ?
  4795. * If not, are the bounding box vertices outside the frustum ?
  4796. * It not, then the cullable object is in the frustum.
  4797. */
  4798. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4799. /** Culling strategy : Bounding Sphere Only.
  4800. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4801. * It's also less accurate than the standard because some not visible objects can still be selected.
  4802. * Test : is the bounding sphere outside the frustum ?
  4803. * If not, then the cullable object is in the frustum.
  4804. */
  4805. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4806. /** Culling strategy : Optimistic Inclusion.
  4807. * This in an inclusion test first, then the standard exclusion test.
  4808. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4809. * 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.
  4810. * Anyway, it's as accurate as the standard strategy.
  4811. * Test :
  4812. * Is the cullable object bounding sphere center in the frustum ?
  4813. * If not, apply the default culling strategy.
  4814. */
  4815. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4816. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4817. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4818. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4819. * 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.
  4820. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4821. * Test :
  4822. * Is the cullable object bounding sphere center in the frustum ?
  4823. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4824. */
  4825. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4826. /**
  4827. * No logging while loading
  4828. */
  4829. static readonly SCENELOADER_NO_LOGGING: number;
  4830. /**
  4831. * Minimal logging while loading
  4832. */
  4833. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4834. /**
  4835. * Summary logging while loading
  4836. */
  4837. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4838. /**
  4839. * Detailled logging while loading
  4840. */
  4841. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4842. }
  4843. }
  4844. declare module "babylonjs/Misc/domManagement" {
  4845. /**
  4846. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4847. * Babylon.js
  4848. */
  4849. export class DomManagement {
  4850. /**
  4851. * Checks if the window object exists
  4852. * @returns true if the window object exists
  4853. */
  4854. static IsWindowObjectExist(): boolean;
  4855. /**
  4856. * Extracts text content from a DOM element hierarchy
  4857. * @param element defines the root element
  4858. * @returns a string
  4859. */
  4860. static GetDOMTextContent(element: HTMLElement): string;
  4861. }
  4862. }
  4863. declare module "babylonjs/Misc/logger" {
  4864. /**
  4865. * Logger used througouht the application to allow configuration of
  4866. * the log level required for the messages.
  4867. */
  4868. export class Logger {
  4869. /**
  4870. * No log
  4871. */
  4872. static readonly NoneLogLevel: number;
  4873. /**
  4874. * Only message logs
  4875. */
  4876. static readonly MessageLogLevel: number;
  4877. /**
  4878. * Only warning logs
  4879. */
  4880. static readonly WarningLogLevel: number;
  4881. /**
  4882. * Only error logs
  4883. */
  4884. static readonly ErrorLogLevel: number;
  4885. /**
  4886. * All logs
  4887. */
  4888. static readonly AllLogLevel: number;
  4889. private static _LogCache;
  4890. /**
  4891. * Gets a value indicating the number of loading errors
  4892. * @ignorenaming
  4893. */
  4894. static errorsCount: number;
  4895. /**
  4896. * Callback called when a new log is added
  4897. */
  4898. static OnNewCacheEntry: (entry: string) => void;
  4899. private static _AddLogEntry;
  4900. private static _FormatMessage;
  4901. private static _LogDisabled;
  4902. private static _LogEnabled;
  4903. private static _WarnDisabled;
  4904. private static _WarnEnabled;
  4905. private static _ErrorDisabled;
  4906. private static _ErrorEnabled;
  4907. /**
  4908. * Log a message to the console
  4909. */
  4910. static Log: (message: string) => void;
  4911. /**
  4912. * Write a warning message to the console
  4913. */
  4914. static Warn: (message: string) => void;
  4915. /**
  4916. * Write an error message to the console
  4917. */
  4918. static Error: (message: string) => void;
  4919. /**
  4920. * Gets current log cache (list of logs)
  4921. */
  4922. static readonly LogCache: string;
  4923. /**
  4924. * Clears the log cache
  4925. */
  4926. static ClearLogCache(): void;
  4927. /**
  4928. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4929. */
  4930. static LogLevels: number;
  4931. }
  4932. }
  4933. declare module "babylonjs/Misc/typeStore" {
  4934. /** @hidden */
  4935. export class _TypeStore {
  4936. /** @hidden */
  4937. static RegisteredTypes: {
  4938. [key: string]: Object;
  4939. };
  4940. /** @hidden */
  4941. static GetClass(fqdn: string): any;
  4942. }
  4943. }
  4944. declare module "babylonjs/Misc/deepCopier" {
  4945. /**
  4946. * Class containing a set of static utilities functions for deep copy.
  4947. */
  4948. export class DeepCopier {
  4949. /**
  4950. * Tries to copy an object by duplicating every property
  4951. * @param source defines the source object
  4952. * @param destination defines the target object
  4953. * @param doNotCopyList defines a list of properties to avoid
  4954. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4955. */
  4956. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4957. }
  4958. }
  4959. declare module "babylonjs/Misc/precisionDate" {
  4960. /**
  4961. * Class containing a set of static utilities functions for precision date
  4962. */
  4963. export class PrecisionDate {
  4964. /**
  4965. * Gets either window.performance.now() if supported or Date.now() else
  4966. */
  4967. static readonly Now: number;
  4968. }
  4969. }
  4970. declare module "babylonjs/Misc/devTools" {
  4971. /** @hidden */
  4972. export class _DevTools {
  4973. static WarnImport(name: string): string;
  4974. }
  4975. }
  4976. declare module "babylonjs/Misc/webRequest" {
  4977. /**
  4978. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  4979. */
  4980. export class WebRequest {
  4981. private _xhr;
  4982. /**
  4983. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  4984. * i.e. when loading files, where the server/service expects an Authorization header
  4985. */
  4986. static CustomRequestHeaders: {
  4987. [key: string]: string;
  4988. };
  4989. /**
  4990. * Add callback functions in this array to update all the requests before they get sent to the network
  4991. */
  4992. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  4993. private _injectCustomRequestHeaders;
  4994. /**
  4995. * Gets or sets a function to be called when loading progress changes
  4996. */
  4997. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  4998. /**
  4999. * Returns client's state
  5000. */
  5001. readonly readyState: number;
  5002. /**
  5003. * Returns client's status
  5004. */
  5005. readonly status: number;
  5006. /**
  5007. * Returns client's status as a text
  5008. */
  5009. readonly statusText: string;
  5010. /**
  5011. * Returns client's response
  5012. */
  5013. readonly response: any;
  5014. /**
  5015. * Returns client's response url
  5016. */
  5017. readonly responseURL: string;
  5018. /**
  5019. * Returns client's response as text
  5020. */
  5021. readonly responseText: string;
  5022. /**
  5023. * Gets or sets the expected response type
  5024. */
  5025. responseType: XMLHttpRequestResponseType;
  5026. /** @hidden */
  5027. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5028. /** @hidden */
  5029. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5030. /**
  5031. * Cancels any network activity
  5032. */
  5033. abort(): void;
  5034. /**
  5035. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5036. * @param body defines an optional request body
  5037. */
  5038. send(body?: Document | BodyInit | null): void;
  5039. /**
  5040. * Sets the request method, request URL
  5041. * @param method defines the method to use (GET, POST, etc..)
  5042. * @param url defines the url to connect with
  5043. */
  5044. open(method: string, url: string): void;
  5045. }
  5046. }
  5047. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5048. /**
  5049. * Class used to evalaute queries containing `and` and `or` operators
  5050. */
  5051. export class AndOrNotEvaluator {
  5052. /**
  5053. * Evaluate a query
  5054. * @param query defines the query to evaluate
  5055. * @param evaluateCallback defines the callback used to filter result
  5056. * @returns true if the query matches
  5057. */
  5058. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5059. private static _HandleParenthesisContent;
  5060. private static _SimplifyNegation;
  5061. }
  5062. }
  5063. declare module "babylonjs/Misc/tags" {
  5064. /**
  5065. * Class used to store custom tags
  5066. */
  5067. export class Tags {
  5068. /**
  5069. * Adds support for tags on the given object
  5070. * @param obj defines the object to use
  5071. */
  5072. static EnableFor(obj: any): void;
  5073. /**
  5074. * Removes tags support
  5075. * @param obj defines the object to use
  5076. */
  5077. static DisableFor(obj: any): void;
  5078. /**
  5079. * Gets a boolean indicating if the given object has tags
  5080. * @param obj defines the object to use
  5081. * @returns a boolean
  5082. */
  5083. static HasTags(obj: any): boolean;
  5084. /**
  5085. * Gets the tags available on a given object
  5086. * @param obj defines the object to use
  5087. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5088. * @returns the tags
  5089. */
  5090. static GetTags(obj: any, asString?: boolean): any;
  5091. /**
  5092. * Adds tags to an object
  5093. * @param obj defines the object to use
  5094. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5095. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5096. */
  5097. static AddTagsTo(obj: any, tagsString: string): void;
  5098. /**
  5099. * @hidden
  5100. */
  5101. static _AddTagTo(obj: any, tag: string): void;
  5102. /**
  5103. * Removes specific tags from a specific object
  5104. * @param obj defines the object to use
  5105. * @param tagsString defines the tags to remove
  5106. */
  5107. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5108. /**
  5109. * @hidden
  5110. */
  5111. static _RemoveTagFrom(obj: any, tag: string): void;
  5112. /**
  5113. * Defines if tags hosted on an object match a given query
  5114. * @param obj defines the object to use
  5115. * @param tagsQuery defines the tag query
  5116. * @returns a boolean
  5117. */
  5118. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5119. }
  5120. }
  5121. declare module "babylonjs/Materials/materialDefines" {
  5122. /**
  5123. * Manages the defines for the Material
  5124. */
  5125. export class MaterialDefines {
  5126. private _keys;
  5127. private _isDirty;
  5128. /** @hidden */
  5129. _renderId: number;
  5130. /** @hidden */
  5131. _areLightsDirty: boolean;
  5132. /** @hidden */
  5133. _areAttributesDirty: boolean;
  5134. /** @hidden */
  5135. _areTexturesDirty: boolean;
  5136. /** @hidden */
  5137. _areFresnelDirty: boolean;
  5138. /** @hidden */
  5139. _areMiscDirty: boolean;
  5140. /** @hidden */
  5141. _areImageProcessingDirty: boolean;
  5142. /** @hidden */
  5143. _normals: boolean;
  5144. /** @hidden */
  5145. _uvs: boolean;
  5146. /** @hidden */
  5147. _needNormals: boolean;
  5148. /** @hidden */
  5149. _needUVs: boolean;
  5150. /**
  5151. * Specifies if the material needs to be re-calculated
  5152. */
  5153. readonly isDirty: boolean;
  5154. /**
  5155. * Marks the material to indicate that it has been re-calculated
  5156. */
  5157. markAsProcessed(): void;
  5158. /**
  5159. * Marks the material to indicate that it needs to be re-calculated
  5160. */
  5161. markAsUnprocessed(): void;
  5162. /**
  5163. * Marks the material to indicate all of its defines need to be re-calculated
  5164. */
  5165. markAllAsDirty(): void;
  5166. /**
  5167. * Marks the material to indicate that image processing needs to be re-calculated
  5168. */
  5169. markAsImageProcessingDirty(): void;
  5170. /**
  5171. * Marks the material to indicate the lights need to be re-calculated
  5172. */
  5173. markAsLightDirty(): void;
  5174. /**
  5175. * Marks the attribute state as changed
  5176. */
  5177. markAsAttributesDirty(): void;
  5178. /**
  5179. * Marks the texture state as changed
  5180. */
  5181. markAsTexturesDirty(): void;
  5182. /**
  5183. * Marks the fresnel state as changed
  5184. */
  5185. markAsFresnelDirty(): void;
  5186. /**
  5187. * Marks the misc state as changed
  5188. */
  5189. markAsMiscDirty(): void;
  5190. /**
  5191. * Rebuilds the material defines
  5192. */
  5193. rebuild(): void;
  5194. /**
  5195. * Specifies if two material defines are equal
  5196. * @param other - A material define instance to compare to
  5197. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5198. */
  5199. isEqual(other: MaterialDefines): boolean;
  5200. /**
  5201. * Clones this instance's defines to another instance
  5202. * @param other - material defines to clone values to
  5203. */
  5204. cloneTo(other: MaterialDefines): void;
  5205. /**
  5206. * Resets the material define values
  5207. */
  5208. reset(): void;
  5209. /**
  5210. * Converts the material define values to a string
  5211. * @returns - String of material define information
  5212. */
  5213. toString(): string;
  5214. }
  5215. }
  5216. declare module "babylonjs/Misc/performanceMonitor" {
  5217. /**
  5218. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5219. */
  5220. export class PerformanceMonitor {
  5221. private _enabled;
  5222. private _rollingFrameTime;
  5223. private _lastFrameTimeMs;
  5224. /**
  5225. * constructor
  5226. * @param frameSampleSize The number of samples required to saturate the sliding window
  5227. */
  5228. constructor(frameSampleSize?: number);
  5229. /**
  5230. * Samples current frame
  5231. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5232. */
  5233. sampleFrame(timeMs?: number): void;
  5234. /**
  5235. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5236. */
  5237. readonly averageFrameTime: number;
  5238. /**
  5239. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5240. */
  5241. readonly averageFrameTimeVariance: number;
  5242. /**
  5243. * Returns the frame time of the most recent frame
  5244. */
  5245. readonly instantaneousFrameTime: number;
  5246. /**
  5247. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5248. */
  5249. readonly averageFPS: number;
  5250. /**
  5251. * Returns the average framerate in frames per second using the most recent frame time
  5252. */
  5253. readonly instantaneousFPS: number;
  5254. /**
  5255. * Returns true if enough samples have been taken to completely fill the sliding window
  5256. */
  5257. readonly isSaturated: boolean;
  5258. /**
  5259. * Enables contributions to the sliding window sample set
  5260. */
  5261. enable(): void;
  5262. /**
  5263. * Disables contributions to the sliding window sample set
  5264. * Samples will not be interpolated over the disabled period
  5265. */
  5266. disable(): void;
  5267. /**
  5268. * Returns true if sampling is enabled
  5269. */
  5270. readonly isEnabled: boolean;
  5271. /**
  5272. * Resets performance monitor
  5273. */
  5274. reset(): void;
  5275. }
  5276. /**
  5277. * RollingAverage
  5278. *
  5279. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5280. */
  5281. export class RollingAverage {
  5282. /**
  5283. * Current average
  5284. */
  5285. average: number;
  5286. /**
  5287. * Current variance
  5288. */
  5289. variance: number;
  5290. protected _samples: Array<number>;
  5291. protected _sampleCount: number;
  5292. protected _pos: number;
  5293. protected _m2: number;
  5294. /**
  5295. * constructor
  5296. * @param length The number of samples required to saturate the sliding window
  5297. */
  5298. constructor(length: number);
  5299. /**
  5300. * Adds a sample to the sample set
  5301. * @param v The sample value
  5302. */
  5303. add(v: number): void;
  5304. /**
  5305. * Returns previously added values or null if outside of history or outside the sliding window domain
  5306. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5307. * @return Value previously recorded with add() or null if outside of range
  5308. */
  5309. history(i: number): number;
  5310. /**
  5311. * Returns true if enough samples have been taken to completely fill the sliding window
  5312. * @return true if sample-set saturated
  5313. */
  5314. isSaturated(): boolean;
  5315. /**
  5316. * Resets the rolling average (equivalent to 0 samples taken so far)
  5317. */
  5318. reset(): void;
  5319. /**
  5320. * Wraps a value around the sample range boundaries
  5321. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5322. * @return Wrapped position in sample range
  5323. */
  5324. protected _wrapPosition(i: number): number;
  5325. }
  5326. }
  5327. declare module "babylonjs/Misc/stringDictionary" {
  5328. import { Nullable } from "babylonjs/types";
  5329. /**
  5330. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5331. * The underlying implementation relies on an associative array to ensure the best performances.
  5332. * The value can be anything including 'null' but except 'undefined'
  5333. */
  5334. export class StringDictionary<T> {
  5335. /**
  5336. * This will clear this dictionary and copy the content from the 'source' one.
  5337. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5338. * @param source the dictionary to take the content from and copy to this dictionary
  5339. */
  5340. copyFrom(source: StringDictionary<T>): void;
  5341. /**
  5342. * Get a value based from its key
  5343. * @param key the given key to get the matching value from
  5344. * @return the value if found, otherwise undefined is returned
  5345. */
  5346. get(key: string): T | undefined;
  5347. /**
  5348. * Get a value from its key or add it if it doesn't exist.
  5349. * This method will ensure you that a given key/data will be present in the dictionary.
  5350. * @param key the given key to get the matching value from
  5351. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5352. * The factory will only be invoked if there's no data for the given key.
  5353. * @return the value corresponding to the key.
  5354. */
  5355. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5356. /**
  5357. * Get a value from its key if present in the dictionary otherwise add it
  5358. * @param key the key to get the value from
  5359. * @param val if there's no such key/value pair in the dictionary add it with this value
  5360. * @return the value corresponding to the key
  5361. */
  5362. getOrAdd(key: string, val: T): T;
  5363. /**
  5364. * Check if there's a given key in the dictionary
  5365. * @param key the key to check for
  5366. * @return true if the key is present, false otherwise
  5367. */
  5368. contains(key: string): boolean;
  5369. /**
  5370. * Add a new key and its corresponding value
  5371. * @param key the key to add
  5372. * @param value the value corresponding to the key
  5373. * @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
  5374. */
  5375. add(key: string, value: T): boolean;
  5376. /**
  5377. * Update a specific value associated to a key
  5378. * @param key defines the key to use
  5379. * @param value defines the value to store
  5380. * @returns true if the value was updated (or false if the key was not found)
  5381. */
  5382. set(key: string, value: T): boolean;
  5383. /**
  5384. * Get the element of the given key and remove it from the dictionary
  5385. * @param key defines the key to search
  5386. * @returns the value associated with the key or null if not found
  5387. */
  5388. getAndRemove(key: string): Nullable<T>;
  5389. /**
  5390. * Remove a key/value from the dictionary.
  5391. * @param key the key to remove
  5392. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5393. */
  5394. remove(key: string): boolean;
  5395. /**
  5396. * Clear the whole content of the dictionary
  5397. */
  5398. clear(): void;
  5399. /**
  5400. * Gets the current count
  5401. */
  5402. readonly count: number;
  5403. /**
  5404. * Execute a callback on each key/val of the dictionary.
  5405. * Note that you can remove any element in this dictionary in the callback implementation
  5406. * @param callback the callback to execute on a given key/value pair
  5407. */
  5408. forEach(callback: (key: string, val: T) => void): void;
  5409. /**
  5410. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5411. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5412. * Note that you can remove any element in this dictionary in the callback implementation
  5413. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5414. * @returns the first item
  5415. */
  5416. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5417. private _count;
  5418. private _data;
  5419. }
  5420. }
  5421. declare module "babylonjs/Misc/promise" {
  5422. /**
  5423. * Helper class that provides a small promise polyfill
  5424. */
  5425. export class PromisePolyfill {
  5426. /**
  5427. * Static function used to check if the polyfill is required
  5428. * If this is the case then the function will inject the polyfill to window.Promise
  5429. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5430. */
  5431. static Apply(force?: boolean): void;
  5432. }
  5433. }
  5434. declare module "babylonjs/Meshes/buffer" {
  5435. import { Nullable, DataArray } from "babylonjs/types";
  5436. /**
  5437. * Class used to store data that will be store in GPU memory
  5438. */
  5439. export class Buffer {
  5440. private _engine;
  5441. private _buffer;
  5442. /** @hidden */
  5443. _data: Nullable<DataArray>;
  5444. private _updatable;
  5445. private _instanced;
  5446. /**
  5447. * Gets the byte stride.
  5448. */
  5449. readonly byteStride: number;
  5450. /**
  5451. * Constructor
  5452. * @param engine the engine
  5453. * @param data the data to use for this buffer
  5454. * @param updatable whether the data is updatable
  5455. * @param stride the stride (optional)
  5456. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5457. * @param instanced whether the buffer is instanced (optional)
  5458. * @param useBytes set to true if the stride in in bytes (optional)
  5459. */
  5460. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5461. /**
  5462. * Create a new VertexBuffer based on the current buffer
  5463. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5464. * @param offset defines offset in the buffer (0 by default)
  5465. * @param size defines the size in floats of attributes (position is 3 for instance)
  5466. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5467. * @param instanced defines if the vertex buffer contains indexed data
  5468. * @param useBytes defines if the offset and stride are in bytes
  5469. * @returns the new vertex buffer
  5470. */
  5471. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5472. /**
  5473. * Gets a boolean indicating if the Buffer is updatable?
  5474. * @returns true if the buffer is updatable
  5475. */
  5476. isUpdatable(): boolean;
  5477. /**
  5478. * Gets current buffer's data
  5479. * @returns a DataArray or null
  5480. */
  5481. getData(): Nullable<DataArray>;
  5482. /**
  5483. * Gets underlying native buffer
  5484. * @returns underlying native buffer
  5485. */
  5486. getBuffer(): Nullable<WebGLBuffer>;
  5487. /**
  5488. * Gets the stride in float32 units (i.e. byte stride / 4).
  5489. * May not be an integer if the byte stride is not divisible by 4.
  5490. * DEPRECATED. Use byteStride instead.
  5491. * @returns the stride in float32 units
  5492. */
  5493. getStrideSize(): number;
  5494. /**
  5495. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5496. * @param data defines the data to store
  5497. */
  5498. create(data?: Nullable<DataArray>): void;
  5499. /** @hidden */
  5500. _rebuild(): void;
  5501. /**
  5502. * Update current buffer data
  5503. * @param data defines the data to store
  5504. */
  5505. update(data: DataArray): void;
  5506. /**
  5507. * Updates the data directly.
  5508. * @param data the new data
  5509. * @param offset the new offset
  5510. * @param vertexCount the vertex count (optional)
  5511. * @param useBytes set to true if the offset is in bytes
  5512. */
  5513. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5514. /**
  5515. * Release all resources
  5516. */
  5517. dispose(): void;
  5518. }
  5519. /**
  5520. * Specialized buffer used to store vertex data
  5521. */
  5522. export class VertexBuffer {
  5523. /** @hidden */
  5524. _buffer: Buffer;
  5525. private _kind;
  5526. private _size;
  5527. private _ownsBuffer;
  5528. private _instanced;
  5529. private _instanceDivisor;
  5530. /**
  5531. * The byte type.
  5532. */
  5533. static readonly BYTE: number;
  5534. /**
  5535. * The unsigned byte type.
  5536. */
  5537. static readonly UNSIGNED_BYTE: number;
  5538. /**
  5539. * The short type.
  5540. */
  5541. static readonly SHORT: number;
  5542. /**
  5543. * The unsigned short type.
  5544. */
  5545. static readonly UNSIGNED_SHORT: number;
  5546. /**
  5547. * The integer type.
  5548. */
  5549. static readonly INT: number;
  5550. /**
  5551. * The unsigned integer type.
  5552. */
  5553. static readonly UNSIGNED_INT: number;
  5554. /**
  5555. * The float type.
  5556. */
  5557. static readonly FLOAT: number;
  5558. /**
  5559. * Gets or sets the instance divisor when in instanced mode
  5560. */
  5561. instanceDivisor: number;
  5562. /**
  5563. * Gets the byte stride.
  5564. */
  5565. readonly byteStride: number;
  5566. /**
  5567. * Gets the byte offset.
  5568. */
  5569. readonly byteOffset: number;
  5570. /**
  5571. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5572. */
  5573. readonly normalized: boolean;
  5574. /**
  5575. * Gets the data type of each component in the array.
  5576. */
  5577. readonly type: number;
  5578. /**
  5579. * Constructor
  5580. * @param engine the engine
  5581. * @param data the data to use for this vertex buffer
  5582. * @param kind the vertex buffer kind
  5583. * @param updatable whether the data is updatable
  5584. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5585. * @param stride the stride (optional)
  5586. * @param instanced whether the buffer is instanced (optional)
  5587. * @param offset the offset of the data (optional)
  5588. * @param size the number of components (optional)
  5589. * @param type the type of the component (optional)
  5590. * @param normalized whether the data contains normalized data (optional)
  5591. * @param useBytes set to true if stride and offset are in bytes (optional)
  5592. */
  5593. 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);
  5594. /** @hidden */
  5595. _rebuild(): void;
  5596. /**
  5597. * Returns the kind of the VertexBuffer (string)
  5598. * @returns a string
  5599. */
  5600. getKind(): string;
  5601. /**
  5602. * Gets a boolean indicating if the VertexBuffer is updatable?
  5603. * @returns true if the buffer is updatable
  5604. */
  5605. isUpdatable(): boolean;
  5606. /**
  5607. * Gets current buffer's data
  5608. * @returns a DataArray or null
  5609. */
  5610. getData(): Nullable<DataArray>;
  5611. /**
  5612. * Gets underlying native buffer
  5613. * @returns underlying native buffer
  5614. */
  5615. getBuffer(): Nullable<WebGLBuffer>;
  5616. /**
  5617. * Gets the stride in float32 units (i.e. byte stride / 4).
  5618. * May not be an integer if the byte stride is not divisible by 4.
  5619. * DEPRECATED. Use byteStride instead.
  5620. * @returns the stride in float32 units
  5621. */
  5622. getStrideSize(): number;
  5623. /**
  5624. * Returns the offset as a multiple of the type byte length.
  5625. * DEPRECATED. Use byteOffset instead.
  5626. * @returns the offset in bytes
  5627. */
  5628. getOffset(): number;
  5629. /**
  5630. * Returns the number of components per vertex attribute (integer)
  5631. * @returns the size in float
  5632. */
  5633. getSize(): number;
  5634. /**
  5635. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5636. * @returns true if this buffer is instanced
  5637. */
  5638. getIsInstanced(): boolean;
  5639. /**
  5640. * Returns the instancing divisor, zero for non-instanced (integer).
  5641. * @returns a number
  5642. */
  5643. getInstanceDivisor(): number;
  5644. /**
  5645. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5646. * @param data defines the data to store
  5647. */
  5648. create(data?: DataArray): void;
  5649. /**
  5650. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5651. * This function will create a new buffer if the current one is not updatable
  5652. * @param data defines the data to store
  5653. */
  5654. update(data: DataArray): void;
  5655. /**
  5656. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5657. * Returns the directly updated WebGLBuffer.
  5658. * @param data the new data
  5659. * @param offset the new offset
  5660. * @param useBytes set to true if the offset is in bytes
  5661. */
  5662. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5663. /**
  5664. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5665. */
  5666. dispose(): void;
  5667. /**
  5668. * Enumerates each value of this vertex buffer as numbers.
  5669. * @param count the number of values to enumerate
  5670. * @param callback the callback function called for each value
  5671. */
  5672. forEach(count: number, callback: (value: number, index: number) => void): void;
  5673. /**
  5674. * Positions
  5675. */
  5676. static readonly PositionKind: string;
  5677. /**
  5678. * Normals
  5679. */
  5680. static readonly NormalKind: string;
  5681. /**
  5682. * Tangents
  5683. */
  5684. static readonly TangentKind: string;
  5685. /**
  5686. * Texture coordinates
  5687. */
  5688. static readonly UVKind: string;
  5689. /**
  5690. * Texture coordinates 2
  5691. */
  5692. static readonly UV2Kind: string;
  5693. /**
  5694. * Texture coordinates 3
  5695. */
  5696. static readonly UV3Kind: string;
  5697. /**
  5698. * Texture coordinates 4
  5699. */
  5700. static readonly UV4Kind: string;
  5701. /**
  5702. * Texture coordinates 5
  5703. */
  5704. static readonly UV5Kind: string;
  5705. /**
  5706. * Texture coordinates 6
  5707. */
  5708. static readonly UV6Kind: string;
  5709. /**
  5710. * Colors
  5711. */
  5712. static readonly ColorKind: string;
  5713. /**
  5714. * Matrix indices (for bones)
  5715. */
  5716. static readonly MatricesIndicesKind: string;
  5717. /**
  5718. * Matrix weights (for bones)
  5719. */
  5720. static readonly MatricesWeightsKind: string;
  5721. /**
  5722. * Additional matrix indices (for bones)
  5723. */
  5724. static readonly MatricesIndicesExtraKind: string;
  5725. /**
  5726. * Additional matrix weights (for bones)
  5727. */
  5728. static readonly MatricesWeightsExtraKind: string;
  5729. /**
  5730. * Deduces the stride given a kind.
  5731. * @param kind The kind string to deduce
  5732. * @returns The deduced stride
  5733. */
  5734. static DeduceStride(kind: string): number;
  5735. /**
  5736. * Gets the byte length of the given type.
  5737. * @param type the type
  5738. * @returns the number of bytes
  5739. */
  5740. static GetTypeByteLength(type: number): number;
  5741. /**
  5742. * Enumerates each value of the given parameters as numbers.
  5743. * @param data the data to enumerate
  5744. * @param byteOffset the byte offset of the data
  5745. * @param byteStride the byte stride of the data
  5746. * @param componentCount the number of components per element
  5747. * @param componentType the type of the component
  5748. * @param count the total number of components
  5749. * @param normalized whether the data is normalized
  5750. * @param callback the callback function called for each value
  5751. */
  5752. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5753. private static _GetFloatValue;
  5754. }
  5755. }
  5756. declare module "babylonjs/Maths/sphericalPolynomial" {
  5757. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5758. /**
  5759. * Class representing spherical polynomial coefficients to the 3rd degree
  5760. */
  5761. export class SphericalPolynomial {
  5762. /**
  5763. * The x coefficients of the spherical polynomial
  5764. */
  5765. x: Vector3;
  5766. /**
  5767. * The y coefficients of the spherical polynomial
  5768. */
  5769. y: Vector3;
  5770. /**
  5771. * The z coefficients of the spherical polynomial
  5772. */
  5773. z: Vector3;
  5774. /**
  5775. * The xx coefficients of the spherical polynomial
  5776. */
  5777. xx: Vector3;
  5778. /**
  5779. * The yy coefficients of the spherical polynomial
  5780. */
  5781. yy: Vector3;
  5782. /**
  5783. * The zz coefficients of the spherical polynomial
  5784. */
  5785. zz: Vector3;
  5786. /**
  5787. * The xy coefficients of the spherical polynomial
  5788. */
  5789. xy: Vector3;
  5790. /**
  5791. * The yz coefficients of the spherical polynomial
  5792. */
  5793. yz: Vector3;
  5794. /**
  5795. * The zx coefficients of the spherical polynomial
  5796. */
  5797. zx: Vector3;
  5798. /**
  5799. * Adds an ambient color to the spherical polynomial
  5800. * @param color the color to add
  5801. */
  5802. addAmbient(color: Color3): void;
  5803. /**
  5804. * Scales the spherical polynomial by the given amount
  5805. * @param scale the amount to scale
  5806. */
  5807. scale(scale: number): void;
  5808. /**
  5809. * Gets the spherical polynomial from harmonics
  5810. * @param harmonics the spherical harmonics
  5811. * @returns the spherical polynomial
  5812. */
  5813. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5814. /**
  5815. * Constructs a spherical polynomial from an array.
  5816. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5817. * @returns the spherical polynomial
  5818. */
  5819. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5820. }
  5821. /**
  5822. * Class representing spherical harmonics coefficients to the 3rd degree
  5823. */
  5824. export class SphericalHarmonics {
  5825. /**
  5826. * The l0,0 coefficients of the spherical harmonics
  5827. */
  5828. l00: Vector3;
  5829. /**
  5830. * The l1,-1 coefficients of the spherical harmonics
  5831. */
  5832. l1_1: Vector3;
  5833. /**
  5834. * The l1,0 coefficients of the spherical harmonics
  5835. */
  5836. l10: Vector3;
  5837. /**
  5838. * The l1,1 coefficients of the spherical harmonics
  5839. */
  5840. l11: Vector3;
  5841. /**
  5842. * The l2,-2 coefficients of the spherical harmonics
  5843. */
  5844. l2_2: Vector3;
  5845. /**
  5846. * The l2,-1 coefficients of the spherical harmonics
  5847. */
  5848. l2_1: Vector3;
  5849. /**
  5850. * The l2,0 coefficients of the spherical harmonics
  5851. */
  5852. l20: Vector3;
  5853. /**
  5854. * The l2,1 coefficients of the spherical harmonics
  5855. */
  5856. l21: Vector3;
  5857. /**
  5858. * The l2,2 coefficients of the spherical harmonics
  5859. */
  5860. lL22: Vector3;
  5861. /**
  5862. * Adds a light to the spherical harmonics
  5863. * @param direction the direction of the light
  5864. * @param color the color of the light
  5865. * @param deltaSolidAngle the delta solid angle of the light
  5866. */
  5867. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5868. /**
  5869. * Scales the spherical harmonics by the given amount
  5870. * @param scale the amount to scale
  5871. */
  5872. scale(scale: number): void;
  5873. /**
  5874. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5875. *
  5876. * ```
  5877. * E_lm = A_l * L_lm
  5878. * ```
  5879. *
  5880. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5881. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5882. * the scaling factors are given in equation 9.
  5883. */
  5884. convertIncidentRadianceToIrradiance(): void;
  5885. /**
  5886. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5887. *
  5888. * ```
  5889. * L = (1/pi) * E * rho
  5890. * ```
  5891. *
  5892. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5893. */
  5894. convertIrradianceToLambertianRadiance(): void;
  5895. /**
  5896. * Gets the spherical harmonics from polynomial
  5897. * @param polynomial the spherical polynomial
  5898. * @returns the spherical harmonics
  5899. */
  5900. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5901. /**
  5902. * Constructs a spherical harmonics from an array.
  5903. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5904. * @returns the spherical harmonics
  5905. */
  5906. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5907. }
  5908. }
  5909. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  5910. import { Nullable } from "babylonjs/types";
  5911. /**
  5912. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5913. */
  5914. export interface CubeMapInfo {
  5915. /**
  5916. * The pixel array for the front face.
  5917. * This is stored in format, left to right, up to down format.
  5918. */
  5919. front: Nullable<ArrayBufferView>;
  5920. /**
  5921. * The pixel array for the back face.
  5922. * This is stored in format, left to right, up to down format.
  5923. */
  5924. back: Nullable<ArrayBufferView>;
  5925. /**
  5926. * The pixel array for the left face.
  5927. * This is stored in format, left to right, up to down format.
  5928. */
  5929. left: Nullable<ArrayBufferView>;
  5930. /**
  5931. * The pixel array for the right face.
  5932. * This is stored in format, left to right, up to down format.
  5933. */
  5934. right: Nullable<ArrayBufferView>;
  5935. /**
  5936. * The pixel array for the up face.
  5937. * This is stored in format, left to right, up to down format.
  5938. */
  5939. up: Nullable<ArrayBufferView>;
  5940. /**
  5941. * The pixel array for the down face.
  5942. * This is stored in format, left to right, up to down format.
  5943. */
  5944. down: Nullable<ArrayBufferView>;
  5945. /**
  5946. * The size of the cubemap stored.
  5947. *
  5948. * Each faces will be size * size pixels.
  5949. */
  5950. size: number;
  5951. /**
  5952. * The format of the texture.
  5953. *
  5954. * RGBA, RGB.
  5955. */
  5956. format: number;
  5957. /**
  5958. * The type of the texture data.
  5959. *
  5960. * UNSIGNED_INT, FLOAT.
  5961. */
  5962. type: number;
  5963. /**
  5964. * Specifies whether the texture is in gamma space.
  5965. */
  5966. gammaSpace: boolean;
  5967. }
  5968. /**
  5969. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5970. */
  5971. export class PanoramaToCubeMapTools {
  5972. private static FACE_FRONT;
  5973. private static FACE_BACK;
  5974. private static FACE_RIGHT;
  5975. private static FACE_LEFT;
  5976. private static FACE_DOWN;
  5977. private static FACE_UP;
  5978. /**
  5979. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5980. *
  5981. * @param float32Array The source data.
  5982. * @param inputWidth The width of the input panorama.
  5983. * @param inputHeight The height of the input panorama.
  5984. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5985. * @return The cubemap data
  5986. */
  5987. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5988. private static CreateCubemapTexture;
  5989. private static CalcProjectionSpherical;
  5990. }
  5991. }
  5992. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  5993. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  5994. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  5995. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  5996. /**
  5997. * Helper class dealing with the extraction of spherical polynomial dataArray
  5998. * from a cube map.
  5999. */
  6000. export class CubeMapToSphericalPolynomialTools {
  6001. private static FileFaces;
  6002. /**
  6003. * Converts a texture to the according Spherical Polynomial data.
  6004. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6005. *
  6006. * @param texture The texture to extract the information from.
  6007. * @return The Spherical Polynomial data.
  6008. */
  6009. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6010. /**
  6011. * Converts a cubemap to the according Spherical Polynomial data.
  6012. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6013. *
  6014. * @param cubeInfo The Cube map to extract the information from.
  6015. * @return The Spherical Polynomial data.
  6016. */
  6017. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6018. }
  6019. }
  6020. declare module "babylonjs/Engines/engineStore" {
  6021. import { Nullable } from "babylonjs/types";
  6022. import { Engine } from "babylonjs/Engines/engine";
  6023. import { Scene } from "babylonjs/scene";
  6024. /**
  6025. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6026. * during the life time of the application.
  6027. */
  6028. export class EngineStore {
  6029. /** Gets the list of created engines */
  6030. static Instances: import("babylonjs/Engines/engine").Engine[];
  6031. /**
  6032. * Gets the latest created engine
  6033. */
  6034. static readonly LastCreatedEngine: Nullable<Engine>;
  6035. /**
  6036. * Gets the latest created scene
  6037. */
  6038. static readonly LastCreatedScene: Nullable<Scene>;
  6039. }
  6040. }
  6041. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  6042. /**
  6043. * Define options used to create a render target texture
  6044. */
  6045. export class RenderTargetCreationOptions {
  6046. /**
  6047. * Specifies is mipmaps must be generated
  6048. */
  6049. generateMipMaps?: boolean;
  6050. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6051. generateDepthBuffer?: boolean;
  6052. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6053. generateStencilBuffer?: boolean;
  6054. /** Defines texture type (int by default) */
  6055. type?: number;
  6056. /** Defines sampling mode (trilinear by default) */
  6057. samplingMode?: number;
  6058. /** Defines format (RGBA by default) */
  6059. format?: number;
  6060. }
  6061. }
  6062. declare module "babylonjs/States/alphaCullingState" {
  6063. /**
  6064. * @hidden
  6065. **/
  6066. export class _AlphaState {
  6067. private _isAlphaBlendDirty;
  6068. private _isBlendFunctionParametersDirty;
  6069. private _isBlendEquationParametersDirty;
  6070. private _isBlendConstantsDirty;
  6071. private _alphaBlend;
  6072. private _blendFunctionParameters;
  6073. private _blendEquationParameters;
  6074. private _blendConstants;
  6075. /**
  6076. * Initializes the state.
  6077. */
  6078. constructor();
  6079. readonly isDirty: boolean;
  6080. alphaBlend: boolean;
  6081. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6082. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6083. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6084. reset(): void;
  6085. apply(gl: WebGLRenderingContext): void;
  6086. }
  6087. }
  6088. declare module "babylonjs/States/depthCullingState" {
  6089. import { Nullable } from "babylonjs/types";
  6090. /**
  6091. * @hidden
  6092. **/
  6093. export class _DepthCullingState {
  6094. private _isDepthTestDirty;
  6095. private _isDepthMaskDirty;
  6096. private _isDepthFuncDirty;
  6097. private _isCullFaceDirty;
  6098. private _isCullDirty;
  6099. private _isZOffsetDirty;
  6100. private _isFrontFaceDirty;
  6101. private _depthTest;
  6102. private _depthMask;
  6103. private _depthFunc;
  6104. private _cull;
  6105. private _cullFace;
  6106. private _zOffset;
  6107. private _frontFace;
  6108. /**
  6109. * Initializes the state.
  6110. */
  6111. constructor();
  6112. readonly isDirty: boolean;
  6113. zOffset: number;
  6114. cullFace: Nullable<number>;
  6115. cull: Nullable<boolean>;
  6116. depthFunc: Nullable<number>;
  6117. depthMask: boolean;
  6118. depthTest: boolean;
  6119. frontFace: Nullable<number>;
  6120. reset(): void;
  6121. apply(gl: WebGLRenderingContext): void;
  6122. }
  6123. }
  6124. declare module "babylonjs/States/stencilState" {
  6125. /**
  6126. * @hidden
  6127. **/
  6128. export class _StencilState {
  6129. /** 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 */
  6130. static readonly ALWAYS: number;
  6131. /** Passed to stencilOperation to specify that stencil value must be kept */
  6132. static readonly KEEP: number;
  6133. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6134. static readonly REPLACE: number;
  6135. private _isStencilTestDirty;
  6136. private _isStencilMaskDirty;
  6137. private _isStencilFuncDirty;
  6138. private _isStencilOpDirty;
  6139. private _stencilTest;
  6140. private _stencilMask;
  6141. private _stencilFunc;
  6142. private _stencilFuncRef;
  6143. private _stencilFuncMask;
  6144. private _stencilOpStencilFail;
  6145. private _stencilOpDepthFail;
  6146. private _stencilOpStencilDepthPass;
  6147. readonly isDirty: boolean;
  6148. stencilFunc: number;
  6149. stencilFuncRef: number;
  6150. stencilFuncMask: number;
  6151. stencilOpStencilFail: number;
  6152. stencilOpDepthFail: number;
  6153. stencilOpStencilDepthPass: number;
  6154. stencilMask: number;
  6155. stencilTest: boolean;
  6156. constructor();
  6157. reset(): void;
  6158. apply(gl: WebGLRenderingContext): void;
  6159. }
  6160. }
  6161. declare module "babylonjs/States/index" {
  6162. export * from "babylonjs/States/alphaCullingState";
  6163. export * from "babylonjs/States/depthCullingState";
  6164. export * from "babylonjs/States/stencilState";
  6165. }
  6166. declare module "babylonjs/Instrumentation/timeToken" {
  6167. import { Nullable } from "babylonjs/types";
  6168. /**
  6169. * @hidden
  6170. **/
  6171. export class _TimeToken {
  6172. _startTimeQuery: Nullable<WebGLQuery>;
  6173. _endTimeQuery: Nullable<WebGLQuery>;
  6174. _timeElapsedQuery: Nullable<WebGLQuery>;
  6175. _timeElapsedQueryEnded: boolean;
  6176. }
  6177. }
  6178. declare module "babylonjs/Materials/Textures/internalTextureTracker" {
  6179. import { Nullable } from "babylonjs/types";
  6180. /**
  6181. * Internal interface used to track InternalTexture already bound to the GL context
  6182. */
  6183. export interface IInternalTextureTracker {
  6184. /**
  6185. * Gets or set the previous tracker in the list
  6186. */
  6187. previous: Nullable<IInternalTextureTracker>;
  6188. /**
  6189. * Gets or set the next tracker in the list
  6190. */
  6191. next: Nullable<IInternalTextureTracker>;
  6192. }
  6193. /**
  6194. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  6195. */
  6196. export class DummyInternalTextureTracker {
  6197. /**
  6198. * Gets or set the previous tracker in the list
  6199. */
  6200. previous: Nullable<IInternalTextureTracker>;
  6201. /**
  6202. * Gets or set the next tracker in the list
  6203. */
  6204. next: Nullable<IInternalTextureTracker>;
  6205. }
  6206. }
  6207. declare module "babylonjs/Materials/Textures/internalTexture" {
  6208. import { Observable } from "babylonjs/Misc/observable";
  6209. import { Nullable, int } from "babylonjs/types";
  6210. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6211. import { IInternalTextureTracker } from "babylonjs/Materials/Textures/internalTextureTracker";
  6212. import { Engine } from "babylonjs/Engines/engine";
  6213. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6214. /**
  6215. * Class used to store data associated with WebGL texture data for the engine
  6216. * This class should not be used directly
  6217. */
  6218. export class InternalTexture implements IInternalTextureTracker {
  6219. /** hidden */
  6220. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6221. /**
  6222. * The source of the texture data is unknown
  6223. */
  6224. static DATASOURCE_UNKNOWN: number;
  6225. /**
  6226. * Texture data comes from an URL
  6227. */
  6228. static DATASOURCE_URL: number;
  6229. /**
  6230. * Texture data is only used for temporary storage
  6231. */
  6232. static DATASOURCE_TEMP: number;
  6233. /**
  6234. * Texture data comes from raw data (ArrayBuffer)
  6235. */
  6236. static DATASOURCE_RAW: number;
  6237. /**
  6238. * Texture content is dynamic (video or dynamic texture)
  6239. */
  6240. static DATASOURCE_DYNAMIC: number;
  6241. /**
  6242. * Texture content is generated by rendering to it
  6243. */
  6244. static DATASOURCE_RENDERTARGET: number;
  6245. /**
  6246. * Texture content is part of a multi render target process
  6247. */
  6248. static DATASOURCE_MULTIRENDERTARGET: number;
  6249. /**
  6250. * Texture data comes from a cube data file
  6251. */
  6252. static DATASOURCE_CUBE: number;
  6253. /**
  6254. * Texture data comes from a raw cube data
  6255. */
  6256. static DATASOURCE_CUBERAW: number;
  6257. /**
  6258. * Texture data come from a prefiltered cube data file
  6259. */
  6260. static DATASOURCE_CUBEPREFILTERED: number;
  6261. /**
  6262. * Texture content is raw 3D data
  6263. */
  6264. static DATASOURCE_RAW3D: number;
  6265. /**
  6266. * Texture content is a depth texture
  6267. */
  6268. static DATASOURCE_DEPTHTEXTURE: number;
  6269. /**
  6270. * Texture data comes from a raw cube data encoded with RGBD
  6271. */
  6272. static DATASOURCE_CUBERAW_RGBD: number;
  6273. /**
  6274. * Defines if the texture is ready
  6275. */
  6276. isReady: boolean;
  6277. /**
  6278. * Defines if the texture is a cube texture
  6279. */
  6280. isCube: boolean;
  6281. /**
  6282. * Defines if the texture contains 3D data
  6283. */
  6284. is3D: boolean;
  6285. /**
  6286. * Gets the URL used to load this texture
  6287. */
  6288. url: string;
  6289. /**
  6290. * Gets the sampling mode of the texture
  6291. */
  6292. samplingMode: number;
  6293. /**
  6294. * Gets a boolean indicating if the texture needs mipmaps generation
  6295. */
  6296. generateMipMaps: boolean;
  6297. /**
  6298. * Gets the number of samples used by the texture (WebGL2+ only)
  6299. */
  6300. samples: number;
  6301. /**
  6302. * Gets the type of the texture (int, float...)
  6303. */
  6304. type: number;
  6305. /**
  6306. * Gets the format of the texture (RGB, RGBA...)
  6307. */
  6308. format: number;
  6309. /**
  6310. * Observable called when the texture is loaded
  6311. */
  6312. onLoadedObservable: Observable<InternalTexture>;
  6313. /**
  6314. * Gets the width of the texture
  6315. */
  6316. width: number;
  6317. /**
  6318. * Gets the height of the texture
  6319. */
  6320. height: number;
  6321. /**
  6322. * Gets the depth of the texture
  6323. */
  6324. depth: number;
  6325. /**
  6326. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6327. */
  6328. baseWidth: number;
  6329. /**
  6330. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6331. */
  6332. baseHeight: number;
  6333. /**
  6334. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6335. */
  6336. baseDepth: number;
  6337. /**
  6338. * Gets a boolean indicating if the texture is inverted on Y axis
  6339. */
  6340. invertY: boolean;
  6341. /**
  6342. * Gets or set the previous tracker in the list
  6343. */
  6344. previous: Nullable<IInternalTextureTracker>;
  6345. /**
  6346. * Gets or set the next tracker in the list
  6347. */
  6348. next: Nullable<IInternalTextureTracker>;
  6349. /** @hidden */
  6350. _invertVScale: boolean;
  6351. /** @hidden */
  6352. _initialSlot: number;
  6353. /** @hidden */
  6354. _designatedSlot: number;
  6355. /** @hidden */
  6356. _dataSource: number;
  6357. /** @hidden */
  6358. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6359. /** @hidden */
  6360. _bufferView: Nullable<ArrayBufferView>;
  6361. /** @hidden */
  6362. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6363. /** @hidden */
  6364. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6365. /** @hidden */
  6366. _size: number;
  6367. /** @hidden */
  6368. _extension: string;
  6369. /** @hidden */
  6370. _files: Nullable<string[]>;
  6371. /** @hidden */
  6372. _workingCanvas: HTMLCanvasElement;
  6373. /** @hidden */
  6374. _workingContext: CanvasRenderingContext2D;
  6375. /** @hidden */
  6376. _framebuffer: Nullable<WebGLFramebuffer>;
  6377. /** @hidden */
  6378. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6379. /** @hidden */
  6380. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6381. /** @hidden */
  6382. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6383. /** @hidden */
  6384. _attachments: Nullable<number[]>;
  6385. /** @hidden */
  6386. _cachedCoordinatesMode: Nullable<number>;
  6387. /** @hidden */
  6388. _cachedWrapU: Nullable<number>;
  6389. /** @hidden */
  6390. _cachedWrapV: Nullable<number>;
  6391. /** @hidden */
  6392. _cachedWrapR: Nullable<number>;
  6393. /** @hidden */
  6394. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6395. /** @hidden */
  6396. _isDisabled: boolean;
  6397. /** @hidden */
  6398. _compression: Nullable<string>;
  6399. /** @hidden */
  6400. _generateStencilBuffer: boolean;
  6401. /** @hidden */
  6402. _generateDepthBuffer: boolean;
  6403. /** @hidden */
  6404. _comparisonFunction: number;
  6405. /** @hidden */
  6406. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6407. /** @hidden */
  6408. _lodGenerationScale: number;
  6409. /** @hidden */
  6410. _lodGenerationOffset: number;
  6411. /** @hidden */
  6412. _lodTextureHigh: BaseTexture;
  6413. /** @hidden */
  6414. _lodTextureMid: BaseTexture;
  6415. /** @hidden */
  6416. _lodTextureLow: BaseTexture;
  6417. /** @hidden */
  6418. _isRGBD: boolean;
  6419. /** @hidden */
  6420. _webGLTexture: Nullable<WebGLTexture>;
  6421. /** @hidden */
  6422. _references: number;
  6423. private _engine;
  6424. /**
  6425. * Gets the Engine the texture belongs to.
  6426. * @returns The babylon engine
  6427. */
  6428. getEngine(): Engine;
  6429. /**
  6430. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6431. */
  6432. readonly dataSource: number;
  6433. /**
  6434. * Creates a new InternalTexture
  6435. * @param engine defines the engine to use
  6436. * @param dataSource defines the type of data that will be used
  6437. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6438. */
  6439. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6440. /**
  6441. * Increments the number of references (ie. the number of Texture that point to it)
  6442. */
  6443. incrementReferences(): void;
  6444. /**
  6445. * Change the size of the texture (not the size of the content)
  6446. * @param width defines the new width
  6447. * @param height defines the new height
  6448. * @param depth defines the new depth (1 by default)
  6449. */
  6450. updateSize(width: int, height: int, depth?: int): void;
  6451. /** @hidden */
  6452. _rebuild(): void;
  6453. /** @hidden */
  6454. _swapAndDie(target: InternalTexture): void;
  6455. /**
  6456. * Dispose the current allocated resources
  6457. */
  6458. dispose(): void;
  6459. }
  6460. }
  6461. declare module "babylonjs/Animations/easing" {
  6462. /**
  6463. * This represents the main contract an easing function should follow.
  6464. * Easing functions are used throughout the animation system.
  6465. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6466. */
  6467. export interface IEasingFunction {
  6468. /**
  6469. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6470. * of the easing function.
  6471. * The link below provides some of the most common examples of easing functions.
  6472. * @see https://easings.net/
  6473. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6474. * @returns the corresponding value on the curve defined by the easing function
  6475. */
  6476. ease(gradient: number): number;
  6477. }
  6478. /**
  6479. * Base class used for every default easing function.
  6480. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6481. */
  6482. export class EasingFunction implements IEasingFunction {
  6483. /**
  6484. * Interpolation follows the mathematical formula associated with the easing function.
  6485. */
  6486. static readonly EASINGMODE_EASEIN: number;
  6487. /**
  6488. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6489. */
  6490. static readonly EASINGMODE_EASEOUT: number;
  6491. /**
  6492. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6493. */
  6494. static readonly EASINGMODE_EASEINOUT: number;
  6495. private _easingMode;
  6496. /**
  6497. * Sets the easing mode of the current function.
  6498. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6499. */
  6500. setEasingMode(easingMode: number): void;
  6501. /**
  6502. * Gets the current easing mode.
  6503. * @returns the easing mode
  6504. */
  6505. getEasingMode(): number;
  6506. /**
  6507. * @hidden
  6508. */
  6509. easeInCore(gradient: number): number;
  6510. /**
  6511. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6512. * of the easing function.
  6513. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6514. * @returns the corresponding value on the curve defined by the easing function
  6515. */
  6516. ease(gradient: number): number;
  6517. }
  6518. /**
  6519. * Easing function with a circle shape (see link below).
  6520. * @see https://easings.net/#easeInCirc
  6521. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6522. */
  6523. export class CircleEase extends EasingFunction implements IEasingFunction {
  6524. /** @hidden */
  6525. easeInCore(gradient: number): number;
  6526. }
  6527. /**
  6528. * Easing function with a ease back shape (see link below).
  6529. * @see https://easings.net/#easeInBack
  6530. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6531. */
  6532. export class BackEase extends EasingFunction implements IEasingFunction {
  6533. /** Defines the amplitude of the function */
  6534. amplitude: number;
  6535. /**
  6536. * Instantiates a back ease easing
  6537. * @see https://easings.net/#easeInBack
  6538. * @param amplitude Defines the amplitude of the function
  6539. */
  6540. constructor(
  6541. /** Defines the amplitude of the function */
  6542. amplitude?: number);
  6543. /** @hidden */
  6544. easeInCore(gradient: number): number;
  6545. }
  6546. /**
  6547. * Easing function with a bouncing shape (see link below).
  6548. * @see https://easings.net/#easeInBounce
  6549. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6550. */
  6551. export class BounceEase extends EasingFunction implements IEasingFunction {
  6552. /** Defines the number of bounces */
  6553. bounces: number;
  6554. /** Defines the amplitude of the bounce */
  6555. bounciness: number;
  6556. /**
  6557. * Instantiates a bounce easing
  6558. * @see https://easings.net/#easeInBounce
  6559. * @param bounces Defines the number of bounces
  6560. * @param bounciness Defines the amplitude of the bounce
  6561. */
  6562. constructor(
  6563. /** Defines the number of bounces */
  6564. bounces?: number,
  6565. /** Defines the amplitude of the bounce */
  6566. bounciness?: number);
  6567. /** @hidden */
  6568. easeInCore(gradient: number): number;
  6569. }
  6570. /**
  6571. * Easing function with a power of 3 shape (see link below).
  6572. * @see https://easings.net/#easeInCubic
  6573. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6574. */
  6575. export class CubicEase extends EasingFunction implements IEasingFunction {
  6576. /** @hidden */
  6577. easeInCore(gradient: number): number;
  6578. }
  6579. /**
  6580. * Easing function with an elastic shape (see link below).
  6581. * @see https://easings.net/#easeInElastic
  6582. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6583. */
  6584. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6585. /** Defines the number of oscillations*/
  6586. oscillations: number;
  6587. /** Defines the amplitude of the oscillations*/
  6588. springiness: number;
  6589. /**
  6590. * Instantiates an elastic easing function
  6591. * @see https://easings.net/#easeInElastic
  6592. * @param oscillations Defines the number of oscillations
  6593. * @param springiness Defines the amplitude of the oscillations
  6594. */
  6595. constructor(
  6596. /** Defines the number of oscillations*/
  6597. oscillations?: number,
  6598. /** Defines the amplitude of the oscillations*/
  6599. springiness?: number);
  6600. /** @hidden */
  6601. easeInCore(gradient: number): number;
  6602. }
  6603. /**
  6604. * Easing function with an exponential shape (see link below).
  6605. * @see https://easings.net/#easeInExpo
  6606. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6607. */
  6608. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6609. /** Defines the exponent of the function */
  6610. exponent: number;
  6611. /**
  6612. * Instantiates an exponential easing function
  6613. * @see https://easings.net/#easeInExpo
  6614. * @param exponent Defines the exponent of the function
  6615. */
  6616. constructor(
  6617. /** Defines the exponent of the function */
  6618. exponent?: number);
  6619. /** @hidden */
  6620. easeInCore(gradient: number): number;
  6621. }
  6622. /**
  6623. * Easing function with a power shape (see link below).
  6624. * @see https://easings.net/#easeInQuad
  6625. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6626. */
  6627. export class PowerEase extends EasingFunction implements IEasingFunction {
  6628. /** Defines the power of the function */
  6629. power: number;
  6630. /**
  6631. * Instantiates an power base easing function
  6632. * @see https://easings.net/#easeInQuad
  6633. * @param power Defines the power of the function
  6634. */
  6635. constructor(
  6636. /** Defines the power of the function */
  6637. power?: number);
  6638. /** @hidden */
  6639. easeInCore(gradient: number): number;
  6640. }
  6641. /**
  6642. * Easing function with a power of 2 shape (see link below).
  6643. * @see https://easings.net/#easeInQuad
  6644. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6645. */
  6646. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6647. /** @hidden */
  6648. easeInCore(gradient: number): number;
  6649. }
  6650. /**
  6651. * Easing function with a power of 4 shape (see link below).
  6652. * @see https://easings.net/#easeInQuart
  6653. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6654. */
  6655. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6656. /** @hidden */
  6657. easeInCore(gradient: number): number;
  6658. }
  6659. /**
  6660. * Easing function with a power of 5 shape (see link below).
  6661. * @see https://easings.net/#easeInQuint
  6662. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6663. */
  6664. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6665. /** @hidden */
  6666. easeInCore(gradient: number): number;
  6667. }
  6668. /**
  6669. * Easing function with a sin shape (see link below).
  6670. * @see https://easings.net/#easeInSine
  6671. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6672. */
  6673. export class SineEase extends EasingFunction implements IEasingFunction {
  6674. /** @hidden */
  6675. easeInCore(gradient: number): number;
  6676. }
  6677. /**
  6678. * Easing function with a bezier shape (see link below).
  6679. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6680. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6681. */
  6682. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6683. /** Defines the x component of the start tangent in the bezier curve */
  6684. x1: number;
  6685. /** Defines the y component of the start tangent in the bezier curve */
  6686. y1: number;
  6687. /** Defines the x component of the end tangent in the bezier curve */
  6688. x2: number;
  6689. /** Defines the y component of the end tangent in the bezier curve */
  6690. y2: number;
  6691. /**
  6692. * Instantiates a bezier function
  6693. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6694. * @param x1 Defines the x component of the start tangent in the bezier curve
  6695. * @param y1 Defines the y component of the start tangent in the bezier curve
  6696. * @param x2 Defines the x component of the end tangent in the bezier curve
  6697. * @param y2 Defines the y component of the end tangent in the bezier curve
  6698. */
  6699. constructor(
  6700. /** Defines the x component of the start tangent in the bezier curve */
  6701. x1?: number,
  6702. /** Defines the y component of the start tangent in the bezier curve */
  6703. y1?: number,
  6704. /** Defines the x component of the end tangent in the bezier curve */
  6705. x2?: number,
  6706. /** Defines the y component of the end tangent in the bezier curve */
  6707. y2?: number);
  6708. /** @hidden */
  6709. easeInCore(gradient: number): number;
  6710. }
  6711. }
  6712. declare module "babylonjs/Animations/animationKey" {
  6713. /**
  6714. * Defines an interface which represents an animation key frame
  6715. */
  6716. export interface IAnimationKey {
  6717. /**
  6718. * Frame of the key frame
  6719. */
  6720. frame: number;
  6721. /**
  6722. * Value at the specifies key frame
  6723. */
  6724. value: any;
  6725. /**
  6726. * The input tangent for the cubic hermite spline
  6727. */
  6728. inTangent?: any;
  6729. /**
  6730. * The output tangent for the cubic hermite spline
  6731. */
  6732. outTangent?: any;
  6733. /**
  6734. * The animation interpolation type
  6735. */
  6736. interpolation?: AnimationKeyInterpolation;
  6737. }
  6738. /**
  6739. * Enum for the animation key frame interpolation type
  6740. */
  6741. export enum AnimationKeyInterpolation {
  6742. /**
  6743. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6744. */
  6745. STEP = 1
  6746. }
  6747. }
  6748. declare module "babylonjs/Animations/animationRange" {
  6749. /**
  6750. * Represents the range of an animation
  6751. */
  6752. export class AnimationRange {
  6753. /**The name of the animation range**/
  6754. name: string;
  6755. /**The starting frame of the animation */
  6756. from: number;
  6757. /**The ending frame of the animation*/
  6758. to: number;
  6759. /**
  6760. * Initializes the range of an animation
  6761. * @param name The name of the animation range
  6762. * @param from The starting frame of the animation
  6763. * @param to The ending frame of the animation
  6764. */
  6765. constructor(
  6766. /**The name of the animation range**/
  6767. name: string,
  6768. /**The starting frame of the animation */
  6769. from: number,
  6770. /**The ending frame of the animation*/
  6771. to: number);
  6772. /**
  6773. * Makes a copy of the animation range
  6774. * @returns A copy of the animation range
  6775. */
  6776. clone(): AnimationRange;
  6777. }
  6778. }
  6779. declare module "babylonjs/Animations/animationEvent" {
  6780. /**
  6781. * Composed of a frame, and an action function
  6782. */
  6783. export class AnimationEvent {
  6784. /** The frame for which the event is triggered **/
  6785. frame: number;
  6786. /** The event to perform when triggered **/
  6787. action: (currentFrame: number) => void;
  6788. /** Specifies if the event should be triggered only once**/
  6789. onlyOnce?: boolean | undefined;
  6790. /**
  6791. * Specifies if the animation event is done
  6792. */
  6793. isDone: boolean;
  6794. /**
  6795. * Initializes the animation event
  6796. * @param frame The frame for which the event is triggered
  6797. * @param action The event to perform when triggered
  6798. * @param onlyOnce Specifies if the event should be triggered only once
  6799. */
  6800. constructor(
  6801. /** The frame for which the event is triggered **/
  6802. frame: number,
  6803. /** The event to perform when triggered **/
  6804. action: (currentFrame: number) => void,
  6805. /** Specifies if the event should be triggered only once**/
  6806. onlyOnce?: boolean | undefined);
  6807. /** @hidden */
  6808. _clone(): AnimationEvent;
  6809. }
  6810. }
  6811. declare module "babylonjs/Behaviors/behavior" {
  6812. import { Nullable } from "babylonjs/types";
  6813. /**
  6814. * Interface used to define a behavior
  6815. */
  6816. export interface Behavior<T> {
  6817. /** gets or sets behavior's name */
  6818. name: string;
  6819. /**
  6820. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6821. */
  6822. init(): void;
  6823. /**
  6824. * Called when the behavior is attached to a target
  6825. * @param target defines the target where the behavior is attached to
  6826. */
  6827. attach(target: T): void;
  6828. /**
  6829. * Called when the behavior is detached from its target
  6830. */
  6831. detach(): void;
  6832. }
  6833. /**
  6834. * Interface implemented by classes supporting behaviors
  6835. */
  6836. export interface IBehaviorAware<T> {
  6837. /**
  6838. * Attach a behavior
  6839. * @param behavior defines the behavior to attach
  6840. * @returns the current host
  6841. */
  6842. addBehavior(behavior: Behavior<T>): T;
  6843. /**
  6844. * Remove a behavior from the current object
  6845. * @param behavior defines the behavior to detach
  6846. * @returns the current host
  6847. */
  6848. removeBehavior(behavior: Behavior<T>): T;
  6849. /**
  6850. * Gets a behavior using its name to search
  6851. * @param name defines the name to search
  6852. * @returns the behavior or null if not found
  6853. */
  6854. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6855. }
  6856. }
  6857. declare module "babylonjs/Collisions/intersectionInfo" {
  6858. import { Nullable } from "babylonjs/types";
  6859. /**
  6860. * @hidden
  6861. */
  6862. export class IntersectionInfo {
  6863. bu: Nullable<number>;
  6864. bv: Nullable<number>;
  6865. distance: number;
  6866. faceId: number;
  6867. subMeshId: number;
  6868. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6869. }
  6870. }
  6871. declare module "babylonjs/Culling/boundingSphere" {
  6872. import { DeepImmutable } from "babylonjs/types";
  6873. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6874. /**
  6875. * Class used to store bounding sphere information
  6876. */
  6877. export class BoundingSphere {
  6878. /**
  6879. * Gets the center of the bounding sphere in local space
  6880. */
  6881. readonly center: Vector3;
  6882. /**
  6883. * Radius of the bounding sphere in local space
  6884. */
  6885. radius: number;
  6886. /**
  6887. * Gets the center of the bounding sphere in world space
  6888. */
  6889. readonly centerWorld: Vector3;
  6890. /**
  6891. * Radius of the bounding sphere in world space
  6892. */
  6893. radiusWorld: number;
  6894. /**
  6895. * Gets the minimum vector in local space
  6896. */
  6897. readonly minimum: Vector3;
  6898. /**
  6899. * Gets the maximum vector in local space
  6900. */
  6901. readonly maximum: Vector3;
  6902. private _worldMatrix;
  6903. private static readonly TmpVector3;
  6904. /**
  6905. * Creates a new bounding sphere
  6906. * @param min defines the minimum vector (in local space)
  6907. * @param max defines the maximum vector (in local space)
  6908. * @param worldMatrix defines the new world matrix
  6909. */
  6910. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6911. /**
  6912. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6913. * @param min defines the new minimum vector (in local space)
  6914. * @param max defines the new maximum vector (in local space)
  6915. * @param worldMatrix defines the new world matrix
  6916. */
  6917. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6918. /**
  6919. * Scale the current bounding sphere by applying a scale factor
  6920. * @param factor defines the scale factor to apply
  6921. * @returns the current bounding box
  6922. */
  6923. scale(factor: number): BoundingSphere;
  6924. /**
  6925. * Gets the world matrix of the bounding box
  6926. * @returns a matrix
  6927. */
  6928. getWorldMatrix(): DeepImmutable<Matrix>;
  6929. /** @hidden */
  6930. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6931. /**
  6932. * Tests if the bounding sphere is intersecting the frustum planes
  6933. * @param frustumPlanes defines the frustum planes to test
  6934. * @returns true if there is an intersection
  6935. */
  6936. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6937. /**
  6938. * Tests if the bounding sphere center is in between the frustum planes.
  6939. * Used for optimistic fast inclusion.
  6940. * @param frustumPlanes defines the frustum planes to test
  6941. * @returns true if the sphere center is in between the frustum planes
  6942. */
  6943. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6944. /**
  6945. * Tests if a point is inside the bounding sphere
  6946. * @param point defines the point to test
  6947. * @returns true if the point is inside the bounding sphere
  6948. */
  6949. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6950. /**
  6951. * Checks if two sphere intersct
  6952. * @param sphere0 sphere 0
  6953. * @param sphere1 sphere 1
  6954. * @returns true if the speres intersect
  6955. */
  6956. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6957. }
  6958. }
  6959. declare module "babylonjs/Culling/boundingBox" {
  6960. import { DeepImmutable } from "babylonjs/types";
  6961. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6962. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6963. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6964. /**
  6965. * Class used to store bounding box information
  6966. */
  6967. export class BoundingBox implements ICullable {
  6968. /**
  6969. * Gets the 8 vectors representing the bounding box in local space
  6970. */
  6971. readonly vectors: Vector3[];
  6972. /**
  6973. * Gets the center of the bounding box in local space
  6974. */
  6975. readonly center: Vector3;
  6976. /**
  6977. * Gets the center of the bounding box in world space
  6978. */
  6979. readonly centerWorld: Vector3;
  6980. /**
  6981. * Gets the extend size in local space
  6982. */
  6983. readonly extendSize: Vector3;
  6984. /**
  6985. * Gets the extend size in world space
  6986. */
  6987. readonly extendSizeWorld: Vector3;
  6988. /**
  6989. * Gets the OBB (object bounding box) directions
  6990. */
  6991. readonly directions: Vector3[];
  6992. /**
  6993. * Gets the 8 vectors representing the bounding box in world space
  6994. */
  6995. readonly vectorsWorld: Vector3[];
  6996. /**
  6997. * Gets the minimum vector in world space
  6998. */
  6999. readonly minimumWorld: Vector3;
  7000. /**
  7001. * Gets the maximum vector in world space
  7002. */
  7003. readonly maximumWorld: Vector3;
  7004. /**
  7005. * Gets the minimum vector in local space
  7006. */
  7007. readonly minimum: Vector3;
  7008. /**
  7009. * Gets the maximum vector in local space
  7010. */
  7011. readonly maximum: Vector3;
  7012. private _worldMatrix;
  7013. private static readonly TmpVector3;
  7014. /**
  7015. * @hidden
  7016. */
  7017. _tag: number;
  7018. /**
  7019. * Creates a new bounding box
  7020. * @param min defines the minimum vector (in local space)
  7021. * @param max defines the maximum vector (in local space)
  7022. * @param worldMatrix defines the new world matrix
  7023. */
  7024. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7025. /**
  7026. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7027. * @param min defines the new minimum vector (in local space)
  7028. * @param max defines the new maximum vector (in local space)
  7029. * @param worldMatrix defines the new world matrix
  7030. */
  7031. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7032. /**
  7033. * Scale the current bounding box by applying a scale factor
  7034. * @param factor defines the scale factor to apply
  7035. * @returns the current bounding box
  7036. */
  7037. scale(factor: number): BoundingBox;
  7038. /**
  7039. * Gets the world matrix of the bounding box
  7040. * @returns a matrix
  7041. */
  7042. getWorldMatrix(): DeepImmutable<Matrix>;
  7043. /** @hidden */
  7044. _update(world: DeepImmutable<Matrix>): void;
  7045. /**
  7046. * Tests if the bounding box is intersecting the frustum planes
  7047. * @param frustumPlanes defines the frustum planes to test
  7048. * @returns true if there is an intersection
  7049. */
  7050. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7051. /**
  7052. * Tests if the bounding box is entirely inside the frustum planes
  7053. * @param frustumPlanes defines the frustum planes to test
  7054. * @returns true if there is an inclusion
  7055. */
  7056. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7057. /**
  7058. * Tests if a point is inside the bounding box
  7059. * @param point defines the point to test
  7060. * @returns true if the point is inside the bounding box
  7061. */
  7062. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7063. /**
  7064. * Tests if the bounding box intersects with a bounding sphere
  7065. * @param sphere defines the sphere to test
  7066. * @returns true if there is an intersection
  7067. */
  7068. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7069. /**
  7070. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7071. * @param min defines the min vector to use
  7072. * @param max defines the max vector to use
  7073. * @returns true if there is an intersection
  7074. */
  7075. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7076. /**
  7077. * Tests if two bounding boxes are intersections
  7078. * @param box0 defines the first box to test
  7079. * @param box1 defines the second box to test
  7080. * @returns true if there is an intersection
  7081. */
  7082. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7083. /**
  7084. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7085. * @param minPoint defines the minimum vector of the bounding box
  7086. * @param maxPoint defines the maximum vector of the bounding box
  7087. * @param sphereCenter defines the sphere center
  7088. * @param sphereRadius defines the sphere radius
  7089. * @returns true if there is an intersection
  7090. */
  7091. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7092. /**
  7093. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7094. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7095. * @param frustumPlanes defines the frustum planes to test
  7096. * @return true if there is an inclusion
  7097. */
  7098. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7099. /**
  7100. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7101. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7102. * @param frustumPlanes defines the frustum planes to test
  7103. * @return true if there is an intersection
  7104. */
  7105. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7106. }
  7107. }
  7108. declare module "babylonjs/Collisions/collider" {
  7109. import { Nullable, IndicesArray } from "babylonjs/types";
  7110. import { Vector3, Plane } from "babylonjs/Maths/math";
  7111. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7112. /** @hidden */
  7113. export class Collider {
  7114. /** Define if a collision was found */
  7115. collisionFound: boolean;
  7116. /**
  7117. * Define last intersection point in local space
  7118. */
  7119. intersectionPoint: Vector3;
  7120. /**
  7121. * Define last collided mesh
  7122. */
  7123. collidedMesh: Nullable<AbstractMesh>;
  7124. private _collisionPoint;
  7125. private _planeIntersectionPoint;
  7126. private _tempVector;
  7127. private _tempVector2;
  7128. private _tempVector3;
  7129. private _tempVector4;
  7130. private _edge;
  7131. private _baseToVertex;
  7132. private _destinationPoint;
  7133. private _slidePlaneNormal;
  7134. private _displacementVector;
  7135. /** @hidden */
  7136. _radius: Vector3;
  7137. /** @hidden */
  7138. _retry: number;
  7139. private _velocity;
  7140. private _basePoint;
  7141. private _epsilon;
  7142. /** @hidden */
  7143. _velocityWorldLength: number;
  7144. /** @hidden */
  7145. _basePointWorld: Vector3;
  7146. private _velocityWorld;
  7147. private _normalizedVelocity;
  7148. /** @hidden */
  7149. _initialVelocity: Vector3;
  7150. /** @hidden */
  7151. _initialPosition: Vector3;
  7152. private _nearestDistance;
  7153. private _collisionMask;
  7154. collisionMask: number;
  7155. /**
  7156. * Gets the plane normal used to compute the sliding response (in local space)
  7157. */
  7158. readonly slidePlaneNormal: Vector3;
  7159. /** @hidden */
  7160. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7161. /** @hidden */
  7162. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7163. /** @hidden */
  7164. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7165. /** @hidden */
  7166. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7167. /** @hidden */
  7168. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7169. /** @hidden */
  7170. _getResponse(pos: Vector3, vel: Vector3): void;
  7171. }
  7172. }
  7173. declare module "babylonjs/Culling/boundingInfo" {
  7174. import { DeepImmutable } from "babylonjs/types";
  7175. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7176. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7177. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7178. import { Collider } from "babylonjs/Collisions/collider";
  7179. /**
  7180. * Interface for cullable objects
  7181. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7182. */
  7183. export interface ICullable {
  7184. /**
  7185. * Checks if the object or part of the object is in the frustum
  7186. * @param frustumPlanes Camera near/planes
  7187. * @returns true if the object is in frustum otherwise false
  7188. */
  7189. isInFrustum(frustumPlanes: Plane[]): boolean;
  7190. /**
  7191. * Checks if a cullable object (mesh...) is in the camera frustum
  7192. * Unlike isInFrustum this cheks the full bounding box
  7193. * @param frustumPlanes Camera near/planes
  7194. * @returns true if the object is in frustum otherwise false
  7195. */
  7196. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7197. }
  7198. /**
  7199. * Info for a bounding data of a mesh
  7200. */
  7201. export class BoundingInfo implements ICullable {
  7202. /**
  7203. * Bounding box for the mesh
  7204. */
  7205. readonly boundingBox: BoundingBox;
  7206. /**
  7207. * Bounding sphere for the mesh
  7208. */
  7209. readonly boundingSphere: BoundingSphere;
  7210. private _isLocked;
  7211. private static readonly TmpVector3;
  7212. /**
  7213. * Constructs bounding info
  7214. * @param minimum min vector of the bounding box/sphere
  7215. * @param maximum max vector of the bounding box/sphere
  7216. * @param worldMatrix defines the new world matrix
  7217. */
  7218. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7219. /**
  7220. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7221. * @param min defines the new minimum vector (in local space)
  7222. * @param max defines the new maximum vector (in local space)
  7223. * @param worldMatrix defines the new world matrix
  7224. */
  7225. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7226. /**
  7227. * min vector of the bounding box/sphere
  7228. */
  7229. readonly minimum: Vector3;
  7230. /**
  7231. * max vector of the bounding box/sphere
  7232. */
  7233. readonly maximum: Vector3;
  7234. /**
  7235. * If the info is locked and won't be updated to avoid perf overhead
  7236. */
  7237. isLocked: boolean;
  7238. /**
  7239. * Updates the bounding sphere and box
  7240. * @param world world matrix to be used to update
  7241. */
  7242. update(world: DeepImmutable<Matrix>): void;
  7243. /**
  7244. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7245. * @param center New center of the bounding info
  7246. * @param extend New extend of the bounding info
  7247. * @returns the current bounding info
  7248. */
  7249. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7250. /**
  7251. * Scale the current bounding info by applying a scale factor
  7252. * @param factor defines the scale factor to apply
  7253. * @returns the current bounding info
  7254. */
  7255. scale(factor: number): BoundingInfo;
  7256. /**
  7257. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7258. * @param frustumPlanes defines the frustum to test
  7259. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7260. * @returns true if the bounding info is in the frustum planes
  7261. */
  7262. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7263. /**
  7264. * Gets the world distance between the min and max points of the bounding box
  7265. */
  7266. readonly diagonalLength: number;
  7267. /**
  7268. * Checks if a cullable object (mesh...) is in the camera frustum
  7269. * Unlike isInFrustum this cheks the full bounding box
  7270. * @param frustumPlanes Camera near/planes
  7271. * @returns true if the object is in frustum otherwise false
  7272. */
  7273. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7274. /** @hidden */
  7275. _checkCollision(collider: Collider): boolean;
  7276. /**
  7277. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7278. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7279. * @param point the point to check intersection with
  7280. * @returns if the point intersects
  7281. */
  7282. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7283. /**
  7284. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7285. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7286. * @param boundingInfo the bounding info to check intersection with
  7287. * @param precise if the intersection should be done using OBB
  7288. * @returns if the bounding info intersects
  7289. */
  7290. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7291. }
  7292. }
  7293. declare module "babylonjs/Misc/smartArray" {
  7294. /**
  7295. * Defines an array and its length.
  7296. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7297. */
  7298. export interface ISmartArrayLike<T> {
  7299. /**
  7300. * The data of the array.
  7301. */
  7302. data: Array<T>;
  7303. /**
  7304. * The active length of the array.
  7305. */
  7306. length: number;
  7307. }
  7308. /**
  7309. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7310. */
  7311. export class SmartArray<T> implements ISmartArrayLike<T> {
  7312. /**
  7313. * The full set of data from the array.
  7314. */
  7315. data: Array<T>;
  7316. /**
  7317. * The active length of the array.
  7318. */
  7319. length: number;
  7320. protected _id: number;
  7321. /**
  7322. * Instantiates a Smart Array.
  7323. * @param capacity defines the default capacity of the array.
  7324. */
  7325. constructor(capacity: number);
  7326. /**
  7327. * Pushes a value at the end of the active data.
  7328. * @param value defines the object to push in the array.
  7329. */
  7330. push(value: T): void;
  7331. /**
  7332. * Iterates over the active data and apply the lambda to them.
  7333. * @param func defines the action to apply on each value.
  7334. */
  7335. forEach(func: (content: T) => void): void;
  7336. /**
  7337. * Sorts the full sets of data.
  7338. * @param compareFn defines the comparison function to apply.
  7339. */
  7340. sort(compareFn: (a: T, b: T) => number): void;
  7341. /**
  7342. * Resets the active data to an empty array.
  7343. */
  7344. reset(): void;
  7345. /**
  7346. * Releases all the data from the array as well as the array.
  7347. */
  7348. dispose(): void;
  7349. /**
  7350. * Concats the active data with a given array.
  7351. * @param array defines the data to concatenate with.
  7352. */
  7353. concat(array: any): void;
  7354. /**
  7355. * Returns the position of a value in the active data.
  7356. * @param value defines the value to find the index for
  7357. * @returns the index if found in the active data otherwise -1
  7358. */
  7359. indexOf(value: T): number;
  7360. /**
  7361. * Returns whether an element is part of the active data.
  7362. * @param value defines the value to look for
  7363. * @returns true if found in the active data otherwise false
  7364. */
  7365. contains(value: T): boolean;
  7366. private static _GlobalId;
  7367. }
  7368. /**
  7369. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7370. * The data in this array can only be present once
  7371. */
  7372. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7373. private _duplicateId;
  7374. /**
  7375. * Pushes a value at the end of the active data.
  7376. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7377. * @param value defines the object to push in the array.
  7378. */
  7379. push(value: T): void;
  7380. /**
  7381. * Pushes a value at the end of the active data.
  7382. * If the data is already present, it won t be added again
  7383. * @param value defines the object to push in the array.
  7384. * @returns true if added false if it was already present
  7385. */
  7386. pushNoDuplicate(value: T): boolean;
  7387. /**
  7388. * Resets the active data to an empty array.
  7389. */
  7390. reset(): void;
  7391. /**
  7392. * Concats the active data with a given array.
  7393. * This ensures no dupplicate will be present in the result.
  7394. * @param array defines the data to concatenate with.
  7395. */
  7396. concatWithNoDuplicate(array: any): void;
  7397. }
  7398. }
  7399. declare module "babylonjs/Materials/multiMaterial" {
  7400. import { Nullable } from "babylonjs/types";
  7401. import { Scene } from "babylonjs/scene";
  7402. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7403. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  7404. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7405. import { Material } from "babylonjs/Materials/material";
  7406. /**
  7407. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7408. * separate meshes. This can be use to improve performances.
  7409. * @see http://doc.babylonjs.com/how_to/multi_materials
  7410. */
  7411. export class MultiMaterial extends Material {
  7412. private _subMaterials;
  7413. /**
  7414. * Gets or Sets the list of Materials used within the multi material.
  7415. * They need to be ordered according to the submeshes order in the associated mesh
  7416. */
  7417. subMaterials: Nullable<Material>[];
  7418. /**
  7419. * Function used to align with Node.getChildren()
  7420. * @returns the list of Materials used within the multi material
  7421. */
  7422. getChildren(): Nullable<Material>[];
  7423. /**
  7424. * Instantiates a new Multi Material
  7425. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7426. * separate meshes. This can be use to improve performances.
  7427. * @see http://doc.babylonjs.com/how_to/multi_materials
  7428. * @param name Define the name in the scene
  7429. * @param scene Define the scene the material belongs to
  7430. */
  7431. constructor(name: string, scene: Scene);
  7432. private _hookArray;
  7433. /**
  7434. * Get one of the submaterial by its index in the submaterials array
  7435. * @param index The index to look the sub material at
  7436. * @returns The Material if the index has been defined
  7437. */
  7438. getSubMaterial(index: number): Nullable<Material>;
  7439. /**
  7440. * Get the list of active textures for the whole sub materials list.
  7441. * @returns All the textures that will be used during the rendering
  7442. */
  7443. getActiveTextures(): BaseTexture[];
  7444. /**
  7445. * Gets the current class name of the material e.g. "MultiMaterial"
  7446. * Mainly use in serialization.
  7447. * @returns the class name
  7448. */
  7449. getClassName(): string;
  7450. /**
  7451. * Checks if the material is ready to render the requested sub mesh
  7452. * @param mesh Define the mesh the submesh belongs to
  7453. * @param subMesh Define the sub mesh to look readyness for
  7454. * @param useInstances Define whether or not the material is used with instances
  7455. * @returns true if ready, otherwise false
  7456. */
  7457. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7458. /**
  7459. * Clones the current material and its related sub materials
  7460. * @param name Define the name of the newly cloned material
  7461. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7462. * @returns the cloned material
  7463. */
  7464. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7465. /**
  7466. * Serializes the materials into a JSON representation.
  7467. * @returns the JSON representation
  7468. */
  7469. serialize(): any;
  7470. /**
  7471. * Dispose the material and release its associated resources
  7472. * @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)
  7473. * @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)
  7474. * @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)
  7475. */
  7476. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7477. /**
  7478. * Creates a MultiMaterial from parsed MultiMaterial data.
  7479. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7480. * @param scene defines the hosting scene
  7481. * @returns a new MultiMaterial
  7482. */
  7483. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7484. }
  7485. }
  7486. declare module "babylonjs/Loading/sceneLoaderFlags" {
  7487. /**
  7488. * Class used to represent data loading progression
  7489. */
  7490. export class SceneLoaderFlags {
  7491. private static _ForceFullSceneLoadingForIncremental;
  7492. private static _ShowLoadingScreen;
  7493. private static _CleanBoneMatrixWeights;
  7494. private static _loggingLevel;
  7495. /**
  7496. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7497. */
  7498. static ForceFullSceneLoadingForIncremental: boolean;
  7499. /**
  7500. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7501. */
  7502. static ShowLoadingScreen: boolean;
  7503. /**
  7504. * Defines the current logging level (while loading the scene)
  7505. * @ignorenaming
  7506. */
  7507. static loggingLevel: number;
  7508. /**
  7509. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7510. */
  7511. static CleanBoneMatrixWeights: boolean;
  7512. }
  7513. }
  7514. declare module "babylonjs/Meshes/transformNode" {
  7515. import { DeepImmutable } from "babylonjs/types";
  7516. import { Observable } from "babylonjs/Misc/observable";
  7517. import { Nullable } from "babylonjs/types";
  7518. import { Camera } from "babylonjs/Cameras/camera";
  7519. import { Scene } from "babylonjs/scene";
  7520. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  7521. import { Node } from "babylonjs/node";
  7522. import { Bone } from "babylonjs/Bones/bone";
  7523. /**
  7524. * 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.
  7525. * @see https://doc.babylonjs.com/how_to/transformnode
  7526. */
  7527. export class TransformNode extends Node {
  7528. /**
  7529. * Object will not rotate to face the camera
  7530. */
  7531. static BILLBOARDMODE_NONE: number;
  7532. /**
  7533. * Object will rotate to face the camera but only on the x axis
  7534. */
  7535. static BILLBOARDMODE_X: number;
  7536. /**
  7537. * Object will rotate to face the camera but only on the y axis
  7538. */
  7539. static BILLBOARDMODE_Y: number;
  7540. /**
  7541. * Object will rotate to face the camera but only on the z axis
  7542. */
  7543. static BILLBOARDMODE_Z: number;
  7544. /**
  7545. * Object will rotate to face the camera
  7546. */
  7547. static BILLBOARDMODE_ALL: number;
  7548. private _forward;
  7549. private _forwardInverted;
  7550. private _up;
  7551. private _right;
  7552. private _rightInverted;
  7553. private _position;
  7554. private _rotation;
  7555. private _rotationQuaternion;
  7556. protected _scaling: Vector3;
  7557. protected _isDirty: boolean;
  7558. private _transformToBoneReferal;
  7559. /**
  7560. * Set the billboard mode. Default is 0.
  7561. *
  7562. * | Value | Type | Description |
  7563. * | --- | --- | --- |
  7564. * | 0 | BILLBOARDMODE_NONE | |
  7565. * | 1 | BILLBOARDMODE_X | |
  7566. * | 2 | BILLBOARDMODE_Y | |
  7567. * | 4 | BILLBOARDMODE_Z | |
  7568. * | 7 | BILLBOARDMODE_ALL | |
  7569. *
  7570. */
  7571. billboardMode: number;
  7572. /**
  7573. * 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
  7574. */
  7575. scalingDeterminant: number;
  7576. /**
  7577. * Sets the distance of the object to max, often used by skybox
  7578. */
  7579. infiniteDistance: boolean;
  7580. /**
  7581. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7582. * By default the system will update normals to compensate
  7583. */
  7584. ignoreNonUniformScaling: boolean;
  7585. /** @hidden */
  7586. _poseMatrix: Matrix;
  7587. /** @hidden */
  7588. _localMatrix: Matrix;
  7589. private _absolutePosition;
  7590. private _pivotMatrix;
  7591. private _pivotMatrixInverse;
  7592. protected _postMultiplyPivotMatrix: boolean;
  7593. private _tempMatrix;
  7594. private _tempMatrix2;
  7595. protected _isWorldMatrixFrozen: boolean;
  7596. /** @hidden */
  7597. _indexInSceneTransformNodesArray: number;
  7598. /**
  7599. * An event triggered after the world matrix is updated
  7600. */
  7601. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7602. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7603. /**
  7604. * Gets a string identifying the name of the class
  7605. * @returns "TransformNode" string
  7606. */
  7607. getClassName(): string;
  7608. /**
  7609. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7610. */
  7611. position: Vector3;
  7612. /**
  7613. * 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)).
  7614. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7615. */
  7616. rotation: Vector3;
  7617. /**
  7618. * 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)).
  7619. */
  7620. scaling: Vector3;
  7621. /**
  7622. * 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).
  7623. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7624. */
  7625. rotationQuaternion: Nullable<Quaternion>;
  7626. /**
  7627. * The forward direction of that transform in world space.
  7628. */
  7629. readonly forward: Vector3;
  7630. /**
  7631. * The up direction of that transform in world space.
  7632. */
  7633. readonly up: Vector3;
  7634. /**
  7635. * The right direction of that transform in world space.
  7636. */
  7637. readonly right: Vector3;
  7638. /**
  7639. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7640. * @param matrix the matrix to copy the pose from
  7641. * @returns this TransformNode.
  7642. */
  7643. updatePoseMatrix(matrix: Matrix): TransformNode;
  7644. /**
  7645. * Returns the mesh Pose matrix.
  7646. * @returns the pose matrix
  7647. */
  7648. getPoseMatrix(): Matrix;
  7649. /** @hidden */
  7650. _isSynchronized(): boolean;
  7651. /** @hidden */
  7652. _initCache(): void;
  7653. /**
  7654. * Flag the transform node as dirty (Forcing it to update everything)
  7655. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7656. * @returns this transform node
  7657. */
  7658. markAsDirty(property: string): TransformNode;
  7659. /**
  7660. * Returns the current mesh absolute position.
  7661. * Returns a Vector3.
  7662. */
  7663. readonly absolutePosition: Vector3;
  7664. /**
  7665. * Sets a new matrix to apply before all other transformation
  7666. * @param matrix defines the transform matrix
  7667. * @returns the current TransformNode
  7668. */
  7669. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7670. /**
  7671. * Sets a new pivot matrix to the current node
  7672. * @param matrix defines the new pivot matrix to use
  7673. * @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
  7674. * @returns the current TransformNode
  7675. */
  7676. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7677. /**
  7678. * Returns the mesh pivot matrix.
  7679. * Default : Identity.
  7680. * @returns the matrix
  7681. */
  7682. getPivotMatrix(): Matrix;
  7683. /**
  7684. * Prevents the World matrix to be computed any longer.
  7685. * @returns the TransformNode.
  7686. */
  7687. freezeWorldMatrix(): TransformNode;
  7688. /**
  7689. * Allows back the World matrix computation.
  7690. * @returns the TransformNode.
  7691. */
  7692. unfreezeWorldMatrix(): this;
  7693. /**
  7694. * True if the World matrix has been frozen.
  7695. */
  7696. readonly isWorldMatrixFrozen: boolean;
  7697. /**
  7698. * Retuns the mesh absolute position in the World.
  7699. * @returns a Vector3.
  7700. */
  7701. getAbsolutePosition(): Vector3;
  7702. /**
  7703. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7704. * @param absolutePosition the absolute position to set
  7705. * @returns the TransformNode.
  7706. */
  7707. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7708. /**
  7709. * Sets the mesh position in its local space.
  7710. * @param vector3 the position to set in localspace
  7711. * @returns the TransformNode.
  7712. */
  7713. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7714. /**
  7715. * Returns the mesh position in the local space from the current World matrix values.
  7716. * @returns a new Vector3.
  7717. */
  7718. getPositionExpressedInLocalSpace(): Vector3;
  7719. /**
  7720. * Translates the mesh along the passed Vector3 in its local space.
  7721. * @param vector3 the distance to translate in localspace
  7722. * @returns the TransformNode.
  7723. */
  7724. locallyTranslate(vector3: Vector3): TransformNode;
  7725. private static _lookAtVectorCache;
  7726. /**
  7727. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7728. * @param targetPoint the position (must be in same space as current mesh) to look at
  7729. * @param yawCor optional yaw (y-axis) correction in radians
  7730. * @param pitchCor optional pitch (x-axis) correction in radians
  7731. * @param rollCor optional roll (z-axis) correction in radians
  7732. * @param space the choosen space of the target
  7733. * @returns the TransformNode.
  7734. */
  7735. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7736. /**
  7737. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7738. * This Vector3 is expressed in the World space.
  7739. * @param localAxis axis to rotate
  7740. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7741. */
  7742. getDirection(localAxis: Vector3): Vector3;
  7743. /**
  7744. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7745. * localAxis is expressed in the mesh local space.
  7746. * result is computed in the Wordl space from the mesh World matrix.
  7747. * @param localAxis axis to rotate
  7748. * @param result the resulting transformnode
  7749. * @returns this TransformNode.
  7750. */
  7751. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7752. /**
  7753. * Sets this transform node rotation to the given local axis.
  7754. * @param localAxis the axis in local space
  7755. * @param yawCor optional yaw (y-axis) correction in radians
  7756. * @param pitchCor optional pitch (x-axis) correction in radians
  7757. * @param rollCor optional roll (z-axis) correction in radians
  7758. * @returns this TransformNode
  7759. */
  7760. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7761. /**
  7762. * Sets a new pivot point to the current node
  7763. * @param point defines the new pivot point to use
  7764. * @param space defines if the point is in world or local space (local by default)
  7765. * @returns the current TransformNode
  7766. */
  7767. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7768. /**
  7769. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7770. * @returns the pivot point
  7771. */
  7772. getPivotPoint(): Vector3;
  7773. /**
  7774. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7775. * @param result the vector3 to store the result
  7776. * @returns this TransformNode.
  7777. */
  7778. getPivotPointToRef(result: Vector3): TransformNode;
  7779. /**
  7780. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7781. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7782. */
  7783. getAbsolutePivotPoint(): Vector3;
  7784. /**
  7785. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7786. * @param result vector3 to store the result
  7787. * @returns this TransformNode.
  7788. */
  7789. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7790. /**
  7791. * Defines the passed node as the parent of the current node.
  7792. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7793. * @see https://doc.babylonjs.com/how_to/parenting
  7794. * @param node the node ot set as the parent
  7795. * @returns this TransformNode.
  7796. */
  7797. setParent(node: Nullable<Node>): TransformNode;
  7798. private _nonUniformScaling;
  7799. /**
  7800. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7801. */
  7802. readonly nonUniformScaling: boolean;
  7803. /** @hidden */
  7804. _updateNonUniformScalingState(value: boolean): boolean;
  7805. /**
  7806. * Attach the current TransformNode to another TransformNode associated with a bone
  7807. * @param bone Bone affecting the TransformNode
  7808. * @param affectedTransformNode TransformNode associated with the bone
  7809. * @returns this object
  7810. */
  7811. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7812. /**
  7813. * Detach the transform node if its associated with a bone
  7814. * @returns this object
  7815. */
  7816. detachFromBone(): TransformNode;
  7817. private static _rotationAxisCache;
  7818. /**
  7819. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7820. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7821. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7822. * The passed axis is also normalized.
  7823. * @param axis the axis to rotate around
  7824. * @param amount the amount to rotate in radians
  7825. * @param space Space to rotate in (Default: local)
  7826. * @returns the TransformNode.
  7827. */
  7828. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7829. /**
  7830. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7831. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7832. * The passed axis is also normalized. .
  7833. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7834. * @param point the point to rotate around
  7835. * @param axis the axis to rotate around
  7836. * @param amount the amount to rotate in radians
  7837. * @returns the TransformNode
  7838. */
  7839. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7840. /**
  7841. * Translates the mesh along the axis vector for the passed distance in the given space.
  7842. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7843. * @param axis the axis to translate in
  7844. * @param distance the distance to translate
  7845. * @param space Space to rotate in (Default: local)
  7846. * @returns the TransformNode.
  7847. */
  7848. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7849. /**
  7850. * Adds a rotation step to the mesh current rotation.
  7851. * x, y, z are Euler angles expressed in radians.
  7852. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7853. * This means this rotation is made in the mesh local space only.
  7854. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7855. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7856. * ```javascript
  7857. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7858. * ```
  7859. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7860. * 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.
  7861. * @param x Rotation to add
  7862. * @param y Rotation to add
  7863. * @param z Rotation to add
  7864. * @returns the TransformNode.
  7865. */
  7866. addRotation(x: number, y: number, z: number): TransformNode;
  7867. /**
  7868. * Computes the world matrix of the node
  7869. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7870. * @returns the world matrix
  7871. */
  7872. computeWorldMatrix(force?: boolean): Matrix;
  7873. protected _afterComputeWorldMatrix(): void;
  7874. /**
  7875. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7876. * @param func callback function to add
  7877. *
  7878. * @returns the TransformNode.
  7879. */
  7880. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7881. /**
  7882. * Removes a registered callback function.
  7883. * @param func callback function to remove
  7884. * @returns the TransformNode.
  7885. */
  7886. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7887. /**
  7888. * Gets the position of the current mesh in camera space
  7889. * @param camera defines the camera to use
  7890. * @returns a position
  7891. */
  7892. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7893. /**
  7894. * Returns the distance from the mesh to the active camera
  7895. * @param camera defines the camera to use
  7896. * @returns the distance
  7897. */
  7898. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7899. /**
  7900. * Clone the current transform node
  7901. * @param name Name of the new clone
  7902. * @param newParent New parent for the clone
  7903. * @param doNotCloneChildren Do not clone children hierarchy
  7904. * @returns the new transform node
  7905. */
  7906. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7907. /**
  7908. * Serializes the objects information.
  7909. * @param currentSerializationObject defines the object to serialize in
  7910. * @returns the serialized object
  7911. */
  7912. serialize(currentSerializationObject?: any): any;
  7913. /**
  7914. * Returns a new TransformNode object parsed from the source provided.
  7915. * @param parsedTransformNode is the source.
  7916. * @param scene the scne the object belongs to
  7917. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7918. * @returns a new TransformNode object parsed from the source provided.
  7919. */
  7920. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7921. /**
  7922. * Get all child-transformNodes of this node
  7923. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  7924. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  7925. * @returns an array of TransformNode
  7926. */
  7927. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7928. /**
  7929. * Releases resources associated with this transform node.
  7930. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7931. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7932. */
  7933. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7934. }
  7935. }
  7936. declare module "babylonjs/Animations/animationPropertiesOverride" {
  7937. /**
  7938. * Class used to override all child animations of a given target
  7939. */
  7940. export class AnimationPropertiesOverride {
  7941. /**
  7942. * Gets or sets a value indicating if animation blending must be used
  7943. */
  7944. enableBlending: boolean;
  7945. /**
  7946. * Gets or sets the blending speed to use when enableBlending is true
  7947. */
  7948. blendingSpeed: number;
  7949. /**
  7950. * Gets or sets the default loop mode to use
  7951. */
  7952. loopMode: number;
  7953. }
  7954. }
  7955. declare module "babylonjs/Bones/bone" {
  7956. import { Skeleton } from "babylonjs/Bones/skeleton";
  7957. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  7958. import { Nullable } from "babylonjs/types";
  7959. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7960. import { TransformNode } from "babylonjs/Meshes/transformNode";
  7961. import { Node } from "babylonjs/node";
  7962. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  7963. /**
  7964. * Class used to store bone information
  7965. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7966. */
  7967. export class Bone extends Node {
  7968. /**
  7969. * defines the bone name
  7970. */
  7971. name: string;
  7972. private static _tmpVecs;
  7973. private static _tmpQuat;
  7974. private static _tmpMats;
  7975. /**
  7976. * Gets the list of child bones
  7977. */
  7978. children: Bone[];
  7979. /** Gets the animations associated with this bone */
  7980. animations: import("babylonjs/Animations/animation").Animation[];
  7981. /**
  7982. * Gets or sets bone length
  7983. */
  7984. length: number;
  7985. /**
  7986. * @hidden Internal only
  7987. * Set this value to map this bone to a different index in the transform matrices
  7988. * Set this value to -1 to exclude the bone from the transform matrices
  7989. */
  7990. _index: Nullable<number>;
  7991. private _skeleton;
  7992. private _localMatrix;
  7993. private _restPose;
  7994. private _baseMatrix;
  7995. private _absoluteTransform;
  7996. private _invertedAbsoluteTransform;
  7997. private _parent;
  7998. private _scalingDeterminant;
  7999. private _worldTransform;
  8000. private _localScaling;
  8001. private _localRotation;
  8002. private _localPosition;
  8003. private _needToDecompose;
  8004. private _needToCompose;
  8005. /** @hidden */
  8006. _linkedTransformNode: Nullable<TransformNode>;
  8007. /** @hidden */
  8008. /** @hidden */
  8009. _matrix: Matrix;
  8010. /**
  8011. * Create a new bone
  8012. * @param name defines the bone name
  8013. * @param skeleton defines the parent skeleton
  8014. * @param parentBone defines the parent (can be null if the bone is the root)
  8015. * @param localMatrix defines the local matrix
  8016. * @param restPose defines the rest pose matrix
  8017. * @param baseMatrix defines the base matrix
  8018. * @param index defines index of the bone in the hiearchy
  8019. */
  8020. constructor(
  8021. /**
  8022. * defines the bone name
  8023. */
  8024. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8025. /**
  8026. * Gets the current object class name.
  8027. * @return the class name
  8028. */
  8029. getClassName(): string;
  8030. /**
  8031. * Gets the parent skeleton
  8032. * @returns a skeleton
  8033. */
  8034. getSkeleton(): Skeleton;
  8035. /**
  8036. * Gets parent bone
  8037. * @returns a bone or null if the bone is the root of the bone hierarchy
  8038. */
  8039. getParent(): Nullable<Bone>;
  8040. /**
  8041. * Returns an array containing the root bones
  8042. * @returns an array containing the root bones
  8043. */
  8044. getChildren(): Array<Bone>;
  8045. /**
  8046. * Sets the parent bone
  8047. * @param parent defines the parent (can be null if the bone is the root)
  8048. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8049. */
  8050. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8051. /**
  8052. * Gets the local matrix
  8053. * @returns a matrix
  8054. */
  8055. getLocalMatrix(): Matrix;
  8056. /**
  8057. * Gets the base matrix (initial matrix which remains unchanged)
  8058. * @returns a matrix
  8059. */
  8060. getBaseMatrix(): Matrix;
  8061. /**
  8062. * Gets the rest pose matrix
  8063. * @returns a matrix
  8064. */
  8065. getRestPose(): Matrix;
  8066. /**
  8067. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8068. */
  8069. getWorldMatrix(): Matrix;
  8070. /**
  8071. * Sets the local matrix to rest pose matrix
  8072. */
  8073. returnToRest(): void;
  8074. /**
  8075. * Gets the inverse of the absolute transform matrix.
  8076. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8077. * @returns a matrix
  8078. */
  8079. getInvertedAbsoluteTransform(): Matrix;
  8080. /**
  8081. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8082. * @returns a matrix
  8083. */
  8084. getAbsoluteTransform(): Matrix;
  8085. /**
  8086. * Links with the given transform node.
  8087. * The local matrix of this bone is copied from the transform node every frame.
  8088. * @param transformNode defines the transform node to link to
  8089. */
  8090. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8091. /** Gets or sets current position (in local space) */
  8092. position: Vector3;
  8093. /** Gets or sets current rotation (in local space) */
  8094. rotation: Vector3;
  8095. /** Gets or sets current rotation quaternion (in local space) */
  8096. rotationQuaternion: Quaternion;
  8097. /** Gets or sets current scaling (in local space) */
  8098. scaling: Vector3;
  8099. /**
  8100. * Gets the animation properties override
  8101. */
  8102. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8103. private _decompose;
  8104. private _compose;
  8105. /**
  8106. * Update the base and local matrices
  8107. * @param matrix defines the new base or local matrix
  8108. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8109. * @param updateLocalMatrix defines if the local matrix should be updated
  8110. */
  8111. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8112. /** @hidden */
  8113. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8114. /**
  8115. * Flag the bone as dirty (Forcing it to update everything)
  8116. */
  8117. markAsDirty(): void;
  8118. private _markAsDirtyAndCompose;
  8119. private _markAsDirtyAndDecompose;
  8120. /**
  8121. * Translate the bone in local or world space
  8122. * @param vec The amount to translate the bone
  8123. * @param space The space that the translation is in
  8124. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8125. */
  8126. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8127. /**
  8128. * Set the postion of the bone in local or world space
  8129. * @param position The position to set the bone
  8130. * @param space The space that the position is in
  8131. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8132. */
  8133. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8134. /**
  8135. * Set the absolute position of the bone (world space)
  8136. * @param position The position to set the bone
  8137. * @param mesh The mesh that this bone is attached to
  8138. */
  8139. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8140. /**
  8141. * Scale the bone on the x, y and z axes (in local space)
  8142. * @param x The amount to scale the bone on the x axis
  8143. * @param y The amount to scale the bone on the y axis
  8144. * @param z The amount to scale the bone on the z axis
  8145. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8146. */
  8147. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8148. /**
  8149. * Set the bone scaling in local space
  8150. * @param scale defines the scaling vector
  8151. */
  8152. setScale(scale: Vector3): void;
  8153. /**
  8154. * Gets the current scaling in local space
  8155. * @returns the current scaling vector
  8156. */
  8157. getScale(): Vector3;
  8158. /**
  8159. * Gets the current scaling in local space and stores it in a target vector
  8160. * @param result defines the target vector
  8161. */
  8162. getScaleToRef(result: Vector3): void;
  8163. /**
  8164. * Set the yaw, pitch, and roll of the bone in local or world space
  8165. * @param yaw The rotation of the bone on the y axis
  8166. * @param pitch The rotation of the bone on the x axis
  8167. * @param roll The rotation of the bone on the z axis
  8168. * @param space The space that the axes of rotation are in
  8169. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8170. */
  8171. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8172. /**
  8173. * Add a rotation to the bone on an axis in local or world space
  8174. * @param axis The axis to rotate the bone on
  8175. * @param amount The amount to rotate the bone
  8176. * @param space The space that the axis is in
  8177. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8178. */
  8179. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8180. /**
  8181. * Set the rotation of the bone to a particular axis angle in local or world space
  8182. * @param axis The axis to rotate the bone on
  8183. * @param angle The angle that the bone should be rotated to
  8184. * @param space The space that the axis is in
  8185. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8186. */
  8187. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8188. /**
  8189. * Set the euler rotation of the bone in local of world space
  8190. * @param rotation The euler rotation that the bone should be set to
  8191. * @param space The space that the rotation is in
  8192. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8193. */
  8194. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8195. /**
  8196. * Set the quaternion rotation of the bone in local of world space
  8197. * @param quat The quaternion rotation that the bone should be set to
  8198. * @param space The space that the rotation is in
  8199. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8200. */
  8201. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8202. /**
  8203. * Set the rotation matrix of the bone in local of world space
  8204. * @param rotMat The rotation matrix that the bone should be set to
  8205. * @param space The space that the rotation is in
  8206. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8207. */
  8208. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8209. private _rotateWithMatrix;
  8210. private _getNegativeRotationToRef;
  8211. /**
  8212. * Get the position of the bone in local or world space
  8213. * @param space The space that the returned position is in
  8214. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8215. * @returns The position of the bone
  8216. */
  8217. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8218. /**
  8219. * Copy the position of the bone to a vector3 in local or world space
  8220. * @param space The space that the returned position is in
  8221. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8222. * @param result The vector3 to copy the position to
  8223. */
  8224. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8225. /**
  8226. * Get the absolute position of the bone (world space)
  8227. * @param mesh The mesh that this bone is attached to
  8228. * @returns The absolute position of the bone
  8229. */
  8230. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8231. /**
  8232. * Copy the absolute position of the bone (world space) to the result param
  8233. * @param mesh The mesh that this bone is attached to
  8234. * @param result The vector3 to copy the absolute position to
  8235. */
  8236. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8237. /**
  8238. * Compute the absolute transforms of this bone and its children
  8239. */
  8240. computeAbsoluteTransforms(): void;
  8241. /**
  8242. * Get the world direction from an axis that is in the local space of the bone
  8243. * @param localAxis The local direction that is used to compute the world direction
  8244. * @param mesh The mesh that this bone is attached to
  8245. * @returns The world direction
  8246. */
  8247. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8248. /**
  8249. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8250. * @param localAxis The local direction that is used to compute the world direction
  8251. * @param mesh The mesh that this bone is attached to
  8252. * @param result The vector3 that the world direction will be copied to
  8253. */
  8254. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8255. /**
  8256. * Get the euler rotation of the bone in local or world space
  8257. * @param space The space that the rotation should be in
  8258. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8259. * @returns The euler rotation
  8260. */
  8261. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8262. /**
  8263. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8264. * @param space The space that the rotation should be in
  8265. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8266. * @param result The vector3 that the rotation should be copied to
  8267. */
  8268. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8269. /**
  8270. * Get the quaternion rotation of the bone in either local or world space
  8271. * @param space The space that the rotation should be in
  8272. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8273. * @returns The quaternion rotation
  8274. */
  8275. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8276. /**
  8277. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8278. * @param space The space that the rotation should be in
  8279. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8280. * @param result The quaternion that the rotation should be copied to
  8281. */
  8282. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8283. /**
  8284. * Get the rotation matrix of the bone in local or world space
  8285. * @param space The space that the rotation should be in
  8286. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8287. * @returns The rotation matrix
  8288. */
  8289. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8290. /**
  8291. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8292. * @param space The space that the rotation should be in
  8293. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8294. * @param result The quaternion that the rotation should be copied to
  8295. */
  8296. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8297. /**
  8298. * Get the world position of a point that is in the local space of the bone
  8299. * @param position The local position
  8300. * @param mesh The mesh that this bone is attached to
  8301. * @returns The world position
  8302. */
  8303. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8304. /**
  8305. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8306. * @param position The local position
  8307. * @param mesh The mesh that this bone is attached to
  8308. * @param result The vector3 that the world position should be copied to
  8309. */
  8310. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8311. /**
  8312. * Get the local position of a point that is in world space
  8313. * @param position The world position
  8314. * @param mesh The mesh that this bone is attached to
  8315. * @returns The local position
  8316. */
  8317. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8318. /**
  8319. * Get the local position of a point that is in world space and copy it to the result param
  8320. * @param position The world position
  8321. * @param mesh The mesh that this bone is attached to
  8322. * @param result The vector3 that the local position should be copied to
  8323. */
  8324. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8325. }
  8326. }
  8327. declare module "babylonjs/Misc/iInspectable" {
  8328. /**
  8329. * Enum that determines the text-wrapping mode to use.
  8330. */
  8331. export enum InspectableType {
  8332. /**
  8333. * Checkbox for booleans
  8334. */
  8335. Checkbox = 0,
  8336. /**
  8337. * Sliders for numbers
  8338. */
  8339. Slider = 1,
  8340. /**
  8341. * Vector3
  8342. */
  8343. Vector3 = 2,
  8344. /**
  8345. * Quaternions
  8346. */
  8347. Quaternion = 3,
  8348. /**
  8349. * Color3
  8350. */
  8351. Color3 = 4
  8352. }
  8353. /**
  8354. * Interface used to define custom inspectable properties.
  8355. * This interface is used by the inspector to display custom property grids
  8356. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8357. */
  8358. export interface IInspectable {
  8359. /**
  8360. * Gets the label to display
  8361. */
  8362. label: string;
  8363. /**
  8364. * Gets the name of the property to edit
  8365. */
  8366. propertyName: string;
  8367. /**
  8368. * Gets the type of the editor to use
  8369. */
  8370. type: InspectableType;
  8371. /**
  8372. * Gets the minimum value of the property when using in "slider" mode
  8373. */
  8374. min?: number;
  8375. /**
  8376. * Gets the maximum value of the property when using in "slider" mode
  8377. */
  8378. max?: number;
  8379. /**
  8380. * Gets the setp to use when using in "slider" mode
  8381. */
  8382. step?: number;
  8383. }
  8384. }
  8385. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8386. import { Nullable } from "babylonjs/types";
  8387. import { Scene } from "babylonjs/scene";
  8388. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8389. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8390. /**
  8391. * Class for creating a cube texture
  8392. */
  8393. export class CubeTexture extends BaseTexture {
  8394. private _delayedOnLoad;
  8395. /**
  8396. * The url of the texture
  8397. */
  8398. url: string;
  8399. /**
  8400. * Gets or sets the center of the bounding box associated with the cube texture.
  8401. * It must define where the camera used to render the texture was set
  8402. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8403. */
  8404. boundingBoxPosition: Vector3;
  8405. private _boundingBoxSize;
  8406. /**
  8407. * Gets or sets the size of the bounding box associated with the cube texture
  8408. * When defined, the cubemap will switch to local mode
  8409. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8410. * @example https://www.babylonjs-playground.com/#RNASML
  8411. */
  8412. /**
  8413. * Returns the bounding box size
  8414. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8415. */
  8416. boundingBoxSize: Vector3;
  8417. protected _rotationY: number;
  8418. /**
  8419. * Sets texture matrix rotation angle around Y axis in radians.
  8420. */
  8421. /**
  8422. * Gets texture matrix rotation angle around Y axis radians.
  8423. */
  8424. rotationY: number;
  8425. /**
  8426. * Are mip maps generated for this texture or not.
  8427. */
  8428. readonly noMipmap: boolean;
  8429. private _noMipmap;
  8430. private _files;
  8431. private _extensions;
  8432. private _textureMatrix;
  8433. private _format;
  8434. private _createPolynomials;
  8435. /** @hidden */
  8436. _prefiltered: boolean;
  8437. /**
  8438. * Creates a cube texture from an array of image urls
  8439. * @param files defines an array of image urls
  8440. * @param scene defines the hosting scene
  8441. * @param noMipmap specifies if mip maps are not used
  8442. * @returns a cube texture
  8443. */
  8444. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8445. /**
  8446. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8447. * @param url defines the url of the prefiltered texture
  8448. * @param scene defines the scene the texture is attached to
  8449. * @param forcedExtension defines the extension of the file if different from the url
  8450. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8451. * @return the prefiltered texture
  8452. */
  8453. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8454. /**
  8455. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8456. * as prefiltered data.
  8457. * @param rootUrl defines the url of the texture or the root name of the six images
  8458. * @param scene defines the scene the texture is attached to
  8459. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8460. * @param noMipmap defines if mipmaps should be created or not
  8461. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8462. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8463. * @param onError defines a callback triggered in case of error during load
  8464. * @param format defines the internal format to use for the texture once loaded
  8465. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8466. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8467. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8468. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8469. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8470. * @return the cube texture
  8471. */
  8472. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  8473. /**
  8474. * Get the current class name of the texture useful for serialization or dynamic coding.
  8475. * @returns "CubeTexture"
  8476. */
  8477. getClassName(): string;
  8478. /**
  8479. * Update the url (and optional buffer) of this texture if url was null during construction.
  8480. * @param url the url of the texture
  8481. * @param forcedExtension defines the extension to use
  8482. * @param onLoad callback called when the texture is loaded (defaults to null)
  8483. */
  8484. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8485. /**
  8486. * Delays loading of the cube texture
  8487. * @param forcedExtension defines the extension to use
  8488. */
  8489. delayLoad(forcedExtension?: string): void;
  8490. /**
  8491. * Returns the reflection texture matrix
  8492. * @returns the reflection texture matrix
  8493. */
  8494. getReflectionTextureMatrix(): Matrix;
  8495. /**
  8496. * Sets the reflection texture matrix
  8497. * @param value Reflection texture matrix
  8498. */
  8499. setReflectionTextureMatrix(value: Matrix): void;
  8500. /**
  8501. * Parses text to create a cube texture
  8502. * @param parsedTexture define the serialized text to read from
  8503. * @param scene defines the hosting scene
  8504. * @param rootUrl defines the root url of the cube texture
  8505. * @returns a cube texture
  8506. */
  8507. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8508. /**
  8509. * Makes a clone, or deep copy, of the cube texture
  8510. * @returns a new cube texture
  8511. */
  8512. clone(): CubeTexture;
  8513. }
  8514. }
  8515. declare module "babylonjs/Shaders/postprocess.vertex" {
  8516. /** @hidden */
  8517. export var postprocessVertexShader: {
  8518. name: string;
  8519. shader: string;
  8520. };
  8521. }
  8522. declare module "babylonjs/Cameras/targetCamera" {
  8523. import { Nullable } from "babylonjs/types";
  8524. import { Camera } from "babylonjs/Cameras/camera";
  8525. import { Scene } from "babylonjs/scene";
  8526. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8527. /**
  8528. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8529. * This is the base of the follow, arc rotate cameras and Free camera
  8530. * @see http://doc.babylonjs.com/features/cameras
  8531. */
  8532. export class TargetCamera extends Camera {
  8533. private static _RigCamTransformMatrix;
  8534. private static _TargetTransformMatrix;
  8535. private static _TargetFocalPoint;
  8536. /**
  8537. * Define the current direction the camera is moving to
  8538. */
  8539. cameraDirection: Vector3;
  8540. /**
  8541. * Define the current rotation the camera is rotating to
  8542. */
  8543. cameraRotation: Vector2;
  8544. /**
  8545. * When set, the up vector of the camera will be updated by the rotation of the camera
  8546. */
  8547. updateUpVectorFromRotation: boolean;
  8548. private _tmpQuaternion;
  8549. /**
  8550. * Define the current rotation of the camera
  8551. */
  8552. rotation: Vector3;
  8553. /**
  8554. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8555. */
  8556. rotationQuaternion: Quaternion;
  8557. /**
  8558. * Define the current speed of the camera
  8559. */
  8560. speed: number;
  8561. /**
  8562. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8563. * around all axis.
  8564. */
  8565. noRotationConstraint: boolean;
  8566. /**
  8567. * Define the current target of the camera as an object or a position.
  8568. */
  8569. lockedTarget: any;
  8570. /** @hidden */
  8571. _currentTarget: Vector3;
  8572. /** @hidden */
  8573. _initialFocalDistance: number;
  8574. /** @hidden */
  8575. _viewMatrix: Matrix;
  8576. /** @hidden */
  8577. _camMatrix: Matrix;
  8578. /** @hidden */
  8579. _cameraTransformMatrix: Matrix;
  8580. /** @hidden */
  8581. _cameraRotationMatrix: Matrix;
  8582. /** @hidden */
  8583. _referencePoint: Vector3;
  8584. /** @hidden */
  8585. _transformedReferencePoint: Vector3;
  8586. protected _globalCurrentTarget: Vector3;
  8587. protected _globalCurrentUpVector: Vector3;
  8588. /** @hidden */
  8589. _reset: () => void;
  8590. private _defaultUp;
  8591. /**
  8592. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8593. * This is the base of the follow, arc rotate cameras and Free camera
  8594. * @see http://doc.babylonjs.com/features/cameras
  8595. * @param name Defines the name of the camera in the scene
  8596. * @param position Defines the start position of the camera in the scene
  8597. * @param scene Defines the scene the camera belongs to
  8598. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8599. */
  8600. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8601. /**
  8602. * Gets the position in front of the camera at a given distance.
  8603. * @param distance The distance from the camera we want the position to be
  8604. * @returns the position
  8605. */
  8606. getFrontPosition(distance: number): Vector3;
  8607. /** @hidden */
  8608. _getLockedTargetPosition(): Nullable<Vector3>;
  8609. private _storedPosition;
  8610. private _storedRotation;
  8611. private _storedRotationQuaternion;
  8612. /**
  8613. * Store current camera state of the camera (fov, position, rotation, etc..)
  8614. * @returns the camera
  8615. */
  8616. storeState(): Camera;
  8617. /**
  8618. * Restored camera state. You must call storeState() first
  8619. * @returns whether it was successful or not
  8620. * @hidden
  8621. */
  8622. _restoreStateValues(): boolean;
  8623. /** @hidden */
  8624. _initCache(): void;
  8625. /** @hidden */
  8626. _updateCache(ignoreParentClass?: boolean): void;
  8627. /** @hidden */
  8628. _isSynchronizedViewMatrix(): boolean;
  8629. /** @hidden */
  8630. _computeLocalCameraSpeed(): number;
  8631. /**
  8632. * Defines the target the camera should look at.
  8633. * This will automatically adapt alpha beta and radius to fit within the new target.
  8634. * @param target Defines the new target as a Vector or a mesh
  8635. */
  8636. setTarget(target: Vector3): void;
  8637. /**
  8638. * Return the current target position of the camera. This value is expressed in local space.
  8639. * @returns the target position
  8640. */
  8641. getTarget(): Vector3;
  8642. /** @hidden */
  8643. _decideIfNeedsToMove(): boolean;
  8644. /** @hidden */
  8645. _updatePosition(): void;
  8646. /** @hidden */
  8647. _checkInputs(): void;
  8648. protected _updateCameraRotationMatrix(): void;
  8649. /**
  8650. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8651. * @returns the current camera
  8652. */
  8653. private _rotateUpVectorWithCameraRotationMatrix;
  8654. private _cachedRotationZ;
  8655. private _cachedQuaternionRotationZ;
  8656. /** @hidden */
  8657. _getViewMatrix(): Matrix;
  8658. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8659. /**
  8660. * @hidden
  8661. */
  8662. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8663. /**
  8664. * @hidden
  8665. */
  8666. _updateRigCameras(): void;
  8667. private _getRigCamPositionAndTarget;
  8668. /**
  8669. * Gets the current object class name.
  8670. * @return the class name
  8671. */
  8672. getClassName(): string;
  8673. }
  8674. }
  8675. declare module "babylonjs/Cameras/cameraInputsManager" {
  8676. import { Nullable } from "babylonjs/types";
  8677. import { Camera } from "babylonjs/Cameras/camera";
  8678. /**
  8679. * @ignore
  8680. * This is a list of all the different input types that are available in the application.
  8681. * Fo instance: ArcRotateCameraGamepadInput...
  8682. */
  8683. export var CameraInputTypes: {};
  8684. /**
  8685. * This is the contract to implement in order to create a new input class.
  8686. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8687. */
  8688. export interface ICameraInput<TCamera extends Camera> {
  8689. /**
  8690. * Defines the camera the input is attached to.
  8691. */
  8692. camera: Nullable<TCamera>;
  8693. /**
  8694. * Gets the class name of the current intput.
  8695. * @returns the class name
  8696. */
  8697. getClassName(): string;
  8698. /**
  8699. * Get the friendly name associated with the input class.
  8700. * @returns the input friendly name
  8701. */
  8702. getSimpleName(): string;
  8703. /**
  8704. * Attach the input controls to a specific dom element to get the input from.
  8705. * @param element Defines the element the controls should be listened from
  8706. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8707. */
  8708. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8709. /**
  8710. * Detach the current controls from the specified dom element.
  8711. * @param element Defines the element to stop listening the inputs from
  8712. */
  8713. detachControl(element: Nullable<HTMLElement>): void;
  8714. /**
  8715. * Update the current camera state depending on the inputs that have been used this frame.
  8716. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8717. */
  8718. checkInputs?: () => void;
  8719. }
  8720. /**
  8721. * Represents a map of input types to input instance or input index to input instance.
  8722. */
  8723. export interface CameraInputsMap<TCamera extends Camera> {
  8724. /**
  8725. * Accessor to the input by input type.
  8726. */
  8727. [name: string]: ICameraInput<TCamera>;
  8728. /**
  8729. * Accessor to the input by input index.
  8730. */
  8731. [idx: number]: ICameraInput<TCamera>;
  8732. }
  8733. /**
  8734. * This represents the input manager used within a camera.
  8735. * It helps dealing with all the different kind of input attached to a camera.
  8736. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8737. */
  8738. export class CameraInputsManager<TCamera extends Camera> {
  8739. /**
  8740. * Defines the list of inputs attahed to the camera.
  8741. */
  8742. attached: CameraInputsMap<TCamera>;
  8743. /**
  8744. * Defines the dom element the camera is collecting inputs from.
  8745. * This is null if the controls have not been attached.
  8746. */
  8747. attachedElement: Nullable<HTMLElement>;
  8748. /**
  8749. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8750. */
  8751. noPreventDefault: boolean;
  8752. /**
  8753. * Defined the camera the input manager belongs to.
  8754. */
  8755. camera: TCamera;
  8756. /**
  8757. * Update the current camera state depending on the inputs that have been used this frame.
  8758. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8759. */
  8760. checkInputs: () => void;
  8761. /**
  8762. * Instantiate a new Camera Input Manager.
  8763. * @param camera Defines the camera the input manager blongs to
  8764. */
  8765. constructor(camera: TCamera);
  8766. /**
  8767. * Add an input method to a camera
  8768. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8769. * @param input camera input method
  8770. */
  8771. add(input: ICameraInput<TCamera>): void;
  8772. /**
  8773. * Remove a specific input method from a camera
  8774. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8775. * @param inputToRemove camera input method
  8776. */
  8777. remove(inputToRemove: ICameraInput<TCamera>): void;
  8778. /**
  8779. * Remove a specific input type from a camera
  8780. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8781. * @param inputType the type of the input to remove
  8782. */
  8783. removeByType(inputType: string): void;
  8784. private _addCheckInputs;
  8785. /**
  8786. * Attach the input controls to the currently attached dom element to listen the events from.
  8787. * @param input Defines the input to attach
  8788. */
  8789. attachInput(input: ICameraInput<TCamera>): void;
  8790. /**
  8791. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8792. * @param element Defines the dom element to collect the events from
  8793. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8794. */
  8795. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8796. /**
  8797. * Detach the current manager inputs controls from a specific dom element.
  8798. * @param element Defines the dom element to collect the events from
  8799. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8800. */
  8801. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8802. /**
  8803. * Rebuild the dynamic inputCheck function from the current list of
  8804. * defined inputs in the manager.
  8805. */
  8806. rebuildInputCheck(): void;
  8807. /**
  8808. * Remove all attached input methods from a camera
  8809. */
  8810. clear(): void;
  8811. /**
  8812. * Serialize the current input manager attached to a camera.
  8813. * This ensures than once parsed,
  8814. * the input associated to the camera will be identical to the current ones
  8815. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8816. */
  8817. serialize(serializedCamera: any): void;
  8818. /**
  8819. * Parses an input manager serialized JSON to restore the previous list of inputs
  8820. * and states associated to a camera.
  8821. * @param parsedCamera Defines the JSON to parse
  8822. */
  8823. parse(parsedCamera: any): void;
  8824. }
  8825. }
  8826. declare module "babylonjs/Events/keyboardEvents" {
  8827. /**
  8828. * Gather the list of keyboard event types as constants.
  8829. */
  8830. export class KeyboardEventTypes {
  8831. /**
  8832. * The keydown event is fired when a key becomes active (pressed).
  8833. */
  8834. static readonly KEYDOWN: number;
  8835. /**
  8836. * The keyup event is fired when a key has been released.
  8837. */
  8838. static readonly KEYUP: number;
  8839. }
  8840. /**
  8841. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8842. */
  8843. export class KeyboardInfo {
  8844. /**
  8845. * Defines the type of event (KeyboardEventTypes)
  8846. */
  8847. type: number;
  8848. /**
  8849. * Defines the related dom event
  8850. */
  8851. event: KeyboardEvent;
  8852. /**
  8853. * Instantiates a new keyboard info.
  8854. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8855. * @param type Defines the type of event (KeyboardEventTypes)
  8856. * @param event Defines the related dom event
  8857. */
  8858. constructor(
  8859. /**
  8860. * Defines the type of event (KeyboardEventTypes)
  8861. */
  8862. type: number,
  8863. /**
  8864. * Defines the related dom event
  8865. */
  8866. event: KeyboardEvent);
  8867. }
  8868. /**
  8869. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8870. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8871. */
  8872. export class KeyboardInfoPre extends KeyboardInfo {
  8873. /**
  8874. * Defines the type of event (KeyboardEventTypes)
  8875. */
  8876. type: number;
  8877. /**
  8878. * Defines the related dom event
  8879. */
  8880. event: KeyboardEvent;
  8881. /**
  8882. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8883. */
  8884. skipOnPointerObservable: boolean;
  8885. /**
  8886. * Instantiates a new keyboard pre info.
  8887. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8888. * @param type Defines the type of event (KeyboardEventTypes)
  8889. * @param event Defines the related dom event
  8890. */
  8891. constructor(
  8892. /**
  8893. * Defines the type of event (KeyboardEventTypes)
  8894. */
  8895. type: number,
  8896. /**
  8897. * Defines the related dom event
  8898. */
  8899. event: KeyboardEvent);
  8900. }
  8901. }
  8902. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8903. import { Nullable } from "babylonjs/types";
  8904. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8905. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8906. /**
  8907. * Manage the keyboard inputs to control the movement of a free camera.
  8908. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8909. */
  8910. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8911. /**
  8912. * Defines the camera the input is attached to.
  8913. */
  8914. camera: FreeCamera;
  8915. /**
  8916. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8917. */
  8918. keysUp: number[];
  8919. /**
  8920. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8921. */
  8922. keysDown: number[];
  8923. /**
  8924. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8925. */
  8926. keysLeft: number[];
  8927. /**
  8928. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8929. */
  8930. keysRight: number[];
  8931. private _keys;
  8932. private _onCanvasBlurObserver;
  8933. private _onKeyboardObserver;
  8934. private _engine;
  8935. private _scene;
  8936. /**
  8937. * Attach the input controls to a specific dom element to get the input from.
  8938. * @param element Defines the element the controls should be listened from
  8939. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8940. */
  8941. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8942. /**
  8943. * Detach the current controls from the specified dom element.
  8944. * @param element Defines the element to stop listening the inputs from
  8945. */
  8946. detachControl(element: Nullable<HTMLElement>): void;
  8947. /**
  8948. * Update the current camera state depending on the inputs that have been used this frame.
  8949. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8950. */
  8951. checkInputs(): void;
  8952. /**
  8953. * Gets the class name of the current intput.
  8954. * @returns the class name
  8955. */
  8956. getClassName(): string;
  8957. /** @hidden */
  8958. _onLostFocus(): void;
  8959. /**
  8960. * Get the friendly name associated with the input class.
  8961. * @returns the input friendly name
  8962. */
  8963. getSimpleName(): string;
  8964. }
  8965. }
  8966. declare module "babylonjs/Lights/shadowLight" {
  8967. import { Camera } from "babylonjs/Cameras/camera";
  8968. import { Scene } from "babylonjs/scene";
  8969. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8970. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8971. import { Light } from "babylonjs/Lights/light";
  8972. /**
  8973. * Interface describing all the common properties and methods a shadow light needs to implement.
  8974. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8975. * as well as binding the different shadow properties to the effects.
  8976. */
  8977. export interface IShadowLight extends Light {
  8978. /**
  8979. * The light id in the scene (used in scene.findLighById for instance)
  8980. */
  8981. id: string;
  8982. /**
  8983. * The position the shdow will be casted from.
  8984. */
  8985. position: Vector3;
  8986. /**
  8987. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8988. */
  8989. direction: Vector3;
  8990. /**
  8991. * The transformed position. Position of the light in world space taking parenting in account.
  8992. */
  8993. transformedPosition: Vector3;
  8994. /**
  8995. * The transformed direction. Direction of the light in world space taking parenting in account.
  8996. */
  8997. transformedDirection: Vector3;
  8998. /**
  8999. * The friendly name of the light in the scene.
  9000. */
  9001. name: string;
  9002. /**
  9003. * Defines the shadow projection clipping minimum z value.
  9004. */
  9005. shadowMinZ: number;
  9006. /**
  9007. * Defines the shadow projection clipping maximum z value.
  9008. */
  9009. shadowMaxZ: number;
  9010. /**
  9011. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9012. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9013. */
  9014. computeTransformedInformation(): boolean;
  9015. /**
  9016. * Gets the scene the light belongs to.
  9017. * @returns The scene
  9018. */
  9019. getScene(): Scene;
  9020. /**
  9021. * Callback defining a custom Projection Matrix Builder.
  9022. * This can be used to override the default projection matrix computation.
  9023. */
  9024. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9025. /**
  9026. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9027. * @param matrix The materix to updated with the projection information
  9028. * @param viewMatrix The transform matrix of the light
  9029. * @param renderList The list of mesh to render in the map
  9030. * @returns The current light
  9031. */
  9032. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9033. /**
  9034. * Gets the current depth scale used in ESM.
  9035. * @returns The scale
  9036. */
  9037. getDepthScale(): number;
  9038. /**
  9039. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9040. * @returns true if a cube texture needs to be use
  9041. */
  9042. needCube(): boolean;
  9043. /**
  9044. * Detects if the projection matrix requires to be recomputed this frame.
  9045. * @returns true if it requires to be recomputed otherwise, false.
  9046. */
  9047. needProjectionMatrixCompute(): boolean;
  9048. /**
  9049. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9050. */
  9051. forceProjectionMatrixCompute(): void;
  9052. /**
  9053. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9054. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9055. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9056. */
  9057. getShadowDirection(faceIndex?: number): Vector3;
  9058. /**
  9059. * Gets the minZ used for shadow according to both the scene and the light.
  9060. * @param activeCamera The camera we are returning the min for
  9061. * @returns the depth min z
  9062. */
  9063. getDepthMinZ(activeCamera: Camera): number;
  9064. /**
  9065. * Gets the maxZ used for shadow according to both the scene and the light.
  9066. * @param activeCamera The camera we are returning the max for
  9067. * @returns the depth max z
  9068. */
  9069. getDepthMaxZ(activeCamera: Camera): number;
  9070. }
  9071. /**
  9072. * Base implementation IShadowLight
  9073. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9074. */
  9075. export abstract class ShadowLight extends Light implements IShadowLight {
  9076. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9077. protected _position: Vector3;
  9078. protected _setPosition(value: Vector3): void;
  9079. /**
  9080. * Sets the position the shadow will be casted from. Also use as the light position for both
  9081. * point and spot lights.
  9082. */
  9083. /**
  9084. * Sets the position the shadow will be casted from. Also use as the light position for both
  9085. * point and spot lights.
  9086. */
  9087. position: Vector3;
  9088. protected _direction: Vector3;
  9089. protected _setDirection(value: Vector3): void;
  9090. /**
  9091. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9092. * Also use as the light direction on spot and directional lights.
  9093. */
  9094. /**
  9095. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9096. * Also use as the light direction on spot and directional lights.
  9097. */
  9098. direction: Vector3;
  9099. private _shadowMinZ;
  9100. /**
  9101. * Gets the shadow projection clipping minimum z value.
  9102. */
  9103. /**
  9104. * Sets the shadow projection clipping minimum z value.
  9105. */
  9106. shadowMinZ: number;
  9107. private _shadowMaxZ;
  9108. /**
  9109. * Sets the shadow projection clipping maximum z value.
  9110. */
  9111. /**
  9112. * Gets the shadow projection clipping maximum z value.
  9113. */
  9114. shadowMaxZ: number;
  9115. /**
  9116. * Callback defining a custom Projection Matrix Builder.
  9117. * This can be used to override the default projection matrix computation.
  9118. */
  9119. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9120. /**
  9121. * The transformed position. Position of the light in world space taking parenting in account.
  9122. */
  9123. transformedPosition: Vector3;
  9124. /**
  9125. * The transformed direction. Direction of the light in world space taking parenting in account.
  9126. */
  9127. transformedDirection: Vector3;
  9128. private _needProjectionMatrixCompute;
  9129. /**
  9130. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9131. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9132. */
  9133. computeTransformedInformation(): boolean;
  9134. /**
  9135. * Return the depth scale used for the shadow map.
  9136. * @returns the depth scale.
  9137. */
  9138. getDepthScale(): number;
  9139. /**
  9140. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9141. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9142. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9143. */
  9144. getShadowDirection(faceIndex?: number): Vector3;
  9145. /**
  9146. * Returns the ShadowLight absolute position in the World.
  9147. * @returns the position vector in world space
  9148. */
  9149. getAbsolutePosition(): Vector3;
  9150. /**
  9151. * Sets the ShadowLight direction toward the passed target.
  9152. * @param target The point to target in local space
  9153. * @returns the updated ShadowLight direction
  9154. */
  9155. setDirectionToTarget(target: Vector3): Vector3;
  9156. /**
  9157. * Returns the light rotation in euler definition.
  9158. * @returns the x y z rotation in local space.
  9159. */
  9160. getRotation(): Vector3;
  9161. /**
  9162. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9163. * @returns true if a cube texture needs to be use
  9164. */
  9165. needCube(): boolean;
  9166. /**
  9167. * Detects if the projection matrix requires to be recomputed this frame.
  9168. * @returns true if it requires to be recomputed otherwise, false.
  9169. */
  9170. needProjectionMatrixCompute(): boolean;
  9171. /**
  9172. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9173. */
  9174. forceProjectionMatrixCompute(): void;
  9175. /** @hidden */
  9176. _initCache(): void;
  9177. /** @hidden */
  9178. _isSynchronized(): boolean;
  9179. /**
  9180. * Computes the world matrix of the node
  9181. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9182. * @returns the world matrix
  9183. */
  9184. computeWorldMatrix(force?: boolean): Matrix;
  9185. /**
  9186. * Gets the minZ used for shadow according to both the scene and the light.
  9187. * @param activeCamera The camera we are returning the min for
  9188. * @returns the depth min z
  9189. */
  9190. getDepthMinZ(activeCamera: Camera): number;
  9191. /**
  9192. * Gets the maxZ used for shadow according to both the scene and the light.
  9193. * @param activeCamera The camera we are returning the max for
  9194. * @returns the depth max z
  9195. */
  9196. getDepthMaxZ(activeCamera: Camera): number;
  9197. /**
  9198. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9199. * @param matrix The materix to updated with the projection information
  9200. * @param viewMatrix The transform matrix of the light
  9201. * @param renderList The list of mesh to render in the map
  9202. * @returns The current light
  9203. */
  9204. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9205. }
  9206. }
  9207. declare module "babylonjs/Materials/materialHelper" {
  9208. import { Nullable } from "babylonjs/types";
  9209. import { Scene } from "babylonjs/scene";
  9210. import { Engine } from "babylonjs/Engines/engine";
  9211. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9212. import { Light } from "babylonjs/Lights/light";
  9213. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9214. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9215. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9216. /**
  9217. * "Static Class" containing the most commonly used helper while dealing with material for
  9218. * rendering purpose.
  9219. *
  9220. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9221. *
  9222. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9223. */
  9224. export class MaterialHelper {
  9225. /**
  9226. * Bind the current view position to an effect.
  9227. * @param effect The effect to be bound
  9228. * @param scene The scene the eyes position is used from
  9229. */
  9230. static BindEyePosition(effect: Effect, scene: Scene): void;
  9231. /**
  9232. * Helps preparing the defines values about the UVs in used in the effect.
  9233. * UVs are shared as much as we can accross channels in the shaders.
  9234. * @param texture The texture we are preparing the UVs for
  9235. * @param defines The defines to update
  9236. * @param key The channel key "diffuse", "specular"... used in the shader
  9237. */
  9238. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9239. /**
  9240. * Binds a texture matrix value to its corrsponding uniform
  9241. * @param texture The texture to bind the matrix for
  9242. * @param uniformBuffer The uniform buffer receivin the data
  9243. * @param key The channel key "diffuse", "specular"... used in the shader
  9244. */
  9245. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9246. /**
  9247. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9248. * @param mesh defines the current mesh
  9249. * @param scene defines the current scene
  9250. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9251. * @param pointsCloud defines if point cloud rendering has to be turned on
  9252. * @param fogEnabled defines if fog has to be turned on
  9253. * @param alphaTest defines if alpha testing has to be turned on
  9254. * @param defines defines the current list of defines
  9255. */
  9256. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9257. /**
  9258. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9259. * @param scene defines the current scene
  9260. * @param engine defines the current engine
  9261. * @param defines specifies the list of active defines
  9262. * @param useInstances defines if instances have to be turned on
  9263. * @param useClipPlane defines if clip plane have to be turned on
  9264. */
  9265. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9266. /**
  9267. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9268. * @param mesh The mesh containing the geometry data we will draw
  9269. * @param defines The defines to update
  9270. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9271. * @param useBones Precise whether bones should be used or not (override mesh info)
  9272. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9273. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9274. * @returns false if defines are considered not dirty and have not been checked
  9275. */
  9276. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9277. /**
  9278. * Prepares the defines related to the light information passed in parameter
  9279. * @param scene The scene we are intending to draw
  9280. * @param mesh The mesh the effect is compiling for
  9281. * @param defines The defines to update
  9282. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9283. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9284. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9285. * @returns true if normals will be required for the rest of the effect
  9286. */
  9287. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9288. /**
  9289. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9290. * that won t be acctive due to defines being turned off.
  9291. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9292. * @param samplersList The samplers list
  9293. * @param defines The defines helping in the list generation
  9294. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9295. */
  9296. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9297. /**
  9298. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9299. * @param defines The defines to update while falling back
  9300. * @param fallbacks The authorized effect fallbacks
  9301. * @param maxSimultaneousLights The maximum number of lights allowed
  9302. * @param rank the current rank of the Effect
  9303. * @returns The newly affected rank
  9304. */
  9305. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9306. /**
  9307. * Prepares the list of attributes required for morph targets according to the effect defines.
  9308. * @param attribs The current list of supported attribs
  9309. * @param mesh The mesh to prepare the morph targets attributes for
  9310. * @param defines The current Defines of the effect
  9311. */
  9312. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9313. /**
  9314. * Prepares the list of attributes required for bones according to the effect defines.
  9315. * @param attribs The current list of supported attribs
  9316. * @param mesh The mesh to prepare the bones attributes for
  9317. * @param defines The current Defines of the effect
  9318. * @param fallbacks The current efffect fallback strategy
  9319. */
  9320. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9321. /**
  9322. * Prepares the list of attributes required for instances according to the effect defines.
  9323. * @param attribs The current list of supported attribs
  9324. * @param defines The current Defines of the effect
  9325. */
  9326. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9327. /**
  9328. * Binds the light shadow information to the effect for the given mesh.
  9329. * @param light The light containing the generator
  9330. * @param scene The scene the lights belongs to
  9331. * @param mesh The mesh we are binding the information to render
  9332. * @param lightIndex The light index in the effect used to render the mesh
  9333. * @param effect The effect we are binding the data to
  9334. */
  9335. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9336. /**
  9337. * Binds the light information to the effect.
  9338. * @param light The light containing the generator
  9339. * @param effect The effect we are binding the data to
  9340. * @param lightIndex The light index in the effect used to render
  9341. */
  9342. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9343. /**
  9344. * Binds the lights information from the scene to the effect for the given mesh.
  9345. * @param scene The scene the lights belongs to
  9346. * @param mesh The mesh we are binding the information to render
  9347. * @param effect The effect we are binding the data to
  9348. * @param defines The generated defines for the effect
  9349. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9350. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9351. */
  9352. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9353. private static _tempFogColor;
  9354. /**
  9355. * Binds the fog information from the scene to the effect for the given mesh.
  9356. * @param scene The scene the lights belongs to
  9357. * @param mesh The mesh we are binding the information to render
  9358. * @param effect The effect we are binding the data to
  9359. * @param linearSpace Defines if the fog effect is applied in linear space
  9360. */
  9361. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9362. /**
  9363. * Binds the bones information from the mesh to the effect.
  9364. * @param mesh The mesh we are binding the information to render
  9365. * @param effect The effect we are binding the data to
  9366. */
  9367. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9368. /**
  9369. * Binds the morph targets information from the mesh to the effect.
  9370. * @param abstractMesh The mesh we are binding the information to render
  9371. * @param effect The effect we are binding the data to
  9372. */
  9373. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9374. /**
  9375. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9376. * @param defines The generated defines used in the effect
  9377. * @param effect The effect we are binding the data to
  9378. * @param scene The scene we are willing to render with logarithmic scale for
  9379. */
  9380. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9381. /**
  9382. * Binds the clip plane information from the scene to the effect.
  9383. * @param scene The scene the clip plane information are extracted from
  9384. * @param effect The effect we are binding the data to
  9385. */
  9386. static BindClipPlane(effect: Effect, scene: Scene): void;
  9387. }
  9388. }
  9389. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9390. /** @hidden */
  9391. export var kernelBlurVaryingDeclaration: {
  9392. name: string;
  9393. shader: string;
  9394. };
  9395. }
  9396. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9397. /** @hidden */
  9398. export var kernelBlurFragment: {
  9399. name: string;
  9400. shader: string;
  9401. };
  9402. }
  9403. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9404. /** @hidden */
  9405. export var kernelBlurFragment2: {
  9406. name: string;
  9407. shader: string;
  9408. };
  9409. }
  9410. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9411. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9412. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9413. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9414. /** @hidden */
  9415. export var kernelBlurPixelShader: {
  9416. name: string;
  9417. shader: string;
  9418. };
  9419. }
  9420. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9421. /** @hidden */
  9422. export var kernelBlurVertex: {
  9423. name: string;
  9424. shader: string;
  9425. };
  9426. }
  9427. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9428. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9429. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9430. /** @hidden */
  9431. export var kernelBlurVertexShader: {
  9432. name: string;
  9433. shader: string;
  9434. };
  9435. }
  9436. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9437. import { Vector2 } from "babylonjs/Maths/math";
  9438. import { Nullable } from "babylonjs/types";
  9439. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9440. import { Camera } from "babylonjs/Cameras/camera";
  9441. import { Effect } from "babylonjs/Materials/effect";
  9442. import { Engine } from "babylonjs/Engines/engine";
  9443. import "babylonjs/Shaders/kernelBlur.fragment";
  9444. import "babylonjs/Shaders/kernelBlur.vertex";
  9445. /**
  9446. * The Blur Post Process which blurs an image based on a kernel and direction.
  9447. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9448. */
  9449. export class BlurPostProcess extends PostProcess {
  9450. /** The direction in which to blur the image. */
  9451. direction: Vector2;
  9452. private blockCompilation;
  9453. protected _kernel: number;
  9454. protected _idealKernel: number;
  9455. protected _packedFloat: boolean;
  9456. private _staticDefines;
  9457. /**
  9458. * Sets the length in pixels of the blur sample region
  9459. */
  9460. /**
  9461. * Gets the length in pixels of the blur sample region
  9462. */
  9463. kernel: number;
  9464. /**
  9465. * Sets wether or not the blur needs to unpack/repack floats
  9466. */
  9467. /**
  9468. * Gets wether or not the blur is unpacking/repacking floats
  9469. */
  9470. packedFloat: boolean;
  9471. /**
  9472. * Creates a new instance BlurPostProcess
  9473. * @param name The name of the effect.
  9474. * @param direction The direction in which to blur the image.
  9475. * @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.
  9476. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9477. * @param camera The camera to apply the render pass to.
  9478. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9479. * @param engine The engine which the post process will be applied. (default: current engine)
  9480. * @param reusable If the post process can be reused on the same frame. (default: false)
  9481. * @param textureType Type of textures used when performing the post process. (default: 0)
  9482. * @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)
  9483. */
  9484. constructor(name: string,
  9485. /** The direction in which to blur the image. */
  9486. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9487. /**
  9488. * Updates the effect with the current post process compile time values and recompiles the shader.
  9489. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9490. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9491. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9492. * @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
  9493. * @param onCompiled Called when the shader has been compiled.
  9494. * @param onError Called if there is an error when compiling a shader.
  9495. */
  9496. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9497. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9498. /**
  9499. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9500. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9501. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9502. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9503. * The gaps between physical kernels are compensated for in the weighting of the samples
  9504. * @param idealKernel Ideal blur kernel.
  9505. * @return Nearest best kernel.
  9506. */
  9507. protected _nearestBestKernel(idealKernel: number): number;
  9508. /**
  9509. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9510. * @param x The point on the Gaussian distribution to sample.
  9511. * @return the value of the Gaussian function at x.
  9512. */
  9513. protected _gaussianWeight(x: number): number;
  9514. /**
  9515. * Generates a string that can be used as a floating point number in GLSL.
  9516. * @param x Value to print.
  9517. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9518. * @return GLSL float string.
  9519. */
  9520. protected _glslFloat(x: number, decimalFigures?: number): string;
  9521. }
  9522. }
  9523. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9524. /** @hidden */
  9525. export var shadowMapPixelShader: {
  9526. name: string;
  9527. shader: string;
  9528. };
  9529. }
  9530. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9531. /** @hidden */
  9532. export var bonesDeclaration: {
  9533. name: string;
  9534. shader: string;
  9535. };
  9536. }
  9537. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9538. /** @hidden */
  9539. export var morphTargetsVertexGlobalDeclaration: {
  9540. name: string;
  9541. shader: string;
  9542. };
  9543. }
  9544. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9545. /** @hidden */
  9546. export var morphTargetsVertexDeclaration: {
  9547. name: string;
  9548. shader: string;
  9549. };
  9550. }
  9551. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9552. /** @hidden */
  9553. export var instancesDeclaration: {
  9554. name: string;
  9555. shader: string;
  9556. };
  9557. }
  9558. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9559. /** @hidden */
  9560. export var helperFunctions: {
  9561. name: string;
  9562. shader: string;
  9563. };
  9564. }
  9565. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9566. /** @hidden */
  9567. export var morphTargetsVertex: {
  9568. name: string;
  9569. shader: string;
  9570. };
  9571. }
  9572. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9573. /** @hidden */
  9574. export var instancesVertex: {
  9575. name: string;
  9576. shader: string;
  9577. };
  9578. }
  9579. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9580. /** @hidden */
  9581. export var bonesVertex: {
  9582. name: string;
  9583. shader: string;
  9584. };
  9585. }
  9586. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9587. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9588. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9589. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9590. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9591. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9592. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9593. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9594. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9595. /** @hidden */
  9596. export var shadowMapVertexShader: {
  9597. name: string;
  9598. shader: string;
  9599. };
  9600. }
  9601. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9602. /** @hidden */
  9603. export var depthBoxBlurPixelShader: {
  9604. name: string;
  9605. shader: string;
  9606. };
  9607. }
  9608. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9609. import { Nullable } from "babylonjs/types";
  9610. import { Scene } from "babylonjs/scene";
  9611. import { Matrix } from "babylonjs/Maths/math";
  9612. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9613. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9614. import { Mesh } from "babylonjs/Meshes/mesh";
  9615. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9616. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9617. import { Effect } from "babylonjs/Materials/effect";
  9618. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9619. import "babylonjs/Shaders/shadowMap.fragment";
  9620. import "babylonjs/Shaders/shadowMap.vertex";
  9621. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9622. import { Observable } from "babylonjs/Misc/observable";
  9623. /**
  9624. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9625. */
  9626. export interface ICustomShaderOptions {
  9627. /**
  9628. * Gets or sets the custom shader name to use
  9629. */
  9630. shaderName: string;
  9631. /**
  9632. * The list of attribute names used in the shader
  9633. */
  9634. attributes?: string[];
  9635. /**
  9636. * The list of unifrom names used in the shader
  9637. */
  9638. uniforms?: string[];
  9639. /**
  9640. * The list of sampler names used in the shader
  9641. */
  9642. samplers?: string[];
  9643. /**
  9644. * The list of defines used in the shader
  9645. */
  9646. defines?: string[];
  9647. }
  9648. /**
  9649. * Interface to implement to create a shadow generator compatible with BJS.
  9650. */
  9651. export interface IShadowGenerator {
  9652. /**
  9653. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9654. * @returns The render target texture if present otherwise, null
  9655. */
  9656. getShadowMap(): Nullable<RenderTargetTexture>;
  9657. /**
  9658. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9659. * @returns The render target texture if the shadow map is present otherwise, null
  9660. */
  9661. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9662. /**
  9663. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9664. * @param subMesh The submesh we want to render in the shadow map
  9665. * @param useInstances Defines wether will draw in the map using instances
  9666. * @returns true if ready otherwise, false
  9667. */
  9668. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9669. /**
  9670. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9671. * @param defines Defines of the material we want to update
  9672. * @param lightIndex Index of the light in the enabled light list of the material
  9673. */
  9674. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9675. /**
  9676. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9677. * defined in the generator but impacting the effect).
  9678. * It implies the unifroms available on the materials are the standard BJS ones.
  9679. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9680. * @param effect The effect we are binfing the information for
  9681. */
  9682. bindShadowLight(lightIndex: string, effect: Effect): void;
  9683. /**
  9684. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9685. * (eq to shadow prjection matrix * light transform matrix)
  9686. * @returns The transform matrix used to create the shadow map
  9687. */
  9688. getTransformMatrix(): Matrix;
  9689. /**
  9690. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9691. * Cube and 2D textures for instance.
  9692. */
  9693. recreateShadowMap(): void;
  9694. /**
  9695. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9696. * @param onCompiled Callback triggered at the and of the effects compilation
  9697. * @param options Sets of optional options forcing the compilation with different modes
  9698. */
  9699. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9700. useInstances: boolean;
  9701. }>): void;
  9702. /**
  9703. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9704. * @param options Sets of optional options forcing the compilation with different modes
  9705. * @returns A promise that resolves when the compilation completes
  9706. */
  9707. forceCompilationAsync(options?: Partial<{
  9708. useInstances: boolean;
  9709. }>): Promise<void>;
  9710. /**
  9711. * Serializes the shadow generator setup to a json object.
  9712. * @returns The serialized JSON object
  9713. */
  9714. serialize(): any;
  9715. /**
  9716. * Disposes the Shadow map and related Textures and effects.
  9717. */
  9718. dispose(): void;
  9719. }
  9720. /**
  9721. * Default implementation IShadowGenerator.
  9722. * This is the main object responsible of generating shadows in the framework.
  9723. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9724. */
  9725. export class ShadowGenerator implements IShadowGenerator {
  9726. /**
  9727. * Shadow generator mode None: no filtering applied.
  9728. */
  9729. static readonly FILTER_NONE: number;
  9730. /**
  9731. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9732. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9733. */
  9734. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9735. /**
  9736. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9737. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9738. */
  9739. static readonly FILTER_POISSONSAMPLING: number;
  9740. /**
  9741. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9742. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9743. */
  9744. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9745. /**
  9746. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9747. * edge artifacts on steep falloff.
  9748. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9749. */
  9750. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9751. /**
  9752. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9753. * edge artifacts on steep falloff.
  9754. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9755. */
  9756. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9757. /**
  9758. * Shadow generator mode PCF: Percentage Closer Filtering
  9759. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9760. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9761. */
  9762. static readonly FILTER_PCF: number;
  9763. /**
  9764. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9765. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9766. * Contact Hardening
  9767. */
  9768. static readonly FILTER_PCSS: number;
  9769. /**
  9770. * Reserved for PCF and PCSS
  9771. * Highest Quality.
  9772. *
  9773. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9774. *
  9775. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9776. */
  9777. static readonly QUALITY_HIGH: number;
  9778. /**
  9779. * Reserved for PCF and PCSS
  9780. * Good tradeoff for quality/perf cross devices
  9781. *
  9782. * Execute PCF on a 3*3 kernel.
  9783. *
  9784. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9785. */
  9786. static readonly QUALITY_MEDIUM: number;
  9787. /**
  9788. * Reserved for PCF and PCSS
  9789. * The lowest quality but the fastest.
  9790. *
  9791. * Execute PCF on a 1*1 kernel.
  9792. *
  9793. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9794. */
  9795. static readonly QUALITY_LOW: number;
  9796. /** Gets or sets the custom shader name to use */
  9797. customShaderOptions: ICustomShaderOptions;
  9798. /**
  9799. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9800. */
  9801. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9802. /**
  9803. * Observable triggered before a mesh is rendered in the shadow map.
  9804. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9805. */
  9806. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9807. private _bias;
  9808. /**
  9809. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9810. */
  9811. /**
  9812. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9813. */
  9814. bias: number;
  9815. private _normalBias;
  9816. /**
  9817. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9818. */
  9819. /**
  9820. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9821. */
  9822. normalBias: number;
  9823. private _blurBoxOffset;
  9824. /**
  9825. * Gets the blur box offset: offset applied during the blur pass.
  9826. * Only useful if useKernelBlur = false
  9827. */
  9828. /**
  9829. * Sets the blur box offset: offset applied during the blur pass.
  9830. * Only useful if useKernelBlur = false
  9831. */
  9832. blurBoxOffset: number;
  9833. private _blurScale;
  9834. /**
  9835. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9836. * 2 means half of the size.
  9837. */
  9838. /**
  9839. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9840. * 2 means half of the size.
  9841. */
  9842. blurScale: number;
  9843. private _blurKernel;
  9844. /**
  9845. * Gets the blur kernel: kernel size of the blur pass.
  9846. * Only useful if useKernelBlur = true
  9847. */
  9848. /**
  9849. * Sets the blur kernel: kernel size of the blur pass.
  9850. * Only useful if useKernelBlur = true
  9851. */
  9852. blurKernel: number;
  9853. private _useKernelBlur;
  9854. /**
  9855. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9856. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9857. */
  9858. /**
  9859. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9860. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9861. */
  9862. useKernelBlur: boolean;
  9863. private _depthScale;
  9864. /**
  9865. * Gets the depth scale used in ESM mode.
  9866. */
  9867. /**
  9868. * Sets the depth scale used in ESM mode.
  9869. * This can override the scale stored on the light.
  9870. */
  9871. depthScale: number;
  9872. private _filter;
  9873. /**
  9874. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9875. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9876. */
  9877. /**
  9878. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9879. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9880. */
  9881. filter: number;
  9882. /**
  9883. * Gets if the current filter is set to Poisson Sampling.
  9884. */
  9885. /**
  9886. * Sets the current filter to Poisson Sampling.
  9887. */
  9888. usePoissonSampling: boolean;
  9889. /**
  9890. * Gets if the current filter is set to ESM.
  9891. */
  9892. /**
  9893. * Sets the current filter is to ESM.
  9894. */
  9895. useExponentialShadowMap: boolean;
  9896. /**
  9897. * Gets if the current filter is set to filtered ESM.
  9898. */
  9899. /**
  9900. * Gets if the current filter is set to filtered ESM.
  9901. */
  9902. useBlurExponentialShadowMap: boolean;
  9903. /**
  9904. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9905. * exponential to prevent steep falloff artifacts).
  9906. */
  9907. /**
  9908. * Sets the current filter to "close ESM" (using the inverse of the
  9909. * exponential to prevent steep falloff artifacts).
  9910. */
  9911. useCloseExponentialShadowMap: boolean;
  9912. /**
  9913. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9914. * exponential to prevent steep falloff artifacts).
  9915. */
  9916. /**
  9917. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9918. * exponential to prevent steep falloff artifacts).
  9919. */
  9920. useBlurCloseExponentialShadowMap: boolean;
  9921. /**
  9922. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9923. */
  9924. /**
  9925. * Sets the current filter to "PCF" (percentage closer filtering).
  9926. */
  9927. usePercentageCloserFiltering: boolean;
  9928. private _filteringQuality;
  9929. /**
  9930. * Gets the PCF or PCSS Quality.
  9931. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9932. */
  9933. /**
  9934. * Sets the PCF or PCSS Quality.
  9935. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9936. */
  9937. filteringQuality: number;
  9938. /**
  9939. * Gets if the current filter is set to "PCSS" (contact hardening).
  9940. */
  9941. /**
  9942. * Sets the current filter to "PCSS" (contact hardening).
  9943. */
  9944. useContactHardeningShadow: boolean;
  9945. private _contactHardeningLightSizeUVRatio;
  9946. /**
  9947. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9948. * Using a ratio helps keeping shape stability independently of the map size.
  9949. *
  9950. * It does not account for the light projection as it was having too much
  9951. * instability during the light setup or during light position changes.
  9952. *
  9953. * Only valid if useContactHardeningShadow is true.
  9954. */
  9955. /**
  9956. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9957. * Using a ratio helps keeping shape stability independently of the map size.
  9958. *
  9959. * It does not account for the light projection as it was having too much
  9960. * instability during the light setup or during light position changes.
  9961. *
  9962. * Only valid if useContactHardeningShadow is true.
  9963. */
  9964. contactHardeningLightSizeUVRatio: number;
  9965. private _darkness;
  9966. /**
  9967. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9968. * 0 means strongest and 1 would means no shadow.
  9969. * @returns the darkness.
  9970. */
  9971. getDarkness(): number;
  9972. /**
  9973. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9974. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9975. * @returns the shadow generator allowing fluent coding.
  9976. */
  9977. setDarkness(darkness: number): ShadowGenerator;
  9978. private _transparencyShadow;
  9979. /**
  9980. * Sets the ability to have transparent shadow (boolean).
  9981. * @param transparent True if transparent else False
  9982. * @returns the shadow generator allowing fluent coding
  9983. */
  9984. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9985. private _shadowMap;
  9986. private _shadowMap2;
  9987. /**
  9988. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9989. * @returns The render target texture if present otherwise, null
  9990. */
  9991. getShadowMap(): Nullable<RenderTargetTexture>;
  9992. /**
  9993. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9994. * @returns The render target texture if the shadow map is present otherwise, null
  9995. */
  9996. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9997. /**
  9998. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9999. * @param mesh Mesh to add
  10000. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10001. * @returns the Shadow Generator itself
  10002. */
  10003. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10004. /**
  10005. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10006. * @param mesh Mesh to remove
  10007. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10008. * @returns the Shadow Generator itself
  10009. */
  10010. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10011. /**
  10012. * Controls the extent to which the shadows fade out at the edge of the frustum
  10013. * Used only by directionals and spots
  10014. */
  10015. frustumEdgeFalloff: number;
  10016. private _light;
  10017. /**
  10018. * Returns the associated light object.
  10019. * @returns the light generating the shadow
  10020. */
  10021. getLight(): IShadowLight;
  10022. /**
  10023. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10024. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10025. * It might on the other hand introduce peter panning.
  10026. */
  10027. forceBackFacesOnly: boolean;
  10028. private _scene;
  10029. private _lightDirection;
  10030. private _effect;
  10031. private _viewMatrix;
  10032. private _projectionMatrix;
  10033. private _transformMatrix;
  10034. private _cachedPosition;
  10035. private _cachedDirection;
  10036. private _cachedDefines;
  10037. private _currentRenderID;
  10038. private _boxBlurPostprocess;
  10039. private _kernelBlurXPostprocess;
  10040. private _kernelBlurYPostprocess;
  10041. private _blurPostProcesses;
  10042. private _mapSize;
  10043. private _currentFaceIndex;
  10044. private _currentFaceIndexCache;
  10045. private _textureType;
  10046. private _defaultTextureMatrix;
  10047. /** @hidden */
  10048. static _SceneComponentInitialization: (scene: Scene) => void;
  10049. /**
  10050. * Creates a ShadowGenerator object.
  10051. * A ShadowGenerator is the required tool to use the shadows.
  10052. * Each light casting shadows needs to use its own ShadowGenerator.
  10053. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10054. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10055. * @param light The light object generating the shadows.
  10056. * @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.
  10057. */
  10058. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10059. private _initializeGenerator;
  10060. private _initializeShadowMap;
  10061. private _initializeBlurRTTAndPostProcesses;
  10062. private _renderForShadowMap;
  10063. private _renderSubMeshForShadowMap;
  10064. private _applyFilterValues;
  10065. /**
  10066. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10067. * @param onCompiled Callback triggered at the and of the effects compilation
  10068. * @param options Sets of optional options forcing the compilation with different modes
  10069. */
  10070. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10071. useInstances: boolean;
  10072. }>): void;
  10073. /**
  10074. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10075. * @param options Sets of optional options forcing the compilation with different modes
  10076. * @returns A promise that resolves when the compilation completes
  10077. */
  10078. forceCompilationAsync(options?: Partial<{
  10079. useInstances: boolean;
  10080. }>): Promise<void>;
  10081. /**
  10082. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10083. * @param subMesh The submesh we want to render in the shadow map
  10084. * @param useInstances Defines wether will draw in the map using instances
  10085. * @returns true if ready otherwise, false
  10086. */
  10087. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10088. /**
  10089. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10090. * @param defines Defines of the material we want to update
  10091. * @param lightIndex Index of the light in the enabled light list of the material
  10092. */
  10093. prepareDefines(defines: any, lightIndex: number): void;
  10094. /**
  10095. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10096. * defined in the generator but impacting the effect).
  10097. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10098. * @param effect The effect we are binfing the information for
  10099. */
  10100. bindShadowLight(lightIndex: string, effect: Effect): void;
  10101. /**
  10102. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10103. * (eq to shadow prjection matrix * light transform matrix)
  10104. * @returns The transform matrix used to create the shadow map
  10105. */
  10106. getTransformMatrix(): Matrix;
  10107. /**
  10108. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10109. * Cube and 2D textures for instance.
  10110. */
  10111. recreateShadowMap(): void;
  10112. private _disposeBlurPostProcesses;
  10113. private _disposeRTTandPostProcesses;
  10114. /**
  10115. * Disposes the ShadowGenerator.
  10116. * Returns nothing.
  10117. */
  10118. dispose(): void;
  10119. /**
  10120. * Serializes the shadow generator setup to a json object.
  10121. * @returns The serialized JSON object
  10122. */
  10123. serialize(): any;
  10124. /**
  10125. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10126. * @param parsedShadowGenerator The JSON object to parse
  10127. * @param scene The scene to create the shadow map for
  10128. * @returns The parsed shadow generator
  10129. */
  10130. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10131. }
  10132. }
  10133. declare module "babylonjs/Lights/light" {
  10134. import { Nullable } from "babylonjs/types";
  10135. import { Scene } from "babylonjs/scene";
  10136. import { Vector3, Color3 } from "babylonjs/Maths/math";
  10137. import { Node } from "babylonjs/node";
  10138. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10139. import { Effect } from "babylonjs/Materials/effect";
  10140. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10141. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10142. /**
  10143. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10144. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10145. * 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.
  10146. */
  10147. export abstract class Light extends Node {
  10148. /**
  10149. * Falloff Default: light is falling off following the material specification:
  10150. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10151. */
  10152. static readonly FALLOFF_DEFAULT: number;
  10153. /**
  10154. * Falloff Physical: light is falling off following the inverse squared distance law.
  10155. */
  10156. static readonly FALLOFF_PHYSICAL: number;
  10157. /**
  10158. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10159. * to enhance interoperability with other engines.
  10160. */
  10161. static readonly FALLOFF_GLTF: number;
  10162. /**
  10163. * Falloff Standard: light is falling off like in the standard material
  10164. * to enhance interoperability with other materials.
  10165. */
  10166. static readonly FALLOFF_STANDARD: number;
  10167. /**
  10168. * If every light affecting the material is in this lightmapMode,
  10169. * material.lightmapTexture adds or multiplies
  10170. * (depends on material.useLightmapAsShadowmap)
  10171. * after every other light calculations.
  10172. */
  10173. static readonly LIGHTMAP_DEFAULT: number;
  10174. /**
  10175. * material.lightmapTexture as only diffuse lighting from this light
  10176. * adds only specular lighting from this light
  10177. * adds dynamic shadows
  10178. */
  10179. static readonly LIGHTMAP_SPECULAR: number;
  10180. /**
  10181. * material.lightmapTexture as only lighting
  10182. * no light calculation from this light
  10183. * only adds dynamic shadows from this light
  10184. */
  10185. static readonly LIGHTMAP_SHADOWSONLY: number;
  10186. /**
  10187. * Each light type uses the default quantity according to its type:
  10188. * point/spot lights use luminous intensity
  10189. * directional lights use illuminance
  10190. */
  10191. static readonly INTENSITYMODE_AUTOMATIC: number;
  10192. /**
  10193. * lumen (lm)
  10194. */
  10195. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10196. /**
  10197. * candela (lm/sr)
  10198. */
  10199. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10200. /**
  10201. * lux (lm/m^2)
  10202. */
  10203. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10204. /**
  10205. * nit (cd/m^2)
  10206. */
  10207. static readonly INTENSITYMODE_LUMINANCE: number;
  10208. /**
  10209. * Light type const id of the point light.
  10210. */
  10211. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10212. /**
  10213. * Light type const id of the directional light.
  10214. */
  10215. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10216. /**
  10217. * Light type const id of the spot light.
  10218. */
  10219. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10220. /**
  10221. * Light type const id of the hemispheric light.
  10222. */
  10223. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10224. /**
  10225. * Diffuse gives the basic color to an object.
  10226. */
  10227. diffuse: Color3;
  10228. /**
  10229. * Specular produces a highlight color on an object.
  10230. * Note: This is note affecting PBR materials.
  10231. */
  10232. specular: Color3;
  10233. /**
  10234. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10235. * falling off base on range or angle.
  10236. * This can be set to any values in Light.FALLOFF_x.
  10237. *
  10238. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10239. * other types of materials.
  10240. */
  10241. falloffType: number;
  10242. /**
  10243. * Strength of the light.
  10244. * Note: By default it is define in the framework own unit.
  10245. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10246. */
  10247. intensity: number;
  10248. private _range;
  10249. protected _inverseSquaredRange: number;
  10250. /**
  10251. * Defines how far from the source the light is impacting in scene units.
  10252. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10253. */
  10254. /**
  10255. * Defines how far from the source the light is impacting in scene units.
  10256. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10257. */
  10258. range: number;
  10259. /**
  10260. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10261. * of light.
  10262. */
  10263. private _photometricScale;
  10264. private _intensityMode;
  10265. /**
  10266. * Gets the photometric scale used to interpret the intensity.
  10267. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10268. */
  10269. /**
  10270. * Sets the photometric scale used to interpret the intensity.
  10271. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10272. */
  10273. intensityMode: number;
  10274. private _radius;
  10275. /**
  10276. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10277. */
  10278. /**
  10279. * sets the light radius used by PBR Materials to simulate soft area lights.
  10280. */
  10281. radius: number;
  10282. private _renderPriority;
  10283. /**
  10284. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10285. * exceeding the number allowed of the materials.
  10286. */
  10287. renderPriority: number;
  10288. private _shadowEnabled;
  10289. /**
  10290. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10291. * the current shadow generator.
  10292. */
  10293. /**
  10294. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10295. * the current shadow generator.
  10296. */
  10297. shadowEnabled: boolean;
  10298. private _includedOnlyMeshes;
  10299. /**
  10300. * Gets the only meshes impacted by this light.
  10301. */
  10302. /**
  10303. * Sets the only meshes impacted by this light.
  10304. */
  10305. includedOnlyMeshes: AbstractMesh[];
  10306. private _excludedMeshes;
  10307. /**
  10308. * Gets the meshes not impacted by this light.
  10309. */
  10310. /**
  10311. * Sets the meshes not impacted by this light.
  10312. */
  10313. excludedMeshes: AbstractMesh[];
  10314. private _excludeWithLayerMask;
  10315. /**
  10316. * Gets the layer id use to find what meshes are not impacted by the light.
  10317. * Inactive if 0
  10318. */
  10319. /**
  10320. * Sets the layer id use to find what meshes are not impacted by the light.
  10321. * Inactive if 0
  10322. */
  10323. excludeWithLayerMask: number;
  10324. private _includeOnlyWithLayerMask;
  10325. /**
  10326. * Gets the layer id use to find what meshes are impacted by the light.
  10327. * Inactive if 0
  10328. */
  10329. /**
  10330. * Sets the layer id use to find what meshes are impacted by the light.
  10331. * Inactive if 0
  10332. */
  10333. includeOnlyWithLayerMask: number;
  10334. private _lightmapMode;
  10335. /**
  10336. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10337. */
  10338. /**
  10339. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10340. */
  10341. lightmapMode: number;
  10342. /**
  10343. * Shadow generator associted to the light.
  10344. * @hidden Internal use only.
  10345. */
  10346. _shadowGenerator: Nullable<IShadowGenerator>;
  10347. /**
  10348. * @hidden Internal use only.
  10349. */
  10350. _excludedMeshesIds: string[];
  10351. /**
  10352. * @hidden Internal use only.
  10353. */
  10354. _includedOnlyMeshesIds: string[];
  10355. /**
  10356. * The current light unifom buffer.
  10357. * @hidden Internal use only.
  10358. */
  10359. _uniformBuffer: UniformBuffer;
  10360. /**
  10361. * Creates a Light object in the scene.
  10362. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10363. * @param name The firendly name of the light
  10364. * @param scene The scene the light belongs too
  10365. */
  10366. constructor(name: string, scene: Scene);
  10367. protected abstract _buildUniformLayout(): void;
  10368. /**
  10369. * Sets the passed Effect "effect" with the Light information.
  10370. * @param effect The effect to update
  10371. * @param lightIndex The index of the light in the effect to update
  10372. * @returns The light
  10373. */
  10374. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10375. /**
  10376. * Returns the string "Light".
  10377. * @returns the class name
  10378. */
  10379. getClassName(): string;
  10380. /** @hidden */
  10381. readonly _isLight: boolean;
  10382. /**
  10383. * Converts the light information to a readable string for debug purpose.
  10384. * @param fullDetails Supports for multiple levels of logging within scene loading
  10385. * @returns the human readable light info
  10386. */
  10387. toString(fullDetails?: boolean): string;
  10388. /** @hidden */
  10389. protected _syncParentEnabledState(): void;
  10390. /**
  10391. * Set the enabled state of this node.
  10392. * @param value - the new enabled state
  10393. */
  10394. setEnabled(value: boolean): void;
  10395. /**
  10396. * Returns the Light associated shadow generator if any.
  10397. * @return the associated shadow generator.
  10398. */
  10399. getShadowGenerator(): Nullable<IShadowGenerator>;
  10400. /**
  10401. * Returns a Vector3, the absolute light position in the World.
  10402. * @returns the world space position of the light
  10403. */
  10404. getAbsolutePosition(): Vector3;
  10405. /**
  10406. * Specifies if the light will affect the passed mesh.
  10407. * @param mesh The mesh to test against the light
  10408. * @return true the mesh is affected otherwise, false.
  10409. */
  10410. canAffectMesh(mesh: AbstractMesh): boolean;
  10411. /**
  10412. * Sort function to order lights for rendering.
  10413. * @param a First Light object to compare to second.
  10414. * @param b Second Light object to compare first.
  10415. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10416. */
  10417. static CompareLightsPriority(a: Light, b: Light): number;
  10418. /**
  10419. * Releases resources associated with this node.
  10420. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10421. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10422. */
  10423. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10424. /**
  10425. * Returns the light type ID (integer).
  10426. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10427. */
  10428. getTypeID(): number;
  10429. /**
  10430. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10431. * @returns the scaled intensity in intensity mode unit
  10432. */
  10433. getScaledIntensity(): number;
  10434. /**
  10435. * Returns a new Light object, named "name", from the current one.
  10436. * @param name The name of the cloned light
  10437. * @returns the new created light
  10438. */
  10439. clone(name: string): Nullable<Light>;
  10440. /**
  10441. * Serializes the current light into a Serialization object.
  10442. * @returns the serialized object.
  10443. */
  10444. serialize(): any;
  10445. /**
  10446. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10447. * This new light is named "name" and added to the passed scene.
  10448. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10449. * @param name The friendly name of the light
  10450. * @param scene The scene the new light will belong to
  10451. * @returns the constructor function
  10452. */
  10453. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10454. /**
  10455. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10456. * @param parsedLight The JSON representation of the light
  10457. * @param scene The scene to create the parsed light in
  10458. * @returns the created light after parsing
  10459. */
  10460. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10461. private _hookArrayForExcluded;
  10462. private _hookArrayForIncludedOnly;
  10463. private _resyncMeshes;
  10464. /**
  10465. * Forces the meshes to update their light related information in their rendering used effects
  10466. * @hidden Internal Use Only
  10467. */
  10468. _markMeshesAsLightDirty(): void;
  10469. /**
  10470. * Recomputes the cached photometric scale if needed.
  10471. */
  10472. private _computePhotometricScale;
  10473. /**
  10474. * Returns the Photometric Scale according to the light type and intensity mode.
  10475. */
  10476. private _getPhotometricScale;
  10477. /**
  10478. * Reorder the light in the scene according to their defined priority.
  10479. * @hidden Internal Use Only
  10480. */
  10481. _reorderLightsInScene(): void;
  10482. /**
  10483. * Prepares the list of defines specific to the light type.
  10484. * @param defines the list of defines
  10485. * @param lightIndex defines the index of the light for the effect
  10486. */
  10487. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10488. }
  10489. }
  10490. declare module "babylonjs/Actions/action" {
  10491. import { Observable } from "babylonjs/Misc/observable";
  10492. import { Condition } from "babylonjs/Actions/condition";
  10493. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10494. import { ActionManager } from "babylonjs/Actions/actionManager";
  10495. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10496. /**
  10497. * Interface used to define Action
  10498. */
  10499. export interface IAction {
  10500. /**
  10501. * Trigger for the action
  10502. */
  10503. trigger: number;
  10504. /** Options of the trigger */
  10505. triggerOptions: any;
  10506. /**
  10507. * Gets the trigger parameters
  10508. * @returns the trigger parameters
  10509. */
  10510. getTriggerParameter(): any;
  10511. /**
  10512. * Internal only - executes current action event
  10513. * @hidden
  10514. */
  10515. _executeCurrent(evt?: ActionEvent): void;
  10516. /**
  10517. * Serialize placeholder for child classes
  10518. * @param parent of child
  10519. * @returns the serialized object
  10520. */
  10521. serialize(parent: any): any;
  10522. /**
  10523. * Internal only
  10524. * @hidden
  10525. */
  10526. _prepare(): void;
  10527. /**
  10528. * Internal only - manager for action
  10529. * @hidden
  10530. */
  10531. _actionManager: AbstractActionManager;
  10532. }
  10533. /**
  10534. * The action to be carried out following a trigger
  10535. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10536. */
  10537. export class Action implements IAction {
  10538. /** the trigger, with or without parameters, for the action */
  10539. triggerOptions: any;
  10540. /**
  10541. * Trigger for the action
  10542. */
  10543. trigger: number;
  10544. /**
  10545. * Internal only - manager for action
  10546. * @hidden
  10547. */
  10548. _actionManager: ActionManager;
  10549. private _nextActiveAction;
  10550. private _child;
  10551. private _condition?;
  10552. private _triggerParameter;
  10553. /**
  10554. * An event triggered prior to action being executed.
  10555. */
  10556. onBeforeExecuteObservable: Observable<Action>;
  10557. /**
  10558. * Creates a new Action
  10559. * @param triggerOptions the trigger, with or without parameters, for the action
  10560. * @param condition an optional determinant of action
  10561. */
  10562. constructor(
  10563. /** the trigger, with or without parameters, for the action */
  10564. triggerOptions: any, condition?: Condition);
  10565. /**
  10566. * Internal only
  10567. * @hidden
  10568. */
  10569. _prepare(): void;
  10570. /**
  10571. * Gets the trigger parameters
  10572. * @returns the trigger parameters
  10573. */
  10574. getTriggerParameter(): any;
  10575. /**
  10576. * Internal only - executes current action event
  10577. * @hidden
  10578. */
  10579. _executeCurrent(evt?: ActionEvent): void;
  10580. /**
  10581. * Execute placeholder for child classes
  10582. * @param evt optional action event
  10583. */
  10584. execute(evt?: ActionEvent): void;
  10585. /**
  10586. * Skips to next active action
  10587. */
  10588. skipToNextActiveAction(): void;
  10589. /**
  10590. * Adds action to chain of actions, may be a DoNothingAction
  10591. * @param action defines the next action to execute
  10592. * @returns The action passed in
  10593. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10594. */
  10595. then(action: Action): Action;
  10596. /**
  10597. * Internal only
  10598. * @hidden
  10599. */
  10600. _getProperty(propertyPath: string): string;
  10601. /**
  10602. * Internal only
  10603. * @hidden
  10604. */
  10605. _getEffectiveTarget(target: any, propertyPath: string): any;
  10606. /**
  10607. * Serialize placeholder for child classes
  10608. * @param parent of child
  10609. * @returns the serialized object
  10610. */
  10611. serialize(parent: any): any;
  10612. /**
  10613. * Internal only called by serialize
  10614. * @hidden
  10615. */
  10616. protected _serialize(serializedAction: any, parent?: any): any;
  10617. /**
  10618. * Internal only
  10619. * @hidden
  10620. */
  10621. static _SerializeValueAsString: (value: any) => string;
  10622. /**
  10623. * Internal only
  10624. * @hidden
  10625. */
  10626. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10627. name: string;
  10628. targetType: string;
  10629. value: string;
  10630. };
  10631. }
  10632. }
  10633. declare module "babylonjs/Actions/condition" {
  10634. import { ActionManager } from "babylonjs/Actions/actionManager";
  10635. /**
  10636. * A Condition applied to an Action
  10637. */
  10638. export class Condition {
  10639. /**
  10640. * Internal only - manager for action
  10641. * @hidden
  10642. */
  10643. _actionManager: ActionManager;
  10644. /**
  10645. * Internal only
  10646. * @hidden
  10647. */
  10648. _evaluationId: number;
  10649. /**
  10650. * Internal only
  10651. * @hidden
  10652. */
  10653. _currentResult: boolean;
  10654. /**
  10655. * Creates a new Condition
  10656. * @param actionManager the manager of the action the condition is applied to
  10657. */
  10658. constructor(actionManager: ActionManager);
  10659. /**
  10660. * Check if the current condition is valid
  10661. * @returns a boolean
  10662. */
  10663. isValid(): boolean;
  10664. /**
  10665. * Internal only
  10666. * @hidden
  10667. */
  10668. _getProperty(propertyPath: string): string;
  10669. /**
  10670. * Internal only
  10671. * @hidden
  10672. */
  10673. _getEffectiveTarget(target: any, propertyPath: string): any;
  10674. /**
  10675. * Serialize placeholder for child classes
  10676. * @returns the serialized object
  10677. */
  10678. serialize(): any;
  10679. /**
  10680. * Internal only
  10681. * @hidden
  10682. */
  10683. protected _serialize(serializedCondition: any): any;
  10684. }
  10685. /**
  10686. * Defines specific conditional operators as extensions of Condition
  10687. */
  10688. export class ValueCondition extends Condition {
  10689. /** path to specify the property of the target the conditional operator uses */
  10690. propertyPath: string;
  10691. /** the value compared by the conditional operator against the current value of the property */
  10692. value: any;
  10693. /** the conditional operator, default ValueCondition.IsEqual */
  10694. operator: number;
  10695. /**
  10696. * Internal only
  10697. * @hidden
  10698. */
  10699. private static _IsEqual;
  10700. /**
  10701. * Internal only
  10702. * @hidden
  10703. */
  10704. private static _IsDifferent;
  10705. /**
  10706. * Internal only
  10707. * @hidden
  10708. */
  10709. private static _IsGreater;
  10710. /**
  10711. * Internal only
  10712. * @hidden
  10713. */
  10714. private static _IsLesser;
  10715. /**
  10716. * returns the number for IsEqual
  10717. */
  10718. static readonly IsEqual: number;
  10719. /**
  10720. * Returns the number for IsDifferent
  10721. */
  10722. static readonly IsDifferent: number;
  10723. /**
  10724. * Returns the number for IsGreater
  10725. */
  10726. static readonly IsGreater: number;
  10727. /**
  10728. * Returns the number for IsLesser
  10729. */
  10730. static readonly IsLesser: number;
  10731. /**
  10732. * Internal only The action manager for the condition
  10733. * @hidden
  10734. */
  10735. _actionManager: ActionManager;
  10736. /**
  10737. * Internal only
  10738. * @hidden
  10739. */
  10740. private _target;
  10741. /**
  10742. * Internal only
  10743. * @hidden
  10744. */
  10745. private _effectiveTarget;
  10746. /**
  10747. * Internal only
  10748. * @hidden
  10749. */
  10750. private _property;
  10751. /**
  10752. * Creates a new ValueCondition
  10753. * @param actionManager manager for the action the condition applies to
  10754. * @param target for the action
  10755. * @param propertyPath path to specify the property of the target the conditional operator uses
  10756. * @param value the value compared by the conditional operator against the current value of the property
  10757. * @param operator the conditional operator, default ValueCondition.IsEqual
  10758. */
  10759. constructor(actionManager: ActionManager, target: any,
  10760. /** path to specify the property of the target the conditional operator uses */
  10761. propertyPath: string,
  10762. /** the value compared by the conditional operator against the current value of the property */
  10763. value: any,
  10764. /** the conditional operator, default ValueCondition.IsEqual */
  10765. operator?: number);
  10766. /**
  10767. * Compares the given value with the property value for the specified conditional operator
  10768. * @returns the result of the comparison
  10769. */
  10770. isValid(): boolean;
  10771. /**
  10772. * Serialize the ValueCondition into a JSON compatible object
  10773. * @returns serialization object
  10774. */
  10775. serialize(): any;
  10776. /**
  10777. * Gets the name of the conditional operator for the ValueCondition
  10778. * @param operator the conditional operator
  10779. * @returns the name
  10780. */
  10781. static GetOperatorName(operator: number): string;
  10782. }
  10783. /**
  10784. * Defines a predicate condition as an extension of Condition
  10785. */
  10786. export class PredicateCondition extends Condition {
  10787. /** defines the predicate function used to validate the condition */
  10788. predicate: () => boolean;
  10789. /**
  10790. * Internal only - manager for action
  10791. * @hidden
  10792. */
  10793. _actionManager: ActionManager;
  10794. /**
  10795. * Creates a new PredicateCondition
  10796. * @param actionManager manager for the action the condition applies to
  10797. * @param predicate defines the predicate function used to validate the condition
  10798. */
  10799. constructor(actionManager: ActionManager,
  10800. /** defines the predicate function used to validate the condition */
  10801. predicate: () => boolean);
  10802. /**
  10803. * @returns the validity of the predicate condition
  10804. */
  10805. isValid(): boolean;
  10806. }
  10807. /**
  10808. * Defines a state condition as an extension of Condition
  10809. */
  10810. export class StateCondition extends Condition {
  10811. /** Value to compare with target state */
  10812. value: string;
  10813. /**
  10814. * Internal only - manager for action
  10815. * @hidden
  10816. */
  10817. _actionManager: ActionManager;
  10818. /**
  10819. * Internal only
  10820. * @hidden
  10821. */
  10822. private _target;
  10823. /**
  10824. * Creates a new StateCondition
  10825. * @param actionManager manager for the action the condition applies to
  10826. * @param target of the condition
  10827. * @param value to compare with target state
  10828. */
  10829. constructor(actionManager: ActionManager, target: any,
  10830. /** Value to compare with target state */
  10831. value: string);
  10832. /**
  10833. * Gets a boolean indicating if the current condition is met
  10834. * @returns the validity of the state
  10835. */
  10836. isValid(): boolean;
  10837. /**
  10838. * Serialize the StateCondition into a JSON compatible object
  10839. * @returns serialization object
  10840. */
  10841. serialize(): any;
  10842. }
  10843. }
  10844. declare module "babylonjs/Actions/directActions" {
  10845. import { Action } from "babylonjs/Actions/action";
  10846. import { Condition } from "babylonjs/Actions/condition";
  10847. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10848. /**
  10849. * This defines an action responsible to toggle a boolean once triggered.
  10850. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10851. */
  10852. export class SwitchBooleanAction extends Action {
  10853. /**
  10854. * The path to the boolean property in the target object
  10855. */
  10856. propertyPath: string;
  10857. private _target;
  10858. private _effectiveTarget;
  10859. private _property;
  10860. /**
  10861. * Instantiate the action
  10862. * @param triggerOptions defines the trigger options
  10863. * @param target defines the object containing the boolean
  10864. * @param propertyPath defines the path to the boolean property in the target object
  10865. * @param condition defines the trigger related conditions
  10866. */
  10867. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10868. /** @hidden */
  10869. _prepare(): void;
  10870. /**
  10871. * Execute the action toggle the boolean value.
  10872. */
  10873. execute(): void;
  10874. /**
  10875. * Serializes the actions and its related information.
  10876. * @param parent defines the object to serialize in
  10877. * @returns the serialized object
  10878. */
  10879. serialize(parent: any): any;
  10880. }
  10881. /**
  10882. * This defines an action responsible to set a the state field of the target
  10883. * to a desired value once triggered.
  10884. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10885. */
  10886. export class SetStateAction extends Action {
  10887. /**
  10888. * The value to store in the state field.
  10889. */
  10890. value: string;
  10891. private _target;
  10892. /**
  10893. * Instantiate the action
  10894. * @param triggerOptions defines the trigger options
  10895. * @param target defines the object containing the state property
  10896. * @param value defines the value to store in the state field
  10897. * @param condition defines the trigger related conditions
  10898. */
  10899. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10900. /**
  10901. * Execute the action and store the value on the target state property.
  10902. */
  10903. execute(): void;
  10904. /**
  10905. * Serializes the actions and its related information.
  10906. * @param parent defines the object to serialize in
  10907. * @returns the serialized object
  10908. */
  10909. serialize(parent: any): any;
  10910. }
  10911. /**
  10912. * This defines an action responsible to set a property of the target
  10913. * to a desired value once triggered.
  10914. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10915. */
  10916. export class SetValueAction extends Action {
  10917. /**
  10918. * The path of the property to set in the target.
  10919. */
  10920. propertyPath: string;
  10921. /**
  10922. * The value to set in the property
  10923. */
  10924. value: any;
  10925. private _target;
  10926. private _effectiveTarget;
  10927. private _property;
  10928. /**
  10929. * Instantiate the action
  10930. * @param triggerOptions defines the trigger options
  10931. * @param target defines the object containing the property
  10932. * @param propertyPath defines the path of the property to set in the target
  10933. * @param value defines the value to set in the property
  10934. * @param condition defines the trigger related conditions
  10935. */
  10936. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10937. /** @hidden */
  10938. _prepare(): void;
  10939. /**
  10940. * Execute the action and set the targetted property to the desired value.
  10941. */
  10942. execute(): void;
  10943. /**
  10944. * Serializes the actions and its related information.
  10945. * @param parent defines the object to serialize in
  10946. * @returns the serialized object
  10947. */
  10948. serialize(parent: any): any;
  10949. }
  10950. /**
  10951. * This defines an action responsible to increment the target value
  10952. * to a desired value once triggered.
  10953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10954. */
  10955. export class IncrementValueAction extends Action {
  10956. /**
  10957. * The path of the property to increment in the target.
  10958. */
  10959. propertyPath: string;
  10960. /**
  10961. * The value we should increment the property by.
  10962. */
  10963. value: any;
  10964. private _target;
  10965. private _effectiveTarget;
  10966. private _property;
  10967. /**
  10968. * Instantiate the action
  10969. * @param triggerOptions defines the trigger options
  10970. * @param target defines the object containing the property
  10971. * @param propertyPath defines the path of the property to increment in the target
  10972. * @param value defines the value value we should increment the property by
  10973. * @param condition defines the trigger related conditions
  10974. */
  10975. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10976. /** @hidden */
  10977. _prepare(): void;
  10978. /**
  10979. * Execute the action and increment the target of the value amount.
  10980. */
  10981. execute(): void;
  10982. /**
  10983. * Serializes the actions and its related information.
  10984. * @param parent defines the object to serialize in
  10985. * @returns the serialized object
  10986. */
  10987. serialize(parent: any): any;
  10988. }
  10989. /**
  10990. * This defines an action responsible to start an animation once triggered.
  10991. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10992. */
  10993. export class PlayAnimationAction extends Action {
  10994. /**
  10995. * Where the animation should start (animation frame)
  10996. */
  10997. from: number;
  10998. /**
  10999. * Where the animation should stop (animation frame)
  11000. */
  11001. to: number;
  11002. /**
  11003. * Define if the animation should loop or stop after the first play.
  11004. */
  11005. loop?: boolean;
  11006. private _target;
  11007. /**
  11008. * Instantiate the action
  11009. * @param triggerOptions defines the trigger options
  11010. * @param target defines the target animation or animation name
  11011. * @param from defines from where the animation should start (animation frame)
  11012. * @param end defines where the animation should stop (animation frame)
  11013. * @param loop defines if the animation should loop or stop after the first play
  11014. * @param condition defines the trigger related conditions
  11015. */
  11016. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11017. /** @hidden */
  11018. _prepare(): void;
  11019. /**
  11020. * Execute the action and play the animation.
  11021. */
  11022. execute(): void;
  11023. /**
  11024. * Serializes the actions and its related information.
  11025. * @param parent defines the object to serialize in
  11026. * @returns the serialized object
  11027. */
  11028. serialize(parent: any): any;
  11029. }
  11030. /**
  11031. * This defines an action responsible to stop an animation once triggered.
  11032. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11033. */
  11034. export class StopAnimationAction extends Action {
  11035. private _target;
  11036. /**
  11037. * Instantiate the action
  11038. * @param triggerOptions defines the trigger options
  11039. * @param target defines the target animation or animation name
  11040. * @param condition defines the trigger related conditions
  11041. */
  11042. constructor(triggerOptions: any, target: any, condition?: Condition);
  11043. /** @hidden */
  11044. _prepare(): void;
  11045. /**
  11046. * Execute the action and stop the animation.
  11047. */
  11048. execute(): void;
  11049. /**
  11050. * Serializes the actions and its related information.
  11051. * @param parent defines the object to serialize in
  11052. * @returns the serialized object
  11053. */
  11054. serialize(parent: any): any;
  11055. }
  11056. /**
  11057. * This defines an action responsible that does nothing once triggered.
  11058. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11059. */
  11060. export class DoNothingAction extends Action {
  11061. /**
  11062. * Instantiate the action
  11063. * @param triggerOptions defines the trigger options
  11064. * @param condition defines the trigger related conditions
  11065. */
  11066. constructor(triggerOptions?: any, condition?: Condition);
  11067. /**
  11068. * Execute the action and do nothing.
  11069. */
  11070. execute(): void;
  11071. /**
  11072. * Serializes the actions and its related information.
  11073. * @param parent defines the object to serialize in
  11074. * @returns the serialized object
  11075. */
  11076. serialize(parent: any): any;
  11077. }
  11078. /**
  11079. * This defines an action responsible to trigger several actions once triggered.
  11080. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11081. */
  11082. export class CombineAction extends Action {
  11083. /**
  11084. * The list of aggregated animations to run.
  11085. */
  11086. children: Action[];
  11087. /**
  11088. * Instantiate the action
  11089. * @param triggerOptions defines the trigger options
  11090. * @param children defines the list of aggregated animations to run
  11091. * @param condition defines the trigger related conditions
  11092. */
  11093. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11094. /** @hidden */
  11095. _prepare(): void;
  11096. /**
  11097. * Execute the action and executes all the aggregated actions.
  11098. */
  11099. execute(evt: ActionEvent): void;
  11100. /**
  11101. * Serializes the actions and its related information.
  11102. * @param parent defines the object to serialize in
  11103. * @returns the serialized object
  11104. */
  11105. serialize(parent: any): any;
  11106. }
  11107. /**
  11108. * This defines an action responsible to run code (external event) once triggered.
  11109. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11110. */
  11111. export class ExecuteCodeAction extends Action {
  11112. /**
  11113. * The callback function to run.
  11114. */
  11115. func: (evt: ActionEvent) => void;
  11116. /**
  11117. * Instantiate the action
  11118. * @param triggerOptions defines the trigger options
  11119. * @param func defines the callback function to run
  11120. * @param condition defines the trigger related conditions
  11121. */
  11122. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11123. /**
  11124. * Execute the action and run the attached code.
  11125. */
  11126. execute(evt: ActionEvent): void;
  11127. }
  11128. /**
  11129. * This defines an action responsible to set the parent property of the target once triggered.
  11130. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11131. */
  11132. export class SetParentAction extends Action {
  11133. private _parent;
  11134. private _target;
  11135. /**
  11136. * Instantiate the action
  11137. * @param triggerOptions defines the trigger options
  11138. * @param target defines the target containing the parent property
  11139. * @param parent defines from where the animation should start (animation frame)
  11140. * @param condition defines the trigger related conditions
  11141. */
  11142. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11143. /** @hidden */
  11144. _prepare(): void;
  11145. /**
  11146. * Execute the action and set the parent property.
  11147. */
  11148. execute(): void;
  11149. /**
  11150. * Serializes the actions and its related information.
  11151. * @param parent defines the object to serialize in
  11152. * @returns the serialized object
  11153. */
  11154. serialize(parent: any): any;
  11155. }
  11156. }
  11157. declare module "babylonjs/Actions/actionManager" {
  11158. import { Nullable } from "babylonjs/types";
  11159. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11160. import { Scene } from "babylonjs/scene";
  11161. import { IAction } from "babylonjs/Actions/action";
  11162. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11163. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11164. /**
  11165. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11166. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11167. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11168. */
  11169. export class ActionManager extends AbstractActionManager {
  11170. /**
  11171. * Nothing
  11172. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11173. */
  11174. static readonly NothingTrigger: number;
  11175. /**
  11176. * On pick
  11177. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11178. */
  11179. static readonly OnPickTrigger: number;
  11180. /**
  11181. * On left pick
  11182. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11183. */
  11184. static readonly OnLeftPickTrigger: number;
  11185. /**
  11186. * On right pick
  11187. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11188. */
  11189. static readonly OnRightPickTrigger: number;
  11190. /**
  11191. * On center pick
  11192. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11193. */
  11194. static readonly OnCenterPickTrigger: number;
  11195. /**
  11196. * On pick down
  11197. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11198. */
  11199. static readonly OnPickDownTrigger: number;
  11200. /**
  11201. * On double pick
  11202. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11203. */
  11204. static readonly OnDoublePickTrigger: number;
  11205. /**
  11206. * On pick up
  11207. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11208. */
  11209. static readonly OnPickUpTrigger: number;
  11210. /**
  11211. * On pick out.
  11212. * This trigger will only be raised if you also declared a OnPickDown
  11213. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11214. */
  11215. static readonly OnPickOutTrigger: number;
  11216. /**
  11217. * On long press
  11218. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11219. */
  11220. static readonly OnLongPressTrigger: number;
  11221. /**
  11222. * On pointer over
  11223. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11224. */
  11225. static readonly OnPointerOverTrigger: number;
  11226. /**
  11227. * On pointer out
  11228. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11229. */
  11230. static readonly OnPointerOutTrigger: number;
  11231. /**
  11232. * On every frame
  11233. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11234. */
  11235. static readonly OnEveryFrameTrigger: number;
  11236. /**
  11237. * On intersection enter
  11238. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11239. */
  11240. static readonly OnIntersectionEnterTrigger: number;
  11241. /**
  11242. * On intersection exit
  11243. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11244. */
  11245. static readonly OnIntersectionExitTrigger: number;
  11246. /**
  11247. * On key down
  11248. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11249. */
  11250. static readonly OnKeyDownTrigger: number;
  11251. /**
  11252. * On key up
  11253. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11254. */
  11255. static readonly OnKeyUpTrigger: number;
  11256. private _scene;
  11257. /**
  11258. * Creates a new action manager
  11259. * @param scene defines the hosting scene
  11260. */
  11261. constructor(scene: Scene);
  11262. /**
  11263. * Releases all associated resources
  11264. */
  11265. dispose(): void;
  11266. /**
  11267. * Gets hosting scene
  11268. * @returns the hosting scene
  11269. */
  11270. getScene(): Scene;
  11271. /**
  11272. * Does this action manager handles actions of any of the given triggers
  11273. * @param triggers defines the triggers to be tested
  11274. * @return a boolean indicating whether one (or more) of the triggers is handled
  11275. */
  11276. hasSpecificTriggers(triggers: number[]): boolean;
  11277. /**
  11278. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11279. * speed.
  11280. * @param triggerA defines the trigger to be tested
  11281. * @param triggerB defines the trigger to be tested
  11282. * @return a boolean indicating whether one (or more) of the triggers is handled
  11283. */
  11284. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11285. /**
  11286. * Does this action manager handles actions of a given trigger
  11287. * @param trigger defines the trigger to be tested
  11288. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11289. * @return whether the trigger is handled
  11290. */
  11291. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11292. /**
  11293. * Does this action manager has pointer triggers
  11294. */
  11295. readonly hasPointerTriggers: boolean;
  11296. /**
  11297. * Does this action manager has pick triggers
  11298. */
  11299. readonly hasPickTriggers: boolean;
  11300. /**
  11301. * Registers an action to this action manager
  11302. * @param action defines the action to be registered
  11303. * @return the action amended (prepared) after registration
  11304. */
  11305. registerAction(action: IAction): Nullable<IAction>;
  11306. /**
  11307. * Unregisters an action to this action manager
  11308. * @param action defines the action to be unregistered
  11309. * @return a boolean indicating whether the action has been unregistered
  11310. */
  11311. unregisterAction(action: IAction): Boolean;
  11312. /**
  11313. * Process a specific trigger
  11314. * @param trigger defines the trigger to process
  11315. * @param evt defines the event details to be processed
  11316. */
  11317. processTrigger(trigger: number, evt?: IActionEvent): void;
  11318. /** @hidden */
  11319. _getEffectiveTarget(target: any, propertyPath: string): any;
  11320. /** @hidden */
  11321. _getProperty(propertyPath: string): string;
  11322. /**
  11323. * Serialize this manager to a JSON object
  11324. * @param name defines the property name to store this manager
  11325. * @returns a JSON representation of this manager
  11326. */
  11327. serialize(name: string): any;
  11328. /**
  11329. * Creates a new ActionManager from a JSON data
  11330. * @param parsedActions defines the JSON data to read from
  11331. * @param object defines the hosting mesh
  11332. * @param scene defines the hosting scene
  11333. */
  11334. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11335. /**
  11336. * Get a trigger name by index
  11337. * @param trigger defines the trigger index
  11338. * @returns a trigger name
  11339. */
  11340. static GetTriggerName(trigger: number): string;
  11341. }
  11342. }
  11343. declare module "babylonjs/Culling/ray" {
  11344. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11345. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11346. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11347. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11348. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11349. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11350. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11351. /**
  11352. * Class representing a ray with position and direction
  11353. */
  11354. export class Ray {
  11355. /** origin point */
  11356. origin: Vector3;
  11357. /** direction */
  11358. direction: Vector3;
  11359. /** length of the ray */
  11360. length: number;
  11361. private static readonly TmpVector3;
  11362. private _tmpRay;
  11363. /**
  11364. * Creates a new ray
  11365. * @param origin origin point
  11366. * @param direction direction
  11367. * @param length length of the ray
  11368. */
  11369. constructor(
  11370. /** origin point */
  11371. origin: Vector3,
  11372. /** direction */
  11373. direction: Vector3,
  11374. /** length of the ray */
  11375. length?: number);
  11376. /**
  11377. * Checks if the ray intersects a box
  11378. * @param minimum bound of the box
  11379. * @param maximum bound of the box
  11380. * @param intersectionTreshold extra extend to be added to the box in all direction
  11381. * @returns if the box was hit
  11382. */
  11383. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11384. /**
  11385. * Checks if the ray intersects a box
  11386. * @param box the bounding box to check
  11387. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11388. * @returns if the box was hit
  11389. */
  11390. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11391. /**
  11392. * If the ray hits a sphere
  11393. * @param sphere the bounding sphere to check
  11394. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11395. * @returns true if it hits the sphere
  11396. */
  11397. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11398. /**
  11399. * If the ray hits a triange
  11400. * @param vertex0 triangle vertex
  11401. * @param vertex1 triangle vertex
  11402. * @param vertex2 triangle vertex
  11403. * @returns intersection information if hit
  11404. */
  11405. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11406. /**
  11407. * Checks if ray intersects a plane
  11408. * @param plane the plane to check
  11409. * @returns the distance away it was hit
  11410. */
  11411. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11412. /**
  11413. * Checks if ray intersects a mesh
  11414. * @param mesh the mesh to check
  11415. * @param fastCheck if only the bounding box should checked
  11416. * @returns picking info of the intersecton
  11417. */
  11418. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11419. /**
  11420. * Checks if ray intersects a mesh
  11421. * @param meshes the meshes to check
  11422. * @param fastCheck if only the bounding box should checked
  11423. * @param results array to store result in
  11424. * @returns Array of picking infos
  11425. */
  11426. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11427. private _comparePickingInfo;
  11428. private static smallnum;
  11429. private static rayl;
  11430. /**
  11431. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11432. * @param sega the first point of the segment to test the intersection against
  11433. * @param segb the second point of the segment to test the intersection against
  11434. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11435. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11436. */
  11437. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11438. /**
  11439. * Update the ray from viewport position
  11440. * @param x position
  11441. * @param y y position
  11442. * @param viewportWidth viewport width
  11443. * @param viewportHeight viewport height
  11444. * @param world world matrix
  11445. * @param view view matrix
  11446. * @param projection projection matrix
  11447. * @returns this ray updated
  11448. */
  11449. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11450. /**
  11451. * Creates a ray with origin and direction of 0,0,0
  11452. * @returns the new ray
  11453. */
  11454. static Zero(): Ray;
  11455. /**
  11456. * Creates a new ray from screen space and viewport
  11457. * @param x position
  11458. * @param y y position
  11459. * @param viewportWidth viewport width
  11460. * @param viewportHeight viewport height
  11461. * @param world world matrix
  11462. * @param view view matrix
  11463. * @param projection projection matrix
  11464. * @returns new ray
  11465. */
  11466. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11467. /**
  11468. * 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
  11469. * transformed to the given world matrix.
  11470. * @param origin The origin point
  11471. * @param end The end point
  11472. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11473. * @returns the new ray
  11474. */
  11475. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11476. /**
  11477. * Transforms a ray by a matrix
  11478. * @param ray ray to transform
  11479. * @param matrix matrix to apply
  11480. * @returns the resulting new ray
  11481. */
  11482. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11483. /**
  11484. * Transforms a ray by a matrix
  11485. * @param ray ray to transform
  11486. * @param matrix matrix to apply
  11487. * @param result ray to store result in
  11488. */
  11489. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11490. /**
  11491. * Unproject a ray from screen space to object space
  11492. * @param sourceX defines the screen space x coordinate to use
  11493. * @param sourceY defines the screen space y coordinate to use
  11494. * @param viewportWidth defines the current width of the viewport
  11495. * @param viewportHeight defines the current height of the viewport
  11496. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11497. * @param view defines the view matrix to use
  11498. * @param projection defines the projection matrix to use
  11499. */
  11500. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11501. }
  11502. /**
  11503. * Type used to define predicate used to select faces when a mesh intersection is detected
  11504. */
  11505. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11506. module "babylonjs/scene" {
  11507. interface Scene {
  11508. /** @hidden */
  11509. _tempPickingRay: Nullable<Ray>;
  11510. /** @hidden */
  11511. _cachedRayForTransform: Ray;
  11512. /** @hidden */
  11513. _pickWithRayInverseMatrix: Matrix;
  11514. /** @hidden */
  11515. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11516. /** @hidden */
  11517. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11518. }
  11519. }
  11520. }
  11521. declare module "babylonjs/sceneComponent" {
  11522. import { Scene } from "babylonjs/scene";
  11523. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11524. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11525. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11526. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11527. import { Nullable } from "babylonjs/types";
  11528. import { Camera } from "babylonjs/Cameras/camera";
  11529. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11530. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11531. import { AbstractScene } from "babylonjs/abstractScene";
  11532. /**
  11533. * Groups all the scene component constants in one place to ease maintenance.
  11534. * @hidden
  11535. */
  11536. export class SceneComponentConstants {
  11537. static readonly NAME_EFFECTLAYER: string;
  11538. static readonly NAME_LAYER: string;
  11539. static readonly NAME_LENSFLARESYSTEM: string;
  11540. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11541. static readonly NAME_PARTICLESYSTEM: string;
  11542. static readonly NAME_GAMEPAD: string;
  11543. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11544. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11545. static readonly NAME_DEPTHRENDERER: string;
  11546. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11547. static readonly NAME_SPRITE: string;
  11548. static readonly NAME_OUTLINERENDERER: string;
  11549. static readonly NAME_PROCEDURALTEXTURE: string;
  11550. static readonly NAME_SHADOWGENERATOR: string;
  11551. static readonly NAME_OCTREE: string;
  11552. static readonly NAME_PHYSICSENGINE: string;
  11553. static readonly NAME_AUDIO: string;
  11554. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11555. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11556. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11557. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11558. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11559. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11560. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11561. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11562. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11563. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11564. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11565. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11566. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11567. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11568. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11569. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11570. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11571. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11572. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11573. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11574. static readonly STEP_AFTERRENDER_AUDIO: number;
  11575. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11576. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11577. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11578. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11579. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11580. static readonly STEP_POINTERMOVE_SPRITE: number;
  11581. static readonly STEP_POINTERDOWN_SPRITE: number;
  11582. static readonly STEP_POINTERUP_SPRITE: number;
  11583. }
  11584. /**
  11585. * This represents a scene component.
  11586. *
  11587. * This is used to decouple the dependency the scene is having on the different workloads like
  11588. * layers, post processes...
  11589. */
  11590. export interface ISceneComponent {
  11591. /**
  11592. * The name of the component. Each component must have a unique name.
  11593. */
  11594. name: string;
  11595. /**
  11596. * The scene the component belongs to.
  11597. */
  11598. scene: Scene;
  11599. /**
  11600. * Register the component to one instance of a scene.
  11601. */
  11602. register(): void;
  11603. /**
  11604. * Rebuilds the elements related to this component in case of
  11605. * context lost for instance.
  11606. */
  11607. rebuild(): void;
  11608. /**
  11609. * Disposes the component and the associated ressources.
  11610. */
  11611. dispose(): void;
  11612. }
  11613. /**
  11614. * This represents a SERIALIZABLE scene component.
  11615. *
  11616. * This extends Scene Component to add Serialization methods on top.
  11617. */
  11618. export interface ISceneSerializableComponent extends ISceneComponent {
  11619. /**
  11620. * Adds all the element from the container to the scene
  11621. * @param container the container holding the elements
  11622. */
  11623. addFromContainer(container: AbstractScene): void;
  11624. /**
  11625. * Removes all the elements in the container from the scene
  11626. * @param container contains the elements to remove
  11627. */
  11628. removeFromContainer(container: AbstractScene): void;
  11629. /**
  11630. * Serializes the component data to the specified json object
  11631. * @param serializationObject The object to serialize to
  11632. */
  11633. serialize(serializationObject: any): void;
  11634. }
  11635. /**
  11636. * Strong typing of a Mesh related stage step action
  11637. */
  11638. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11639. /**
  11640. * Strong typing of a Evaluate Sub Mesh related stage step action
  11641. */
  11642. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11643. /**
  11644. * Strong typing of a Active Mesh related stage step action
  11645. */
  11646. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11647. /**
  11648. * Strong typing of a Camera related stage step action
  11649. */
  11650. export type CameraStageAction = (camera: Camera) => void;
  11651. /**
  11652. * Strong typing of a Render Target related stage step action
  11653. */
  11654. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11655. /**
  11656. * Strong typing of a RenderingGroup related stage step action
  11657. */
  11658. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11659. /**
  11660. * Strong typing of a Mesh Render related stage step action
  11661. */
  11662. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11663. /**
  11664. * Strong typing of a simple stage step action
  11665. */
  11666. export type SimpleStageAction = () => void;
  11667. /**
  11668. * Strong typing of a render target action.
  11669. */
  11670. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11671. /**
  11672. * Strong typing of a pointer move action.
  11673. */
  11674. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11675. /**
  11676. * Strong typing of a pointer up/down action.
  11677. */
  11678. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11679. /**
  11680. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11681. * @hidden
  11682. */
  11683. export class Stage<T extends Function> extends Array<{
  11684. index: number;
  11685. component: ISceneComponent;
  11686. action: T;
  11687. }> {
  11688. /**
  11689. * Hide ctor from the rest of the world.
  11690. * @param items The items to add.
  11691. */
  11692. private constructor();
  11693. /**
  11694. * Creates a new Stage.
  11695. * @returns A new instance of a Stage
  11696. */
  11697. static Create<T extends Function>(): Stage<T>;
  11698. /**
  11699. * Registers a step in an ordered way in the targeted stage.
  11700. * @param index Defines the position to register the step in
  11701. * @param component Defines the component attached to the step
  11702. * @param action Defines the action to launch during the step
  11703. */
  11704. registerStep(index: number, component: ISceneComponent, action: T): void;
  11705. /**
  11706. * Clears all the steps from the stage.
  11707. */
  11708. clear(): void;
  11709. }
  11710. }
  11711. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11712. import { Nullable } from "babylonjs/types";
  11713. import { Observable } from "babylonjs/Misc/observable";
  11714. import { Scene } from "babylonjs/scene";
  11715. import { Sprite } from "babylonjs/Sprites/sprite";
  11716. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11717. import { Ray } from "babylonjs/Culling/ray";
  11718. import { Camera } from "babylonjs/Cameras/camera";
  11719. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11720. import { ISceneComponent } from "babylonjs/sceneComponent";
  11721. module "babylonjs/scene" {
  11722. interface Scene {
  11723. /** @hidden */
  11724. _pointerOverSprite: Nullable<Sprite>;
  11725. /** @hidden */
  11726. _pickedDownSprite: Nullable<Sprite>;
  11727. /** @hidden */
  11728. _tempSpritePickingRay: Nullable<Ray>;
  11729. /**
  11730. * All of the sprite managers added to this scene
  11731. * @see http://doc.babylonjs.com/babylon101/sprites
  11732. */
  11733. spriteManagers: Array<ISpriteManager>;
  11734. /**
  11735. * An event triggered when sprites rendering is about to start
  11736. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11737. */
  11738. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11739. /**
  11740. * An event triggered when sprites rendering is done
  11741. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11742. */
  11743. onAfterSpritesRenderingObservable: Observable<Scene>;
  11744. /** @hidden */
  11745. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11746. /** Launch a ray to try to pick a sprite in the scene
  11747. * @param x position on screen
  11748. * @param y position on screen
  11749. * @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
  11750. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11751. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11752. * @returns a PickingInfo
  11753. */
  11754. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11755. /** Use the given ray to pick a sprite in the scene
  11756. * @param ray The ray (in world space) to use to pick meshes
  11757. * @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
  11758. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11759. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11760. * @returns a PickingInfo
  11761. */
  11762. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11763. /**
  11764. * Force the sprite under the pointer
  11765. * @param sprite defines the sprite to use
  11766. */
  11767. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11768. /**
  11769. * Gets the sprite under the pointer
  11770. * @returns a Sprite or null if no sprite is under the pointer
  11771. */
  11772. getPointerOverSprite(): Nullable<Sprite>;
  11773. }
  11774. }
  11775. /**
  11776. * Defines the sprite scene component responsible to manage sprites
  11777. * in a given scene.
  11778. */
  11779. export class SpriteSceneComponent implements ISceneComponent {
  11780. /**
  11781. * The component name helpfull to identify the component in the list of scene components.
  11782. */
  11783. readonly name: string;
  11784. /**
  11785. * The scene the component belongs to.
  11786. */
  11787. scene: Scene;
  11788. /** @hidden */
  11789. private _spritePredicate;
  11790. /**
  11791. * Creates a new instance of the component for the given scene
  11792. * @param scene Defines the scene to register the component in
  11793. */
  11794. constructor(scene: Scene);
  11795. /**
  11796. * Registers the component in a given scene
  11797. */
  11798. register(): void;
  11799. /**
  11800. * Rebuilds the elements related to this component in case of
  11801. * context lost for instance.
  11802. */
  11803. rebuild(): void;
  11804. /**
  11805. * Disposes the component and the associated ressources.
  11806. */
  11807. dispose(): void;
  11808. private _pickSpriteButKeepRay;
  11809. private _pointerMove;
  11810. private _pointerDown;
  11811. private _pointerUp;
  11812. }
  11813. }
  11814. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11815. /** @hidden */
  11816. export var fogFragmentDeclaration: {
  11817. name: string;
  11818. shader: string;
  11819. };
  11820. }
  11821. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11822. /** @hidden */
  11823. export var fogFragment: {
  11824. name: string;
  11825. shader: string;
  11826. };
  11827. }
  11828. declare module "babylonjs/Shaders/sprites.fragment" {
  11829. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11830. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11831. /** @hidden */
  11832. export var spritesPixelShader: {
  11833. name: string;
  11834. shader: string;
  11835. };
  11836. }
  11837. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11838. /** @hidden */
  11839. export var fogVertexDeclaration: {
  11840. name: string;
  11841. shader: string;
  11842. };
  11843. }
  11844. declare module "babylonjs/Shaders/sprites.vertex" {
  11845. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11846. /** @hidden */
  11847. export var spritesVertexShader: {
  11848. name: string;
  11849. shader: string;
  11850. };
  11851. }
  11852. declare module "babylonjs/Sprites/spriteManager" {
  11853. import { IDisposable, Scene } from "babylonjs/scene";
  11854. import { Nullable } from "babylonjs/types";
  11855. import { Observable } from "babylonjs/Misc/observable";
  11856. import { Sprite } from "babylonjs/Sprites/sprite";
  11857. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11858. import { Camera } from "babylonjs/Cameras/camera";
  11859. import { Texture } from "babylonjs/Materials/Textures/texture";
  11860. import "babylonjs/Shaders/sprites.fragment";
  11861. import "babylonjs/Shaders/sprites.vertex";
  11862. import { Ray } from "babylonjs/Culling/ray";
  11863. /**
  11864. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11865. */
  11866. export interface ISpriteManager extends IDisposable {
  11867. /**
  11868. * Restricts the camera to viewing objects with the same layerMask.
  11869. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11870. */
  11871. layerMask: number;
  11872. /**
  11873. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11874. */
  11875. isPickable: boolean;
  11876. /**
  11877. * Specifies the rendering group id for this mesh (0 by default)
  11878. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11879. */
  11880. renderingGroupId: number;
  11881. /**
  11882. * Defines the list of sprites managed by the manager.
  11883. */
  11884. sprites: Array<Sprite>;
  11885. /**
  11886. * Tests the intersection of a sprite with a specific ray.
  11887. * @param ray The ray we are sending to test the collision
  11888. * @param camera The camera space we are sending rays in
  11889. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11890. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11891. * @returns picking info or null.
  11892. */
  11893. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11894. /**
  11895. * Renders the list of sprites on screen.
  11896. */
  11897. render(): void;
  11898. }
  11899. /**
  11900. * Class used to manage multiple sprites on the same spritesheet
  11901. * @see http://doc.babylonjs.com/babylon101/sprites
  11902. */
  11903. export class SpriteManager implements ISpriteManager {
  11904. /** defines the manager's name */
  11905. name: string;
  11906. /** Gets the list of sprites */
  11907. sprites: Sprite[];
  11908. /** Gets or sets the rendering group id (0 by default) */
  11909. renderingGroupId: number;
  11910. /** Gets or sets camera layer mask */
  11911. layerMask: number;
  11912. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11913. fogEnabled: boolean;
  11914. /** Gets or sets a boolean indicating if the sprites are pickable */
  11915. isPickable: boolean;
  11916. /** Defines the default width of a cell in the spritesheet */
  11917. cellWidth: number;
  11918. /** Defines the default height of a cell in the spritesheet */
  11919. cellHeight: number;
  11920. /**
  11921. * An event triggered when the manager is disposed.
  11922. */
  11923. onDisposeObservable: Observable<SpriteManager>;
  11924. private _onDisposeObserver;
  11925. /**
  11926. * Callback called when the manager is disposed
  11927. */
  11928. onDispose: () => void;
  11929. private _capacity;
  11930. private _spriteTexture;
  11931. private _epsilon;
  11932. private _scene;
  11933. private _vertexData;
  11934. private _buffer;
  11935. private _vertexBuffers;
  11936. private _indexBuffer;
  11937. private _effectBase;
  11938. private _effectFog;
  11939. /**
  11940. * Gets or sets the spritesheet texture
  11941. */
  11942. texture: Texture;
  11943. /**
  11944. * Creates a new sprite manager
  11945. * @param name defines the manager's name
  11946. * @param imgUrl defines the sprite sheet url
  11947. * @param capacity defines the maximum allowed number of sprites
  11948. * @param cellSize defines the size of a sprite cell
  11949. * @param scene defines the hosting scene
  11950. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11951. * @param samplingMode defines the smapling mode to use with spritesheet
  11952. */
  11953. constructor(
  11954. /** defines the manager's name */
  11955. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11956. private _appendSpriteVertex;
  11957. /**
  11958. * Intersects the sprites with a ray
  11959. * @param ray defines the ray to intersect with
  11960. * @param camera defines the current active camera
  11961. * @param predicate defines a predicate used to select candidate sprites
  11962. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11963. * @returns null if no hit or a PickingInfo
  11964. */
  11965. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11966. /**
  11967. * Render all child sprites
  11968. */
  11969. render(): void;
  11970. /**
  11971. * Release associated resources
  11972. */
  11973. dispose(): void;
  11974. }
  11975. }
  11976. declare module "babylonjs/Sprites/sprite" {
  11977. import { Vector3, Color4 } from "babylonjs/Maths/math";
  11978. import { Nullable } from "babylonjs/types";
  11979. import { ActionManager } from "babylonjs/Actions/actionManager";
  11980. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11981. /**
  11982. * Class used to represent a sprite
  11983. * @see http://doc.babylonjs.com/babylon101/sprites
  11984. */
  11985. export class Sprite {
  11986. /** defines the name */
  11987. name: string;
  11988. /** Gets or sets the current world position */
  11989. position: Vector3;
  11990. /** Gets or sets the main color */
  11991. color: Color4;
  11992. /** Gets or sets the width */
  11993. width: number;
  11994. /** Gets or sets the height */
  11995. height: number;
  11996. /** Gets or sets rotation angle */
  11997. angle: number;
  11998. /** Gets or sets the cell index in the sprite sheet */
  11999. cellIndex: number;
  12000. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12001. invertU: number;
  12002. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12003. invertV: number;
  12004. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12005. disposeWhenFinishedAnimating: boolean;
  12006. /** Gets the list of attached animations */
  12007. animations: Animation[];
  12008. /** Gets or sets a boolean indicating if the sprite can be picked */
  12009. isPickable: boolean;
  12010. /**
  12011. * Gets or sets the associated action manager
  12012. */
  12013. actionManager: Nullable<ActionManager>;
  12014. private _animationStarted;
  12015. private _loopAnimation;
  12016. private _fromIndex;
  12017. private _toIndex;
  12018. private _delay;
  12019. private _direction;
  12020. private _manager;
  12021. private _time;
  12022. private _onAnimationEnd;
  12023. /**
  12024. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12025. */
  12026. isVisible: boolean;
  12027. /**
  12028. * Gets or sets the sprite size
  12029. */
  12030. size: number;
  12031. /**
  12032. * Creates a new Sprite
  12033. * @param name defines the name
  12034. * @param manager defines the manager
  12035. */
  12036. constructor(
  12037. /** defines the name */
  12038. name: string, manager: ISpriteManager);
  12039. /**
  12040. * Starts an animation
  12041. * @param from defines the initial key
  12042. * @param to defines the end key
  12043. * @param loop defines if the animation must loop
  12044. * @param delay defines the start delay (in ms)
  12045. * @param onAnimationEnd defines a callback to call when animation ends
  12046. */
  12047. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12048. /** Stops current animation (if any) */
  12049. stopAnimation(): void;
  12050. /** @hidden */
  12051. _animate(deltaTime: number): void;
  12052. /** Release associated resources */
  12053. dispose(): void;
  12054. }
  12055. }
  12056. declare module "babylonjs/Collisions/pickingInfo" {
  12057. import { Nullable } from "babylonjs/types";
  12058. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  12059. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12060. import { Sprite } from "babylonjs/Sprites/sprite";
  12061. import { Ray } from "babylonjs/Culling/ray";
  12062. /**
  12063. * Information about the result of picking within a scene
  12064. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12065. */
  12066. export class PickingInfo {
  12067. /** @hidden */
  12068. _pickingUnavailable: boolean;
  12069. /**
  12070. * If the pick collided with an object
  12071. */
  12072. hit: boolean;
  12073. /**
  12074. * Distance away where the pick collided
  12075. */
  12076. distance: number;
  12077. /**
  12078. * The location of pick collision
  12079. */
  12080. pickedPoint: Nullable<Vector3>;
  12081. /**
  12082. * The mesh corresponding the the pick collision
  12083. */
  12084. pickedMesh: Nullable<AbstractMesh>;
  12085. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  12086. bu: number;
  12087. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  12088. bv: number;
  12089. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12090. faceId: number;
  12091. /** Id of the the submesh that was picked */
  12092. subMeshId: number;
  12093. /** If a sprite was picked, this will be the sprite the pick collided with */
  12094. pickedSprite: Nullable<Sprite>;
  12095. /**
  12096. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12097. */
  12098. originMesh: Nullable<AbstractMesh>;
  12099. /**
  12100. * The ray that was used to perform the picking.
  12101. */
  12102. ray: Nullable<Ray>;
  12103. /**
  12104. * Gets the normal correspodning to the face the pick collided with
  12105. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12106. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12107. * @returns The normal correspodning to the face the pick collided with
  12108. */
  12109. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12110. /**
  12111. * Gets the texture coordinates of where the pick occured
  12112. * @returns the vector containing the coordnates of the texture
  12113. */
  12114. getTextureCoordinates(): Nullable<Vector2>;
  12115. }
  12116. }
  12117. declare module "babylonjs/Events/pointerEvents" {
  12118. import { Nullable } from "babylonjs/types";
  12119. import { Vector2 } from "babylonjs/Maths/math";
  12120. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12121. import { Ray } from "babylonjs/Culling/ray";
  12122. /**
  12123. * Gather the list of pointer event types as constants.
  12124. */
  12125. export class PointerEventTypes {
  12126. /**
  12127. * 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.
  12128. */
  12129. static readonly POINTERDOWN: number;
  12130. /**
  12131. * The pointerup event is fired when a pointer is no longer active.
  12132. */
  12133. static readonly POINTERUP: number;
  12134. /**
  12135. * The pointermove event is fired when a pointer changes coordinates.
  12136. */
  12137. static readonly POINTERMOVE: number;
  12138. /**
  12139. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12140. */
  12141. static readonly POINTERWHEEL: number;
  12142. /**
  12143. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12144. */
  12145. static readonly POINTERPICK: number;
  12146. /**
  12147. * The pointertap event is fired when a the object has been touched and released without drag.
  12148. */
  12149. static readonly POINTERTAP: number;
  12150. /**
  12151. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12152. */
  12153. static readonly POINTERDOUBLETAP: number;
  12154. }
  12155. /**
  12156. * Base class of pointer info types.
  12157. */
  12158. export class PointerInfoBase {
  12159. /**
  12160. * Defines the type of event (PointerEventTypes)
  12161. */
  12162. type: number;
  12163. /**
  12164. * Defines the related dom event
  12165. */
  12166. event: PointerEvent | MouseWheelEvent;
  12167. /**
  12168. * Instantiates the base class of pointers info.
  12169. * @param type Defines the type of event (PointerEventTypes)
  12170. * @param event Defines the related dom event
  12171. */
  12172. constructor(
  12173. /**
  12174. * Defines the type of event (PointerEventTypes)
  12175. */
  12176. type: number,
  12177. /**
  12178. * Defines the related dom event
  12179. */
  12180. event: PointerEvent | MouseWheelEvent);
  12181. }
  12182. /**
  12183. * This class is used to store pointer related info for the onPrePointerObservable event.
  12184. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12185. */
  12186. export class PointerInfoPre extends PointerInfoBase {
  12187. /**
  12188. * Ray from a pointer if availible (eg. 6dof controller)
  12189. */
  12190. ray: Nullable<Ray>;
  12191. /**
  12192. * Defines the local position of the pointer on the canvas.
  12193. */
  12194. localPosition: Vector2;
  12195. /**
  12196. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12197. */
  12198. skipOnPointerObservable: boolean;
  12199. /**
  12200. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12201. * @param type Defines the type of event (PointerEventTypes)
  12202. * @param event Defines the related dom event
  12203. * @param localX Defines the local x coordinates of the pointer when the event occured
  12204. * @param localY Defines the local y coordinates of the pointer when the event occured
  12205. */
  12206. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12207. }
  12208. /**
  12209. * This type contains all the data related to a pointer event in Babylon.js.
  12210. * 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.
  12211. */
  12212. export class PointerInfo extends PointerInfoBase {
  12213. /**
  12214. * Defines the picking info associated to the info (if any)\
  12215. */
  12216. pickInfo: Nullable<PickingInfo>;
  12217. /**
  12218. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12219. * @param type Defines the type of event (PointerEventTypes)
  12220. * @param event Defines the related dom event
  12221. * @param pickInfo Defines the picking info associated to the info (if any)\
  12222. */
  12223. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12224. /**
  12225. * Defines the picking info associated to the info (if any)\
  12226. */
  12227. pickInfo: Nullable<PickingInfo>);
  12228. }
  12229. /**
  12230. * Data relating to a touch event on the screen.
  12231. */
  12232. export interface PointerTouch {
  12233. /**
  12234. * X coordinate of touch.
  12235. */
  12236. x: number;
  12237. /**
  12238. * Y coordinate of touch.
  12239. */
  12240. y: number;
  12241. /**
  12242. * Id of touch. Unique for each finger.
  12243. */
  12244. pointerId: number;
  12245. /**
  12246. * Event type passed from DOM.
  12247. */
  12248. type: any;
  12249. }
  12250. }
  12251. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12252. import { Nullable } from "babylonjs/types";
  12253. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12254. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12255. /**
  12256. * Manage the mouse inputs to control the movement of a free camera.
  12257. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12258. */
  12259. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12260. /**
  12261. * Define if touch is enabled in the mouse input
  12262. */
  12263. touchEnabled: boolean;
  12264. /**
  12265. * Defines the camera the input is attached to.
  12266. */
  12267. camera: FreeCamera;
  12268. /**
  12269. * Defines the buttons associated with the input to handle camera move.
  12270. */
  12271. buttons: number[];
  12272. /**
  12273. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12274. */
  12275. angularSensibility: number;
  12276. private _pointerInput;
  12277. private _onMouseMove;
  12278. private _observer;
  12279. private previousPosition;
  12280. /**
  12281. * Manage the mouse inputs to control the movement of a free camera.
  12282. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12283. * @param touchEnabled Defines if touch is enabled or not
  12284. */
  12285. constructor(
  12286. /**
  12287. * Define if touch is enabled in the mouse input
  12288. */
  12289. touchEnabled?: boolean);
  12290. /**
  12291. * Attach the input controls to a specific dom element to get the input from.
  12292. * @param element Defines the element the controls should be listened from
  12293. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12294. */
  12295. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12296. /**
  12297. * Called on JS contextmenu event.
  12298. * Override this method to provide functionality.
  12299. */
  12300. protected onContextMenu(evt: PointerEvent): void;
  12301. /**
  12302. * Detach the current controls from the specified dom element.
  12303. * @param element Defines the element to stop listening the inputs from
  12304. */
  12305. detachControl(element: Nullable<HTMLElement>): void;
  12306. /**
  12307. * Gets the class name of the current intput.
  12308. * @returns the class name
  12309. */
  12310. getClassName(): string;
  12311. /**
  12312. * Get the friendly name associated with the input class.
  12313. * @returns the input friendly name
  12314. */
  12315. getSimpleName(): string;
  12316. }
  12317. }
  12318. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12319. import { Nullable } from "babylonjs/types";
  12320. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12321. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12322. /**
  12323. * Manage the touch inputs to control the movement of a free camera.
  12324. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12325. */
  12326. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12327. /**
  12328. * Defines the camera the input is attached to.
  12329. */
  12330. camera: FreeCamera;
  12331. /**
  12332. * Defines the touch sensibility for rotation.
  12333. * The higher the faster.
  12334. */
  12335. touchAngularSensibility: number;
  12336. /**
  12337. * Defines the touch sensibility for move.
  12338. * The higher the faster.
  12339. */
  12340. touchMoveSensibility: number;
  12341. private _offsetX;
  12342. private _offsetY;
  12343. private _pointerPressed;
  12344. private _pointerInput;
  12345. private _observer;
  12346. private _onLostFocus;
  12347. /**
  12348. * Attach the input controls to a specific dom element to get the input from.
  12349. * @param element Defines the element the controls should be listened from
  12350. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12351. */
  12352. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12353. /**
  12354. * Detach the current controls from the specified dom element.
  12355. * @param element Defines the element to stop listening the inputs from
  12356. */
  12357. detachControl(element: Nullable<HTMLElement>): void;
  12358. /**
  12359. * Update the current camera state depending on the inputs that have been used this frame.
  12360. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12361. */
  12362. checkInputs(): void;
  12363. /**
  12364. * Gets the class name of the current intput.
  12365. * @returns the class name
  12366. */
  12367. getClassName(): string;
  12368. /**
  12369. * Get the friendly name associated with the input class.
  12370. * @returns the input friendly name
  12371. */
  12372. getSimpleName(): string;
  12373. }
  12374. }
  12375. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12376. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12377. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12378. /**
  12379. * Default Inputs manager for the FreeCamera.
  12380. * It groups all the default supported inputs for ease of use.
  12381. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12382. */
  12383. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12384. /**
  12385. * Instantiates a new FreeCameraInputsManager.
  12386. * @param camera Defines the camera the inputs belong to
  12387. */
  12388. constructor(camera: FreeCamera);
  12389. /**
  12390. * Add keyboard input support to the input manager.
  12391. * @returns the current input manager
  12392. */
  12393. addKeyboard(): FreeCameraInputsManager;
  12394. /**
  12395. * Add mouse input support to the input manager.
  12396. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12397. * @returns the current input manager
  12398. */
  12399. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12400. /**
  12401. * Add touch input support to the input manager.
  12402. * @returns the current input manager
  12403. */
  12404. addTouch(): FreeCameraInputsManager;
  12405. }
  12406. }
  12407. declare module "babylonjs/Cameras/freeCamera" {
  12408. import { Vector3 } from "babylonjs/Maths/math";
  12409. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12410. import { Scene } from "babylonjs/scene";
  12411. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12412. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12413. /**
  12414. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12415. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12416. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12417. */
  12418. export class FreeCamera extends TargetCamera {
  12419. /**
  12420. * Define the collision ellipsoid of the camera.
  12421. * This is helpful to simulate a camera body like the player body around the camera
  12422. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12423. */
  12424. ellipsoid: Vector3;
  12425. /**
  12426. * Define an offset for the position of the ellipsoid around the camera.
  12427. * This can be helpful to determine the center of the body near the gravity center of the body
  12428. * instead of its head.
  12429. */
  12430. ellipsoidOffset: Vector3;
  12431. /**
  12432. * Enable or disable collisions of the camera with the rest of the scene objects.
  12433. */
  12434. checkCollisions: boolean;
  12435. /**
  12436. * Enable or disable gravity on the camera.
  12437. */
  12438. applyGravity: boolean;
  12439. /**
  12440. * Define the input manager associated to the camera.
  12441. */
  12442. inputs: FreeCameraInputsManager;
  12443. /**
  12444. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12445. * Higher values reduce sensitivity.
  12446. */
  12447. /**
  12448. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12449. * Higher values reduce sensitivity.
  12450. */
  12451. angularSensibility: number;
  12452. /**
  12453. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12454. */
  12455. keysUp: number[];
  12456. /**
  12457. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12458. */
  12459. keysDown: number[];
  12460. /**
  12461. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12462. */
  12463. keysLeft: number[];
  12464. /**
  12465. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12466. */
  12467. keysRight: number[];
  12468. /**
  12469. * Event raised when the camera collide with a mesh in the scene.
  12470. */
  12471. onCollide: (collidedMesh: AbstractMesh) => void;
  12472. private _collider;
  12473. private _needMoveForGravity;
  12474. private _oldPosition;
  12475. private _diffPosition;
  12476. private _newPosition;
  12477. /** @hidden */
  12478. _localDirection: Vector3;
  12479. /** @hidden */
  12480. _transformedDirection: Vector3;
  12481. /**
  12482. * Instantiates a Free Camera.
  12483. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12484. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12485. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12486. * @param name Define the name of the camera in the scene
  12487. * @param position Define the start position of the camera in the scene
  12488. * @param scene Define the scene the camera belongs to
  12489. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12490. */
  12491. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12492. /**
  12493. * Attached controls to the current camera.
  12494. * @param element Defines the element the controls should be listened from
  12495. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12496. */
  12497. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12498. /**
  12499. * Detach the current controls from the camera.
  12500. * The camera will stop reacting to inputs.
  12501. * @param element Defines the element to stop listening the inputs from
  12502. */
  12503. detachControl(element: HTMLElement): void;
  12504. private _collisionMask;
  12505. /**
  12506. * Define a collision mask to limit the list of object the camera can collide with
  12507. */
  12508. collisionMask: number;
  12509. /** @hidden */
  12510. _collideWithWorld(displacement: Vector3): void;
  12511. private _onCollisionPositionChange;
  12512. /** @hidden */
  12513. _checkInputs(): void;
  12514. /** @hidden */
  12515. _decideIfNeedsToMove(): boolean;
  12516. /** @hidden */
  12517. _updatePosition(): void;
  12518. /**
  12519. * Destroy the camera and release the current resources hold by it.
  12520. */
  12521. dispose(): void;
  12522. /**
  12523. * Gets the current object class name.
  12524. * @return the class name
  12525. */
  12526. getClassName(): string;
  12527. }
  12528. }
  12529. declare module "babylonjs/Gamepads/gamepad" {
  12530. import { Observable } from "babylonjs/Misc/observable";
  12531. /**
  12532. * Represents a gamepad control stick position
  12533. */
  12534. export class StickValues {
  12535. /**
  12536. * The x component of the control stick
  12537. */
  12538. x: number;
  12539. /**
  12540. * The y component of the control stick
  12541. */
  12542. y: number;
  12543. /**
  12544. * Initializes the gamepad x and y control stick values
  12545. * @param x The x component of the gamepad control stick value
  12546. * @param y The y component of the gamepad control stick value
  12547. */
  12548. constructor(
  12549. /**
  12550. * The x component of the control stick
  12551. */
  12552. x: number,
  12553. /**
  12554. * The y component of the control stick
  12555. */
  12556. y: number);
  12557. }
  12558. /**
  12559. * An interface which manages callbacks for gamepad button changes
  12560. */
  12561. export interface GamepadButtonChanges {
  12562. /**
  12563. * Called when a gamepad has been changed
  12564. */
  12565. changed: boolean;
  12566. /**
  12567. * Called when a gamepad press event has been triggered
  12568. */
  12569. pressChanged: boolean;
  12570. /**
  12571. * Called when a touch event has been triggered
  12572. */
  12573. touchChanged: boolean;
  12574. /**
  12575. * Called when a value has changed
  12576. */
  12577. valueChanged: boolean;
  12578. }
  12579. /**
  12580. * Represents a gamepad
  12581. */
  12582. export class Gamepad {
  12583. /**
  12584. * The id of the gamepad
  12585. */
  12586. id: string;
  12587. /**
  12588. * The index of the gamepad
  12589. */
  12590. index: number;
  12591. /**
  12592. * The browser gamepad
  12593. */
  12594. browserGamepad: any;
  12595. /**
  12596. * Specifies what type of gamepad this represents
  12597. */
  12598. type: number;
  12599. private _leftStick;
  12600. private _rightStick;
  12601. /** @hidden */
  12602. _isConnected: boolean;
  12603. private _leftStickAxisX;
  12604. private _leftStickAxisY;
  12605. private _rightStickAxisX;
  12606. private _rightStickAxisY;
  12607. /**
  12608. * Triggered when the left control stick has been changed
  12609. */
  12610. private _onleftstickchanged;
  12611. /**
  12612. * Triggered when the right control stick has been changed
  12613. */
  12614. private _onrightstickchanged;
  12615. /**
  12616. * Represents a gamepad controller
  12617. */
  12618. static GAMEPAD: number;
  12619. /**
  12620. * Represents a generic controller
  12621. */
  12622. static GENERIC: number;
  12623. /**
  12624. * Represents an XBox controller
  12625. */
  12626. static XBOX: number;
  12627. /**
  12628. * Represents a pose-enabled controller
  12629. */
  12630. static POSE_ENABLED: number;
  12631. /**
  12632. * Specifies whether the left control stick should be Y-inverted
  12633. */
  12634. protected _invertLeftStickY: boolean;
  12635. /**
  12636. * Specifies if the gamepad has been connected
  12637. */
  12638. readonly isConnected: boolean;
  12639. /**
  12640. * Initializes the gamepad
  12641. * @param id The id of the gamepad
  12642. * @param index The index of the gamepad
  12643. * @param browserGamepad The browser gamepad
  12644. * @param leftStickX The x component of the left joystick
  12645. * @param leftStickY The y component of the left joystick
  12646. * @param rightStickX The x component of the right joystick
  12647. * @param rightStickY The y component of the right joystick
  12648. */
  12649. constructor(
  12650. /**
  12651. * The id of the gamepad
  12652. */
  12653. id: string,
  12654. /**
  12655. * The index of the gamepad
  12656. */
  12657. index: number,
  12658. /**
  12659. * The browser gamepad
  12660. */
  12661. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12662. /**
  12663. * Callback triggered when the left joystick has changed
  12664. * @param callback
  12665. */
  12666. onleftstickchanged(callback: (values: StickValues) => void): void;
  12667. /**
  12668. * Callback triggered when the right joystick has changed
  12669. * @param callback
  12670. */
  12671. onrightstickchanged(callback: (values: StickValues) => void): void;
  12672. /**
  12673. * Gets the left joystick
  12674. */
  12675. /**
  12676. * Sets the left joystick values
  12677. */
  12678. leftStick: StickValues;
  12679. /**
  12680. * Gets the right joystick
  12681. */
  12682. /**
  12683. * Sets the right joystick value
  12684. */
  12685. rightStick: StickValues;
  12686. /**
  12687. * Updates the gamepad joystick positions
  12688. */
  12689. update(): void;
  12690. /**
  12691. * Disposes the gamepad
  12692. */
  12693. dispose(): void;
  12694. }
  12695. /**
  12696. * Represents a generic gamepad
  12697. */
  12698. export class GenericPad extends Gamepad {
  12699. private _buttons;
  12700. private _onbuttondown;
  12701. private _onbuttonup;
  12702. /**
  12703. * Observable triggered when a button has been pressed
  12704. */
  12705. onButtonDownObservable: Observable<number>;
  12706. /**
  12707. * Observable triggered when a button has been released
  12708. */
  12709. onButtonUpObservable: Observable<number>;
  12710. /**
  12711. * Callback triggered when a button has been pressed
  12712. * @param callback Called when a button has been pressed
  12713. */
  12714. onbuttondown(callback: (buttonPressed: number) => void): void;
  12715. /**
  12716. * Callback triggered when a button has been released
  12717. * @param callback Called when a button has been released
  12718. */
  12719. onbuttonup(callback: (buttonReleased: number) => void): void;
  12720. /**
  12721. * Initializes the generic gamepad
  12722. * @param id The id of the generic gamepad
  12723. * @param index The index of the generic gamepad
  12724. * @param browserGamepad The browser gamepad
  12725. */
  12726. constructor(id: string, index: number, browserGamepad: any);
  12727. private _setButtonValue;
  12728. /**
  12729. * Updates the generic gamepad
  12730. */
  12731. update(): void;
  12732. /**
  12733. * Disposes the generic gamepad
  12734. */
  12735. dispose(): void;
  12736. }
  12737. }
  12738. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  12739. import { Observable } from "babylonjs/Misc/observable";
  12740. import { Nullable } from "babylonjs/types";
  12741. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12742. import { TransformNode } from "babylonjs/Meshes/transformNode";
  12743. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12744. import { Ray } from "babylonjs/Culling/ray";
  12745. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  12746. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  12747. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12748. /**
  12749. * Defines the types of pose enabled controllers that are supported
  12750. */
  12751. export enum PoseEnabledControllerType {
  12752. /**
  12753. * HTC Vive
  12754. */
  12755. VIVE = 0,
  12756. /**
  12757. * Oculus Rift
  12758. */
  12759. OCULUS = 1,
  12760. /**
  12761. * Windows mixed reality
  12762. */
  12763. WINDOWS = 2,
  12764. /**
  12765. * Samsung gear VR
  12766. */
  12767. GEAR_VR = 3,
  12768. /**
  12769. * Google Daydream
  12770. */
  12771. DAYDREAM = 4,
  12772. /**
  12773. * Generic
  12774. */
  12775. GENERIC = 5
  12776. }
  12777. /**
  12778. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12779. */
  12780. export interface MutableGamepadButton {
  12781. /**
  12782. * Value of the button/trigger
  12783. */
  12784. value: number;
  12785. /**
  12786. * If the button/trigger is currently touched
  12787. */
  12788. touched: boolean;
  12789. /**
  12790. * If the button/trigger is currently pressed
  12791. */
  12792. pressed: boolean;
  12793. }
  12794. /**
  12795. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12796. * @hidden
  12797. */
  12798. export interface ExtendedGamepadButton extends GamepadButton {
  12799. /**
  12800. * If the button/trigger is currently pressed
  12801. */
  12802. readonly pressed: boolean;
  12803. /**
  12804. * If the button/trigger is currently touched
  12805. */
  12806. readonly touched: boolean;
  12807. /**
  12808. * Value of the button/trigger
  12809. */
  12810. readonly value: number;
  12811. }
  12812. /** @hidden */
  12813. export interface _GamePadFactory {
  12814. /**
  12815. * Returns wether or not the current gamepad can be created for this type of controller.
  12816. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12817. * @returns true if it can be created, otherwise false
  12818. */
  12819. canCreate(gamepadInfo: any): boolean;
  12820. /**
  12821. * Creates a new instance of the Gamepad.
  12822. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12823. * @returns the new gamepad instance
  12824. */
  12825. create(gamepadInfo: any): Gamepad;
  12826. }
  12827. /**
  12828. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12829. */
  12830. export class PoseEnabledControllerHelper {
  12831. /** @hidden */
  12832. static _ControllerFactories: _GamePadFactory[];
  12833. /** @hidden */
  12834. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12835. /**
  12836. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12837. * @param vrGamepad the gamepad to initialized
  12838. * @returns a vr controller of the type the gamepad identified as
  12839. */
  12840. static InitiateController(vrGamepad: any): Gamepad;
  12841. }
  12842. /**
  12843. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12844. */
  12845. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12846. private _deviceRoomPosition;
  12847. private _deviceRoomRotationQuaternion;
  12848. /**
  12849. * The device position in babylon space
  12850. */
  12851. devicePosition: Vector3;
  12852. /**
  12853. * The device rotation in babylon space
  12854. */
  12855. deviceRotationQuaternion: Quaternion;
  12856. /**
  12857. * The scale factor of the device in babylon space
  12858. */
  12859. deviceScaleFactor: number;
  12860. /**
  12861. * (Likely devicePosition should be used instead) The device position in its room space
  12862. */
  12863. position: Vector3;
  12864. /**
  12865. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12866. */
  12867. rotationQuaternion: Quaternion;
  12868. /**
  12869. * The type of controller (Eg. Windows mixed reality)
  12870. */
  12871. controllerType: PoseEnabledControllerType;
  12872. protected _calculatedPosition: Vector3;
  12873. private _calculatedRotation;
  12874. /**
  12875. * The raw pose from the device
  12876. */
  12877. rawPose: DevicePose;
  12878. private _trackPosition;
  12879. private _maxRotationDistFromHeadset;
  12880. private _draggedRoomRotation;
  12881. /**
  12882. * @hidden
  12883. */
  12884. _disableTrackPosition(fixedPosition: Vector3): void;
  12885. /**
  12886. * Internal, the mesh attached to the controller
  12887. * @hidden
  12888. */
  12889. _mesh: Nullable<AbstractMesh>;
  12890. private _poseControlledCamera;
  12891. private _leftHandSystemQuaternion;
  12892. /**
  12893. * Internal, matrix used to convert room space to babylon space
  12894. * @hidden
  12895. */
  12896. _deviceToWorld: Matrix;
  12897. /**
  12898. * Node to be used when casting a ray from the controller
  12899. * @hidden
  12900. */
  12901. _pointingPoseNode: Nullable<TransformNode>;
  12902. /**
  12903. * Name of the child mesh that can be used to cast a ray from the controller
  12904. */
  12905. static readonly POINTING_POSE: string;
  12906. /**
  12907. * Creates a new PoseEnabledController from a gamepad
  12908. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12909. */
  12910. constructor(browserGamepad: any);
  12911. private _workingMatrix;
  12912. /**
  12913. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12914. */
  12915. update(): void;
  12916. /**
  12917. * Updates only the pose device and mesh without doing any button event checking
  12918. */
  12919. protected _updatePoseAndMesh(): void;
  12920. /**
  12921. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12922. * @param poseData raw pose fromthe device
  12923. */
  12924. updateFromDevice(poseData: DevicePose): void;
  12925. /**
  12926. * @hidden
  12927. */
  12928. _meshAttachedObservable: Observable<AbstractMesh>;
  12929. /**
  12930. * Attaches a mesh to the controller
  12931. * @param mesh the mesh to be attached
  12932. */
  12933. attachToMesh(mesh: AbstractMesh): void;
  12934. /**
  12935. * Attaches the controllers mesh to a camera
  12936. * @param camera the camera the mesh should be attached to
  12937. */
  12938. attachToPoseControlledCamera(camera: TargetCamera): void;
  12939. /**
  12940. * Disposes of the controller
  12941. */
  12942. dispose(): void;
  12943. /**
  12944. * The mesh that is attached to the controller
  12945. */
  12946. readonly mesh: Nullable<AbstractMesh>;
  12947. /**
  12948. * Gets the ray of the controller in the direction the controller is pointing
  12949. * @param length the length the resulting ray should be
  12950. * @returns a ray in the direction the controller is pointing
  12951. */
  12952. getForwardRay(length?: number): Ray;
  12953. }
  12954. }
  12955. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  12956. import { Observable } from "babylonjs/Misc/observable";
  12957. import { Scene } from "babylonjs/scene";
  12958. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12959. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  12960. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  12961. /**
  12962. * Defines the WebVRController object that represents controllers tracked in 3D space
  12963. */
  12964. export abstract class WebVRController extends PoseEnabledController {
  12965. /**
  12966. * Internal, the default controller model for the controller
  12967. */
  12968. protected _defaultModel: AbstractMesh;
  12969. /**
  12970. * Fired when the trigger state has changed
  12971. */
  12972. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12973. /**
  12974. * Fired when the main button state has changed
  12975. */
  12976. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12977. /**
  12978. * Fired when the secondary button state has changed
  12979. */
  12980. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12981. /**
  12982. * Fired when the pad state has changed
  12983. */
  12984. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12985. /**
  12986. * Fired when controllers stick values have changed
  12987. */
  12988. onPadValuesChangedObservable: Observable<StickValues>;
  12989. /**
  12990. * Array of button availible on the controller
  12991. */
  12992. protected _buttons: Array<MutableGamepadButton>;
  12993. private _onButtonStateChange;
  12994. /**
  12995. * Fired when a controller button's state has changed
  12996. * @param callback the callback containing the button that was modified
  12997. */
  12998. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12999. /**
  13000. * X and Y axis corrisponding to the controllers joystick
  13001. */
  13002. pad: StickValues;
  13003. /**
  13004. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  13005. */
  13006. hand: string;
  13007. /**
  13008. * The default controller model for the controller
  13009. */
  13010. readonly defaultModel: AbstractMesh;
  13011. /**
  13012. * Creates a new WebVRController from a gamepad
  13013. * @param vrGamepad the gamepad that the WebVRController should be created from
  13014. */
  13015. constructor(vrGamepad: any);
  13016. /**
  13017. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  13018. */
  13019. update(): void;
  13020. /**
  13021. * Function to be called when a button is modified
  13022. */
  13023. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  13024. /**
  13025. * Loads a mesh and attaches it to the controller
  13026. * @param scene the scene the mesh should be added to
  13027. * @param meshLoaded callback for when the mesh has been loaded
  13028. */
  13029. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  13030. private _setButtonValue;
  13031. private _changes;
  13032. private _checkChanges;
  13033. /**
  13034. * Disposes of th webVRCOntroller
  13035. */
  13036. dispose(): void;
  13037. }
  13038. }
  13039. declare module "babylonjs/Lights/hemisphericLight" {
  13040. import { Nullable } from "babylonjs/types";
  13041. import { Scene } from "babylonjs/scene";
  13042. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  13043. import { Effect } from "babylonjs/Materials/effect";
  13044. import { Light } from "babylonjs/Lights/light";
  13045. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  13046. /**
  13047. * The HemisphericLight simulates the ambient environment light,
  13048. * so the passed direction is the light reflection direction, not the incoming direction.
  13049. */
  13050. export class HemisphericLight extends Light {
  13051. /**
  13052. * The groundColor is the light in the opposite direction to the one specified during creation.
  13053. * 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.
  13054. */
  13055. groundColor: Color3;
  13056. /**
  13057. * The light reflection direction, not the incoming direction.
  13058. */
  13059. direction: Vector3;
  13060. /**
  13061. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  13062. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  13063. * The HemisphericLight can't cast shadows.
  13064. * Documentation : https://doc.babylonjs.com/babylon101/lights
  13065. * @param name The friendly name of the light
  13066. * @param direction The direction of the light reflection
  13067. * @param scene The scene the light belongs to
  13068. */
  13069. constructor(name: string, direction: Vector3, scene: Scene);
  13070. protected _buildUniformLayout(): void;
  13071. /**
  13072. * Returns the string "HemisphericLight".
  13073. * @return The class name
  13074. */
  13075. getClassName(): string;
  13076. /**
  13077. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13078. * Returns the updated direction.
  13079. * @param target The target the direction should point to
  13080. * @return The computed direction
  13081. */
  13082. setDirectionToTarget(target: Vector3): Vector3;
  13083. /**
  13084. * Returns the shadow generator associated to the light.
  13085. * @returns Always null for hemispheric lights because it does not support shadows.
  13086. */
  13087. getShadowGenerator(): Nullable<IShadowGenerator>;
  13088. /**
  13089. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13090. * @param effect The effect to update
  13091. * @param lightIndex The index of the light in the effect to update
  13092. * @returns The hemispheric light
  13093. */
  13094. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13095. /**
  13096. * Computes the world matrix of the node
  13097. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13098. * @param useWasUpdatedFlag defines a reserved property
  13099. * @returns the world matrix
  13100. */
  13101. computeWorldMatrix(): Matrix;
  13102. /**
  13103. * Returns the integer 3.
  13104. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13105. */
  13106. getTypeID(): number;
  13107. /**
  13108. * Prepares the list of defines specific to the light type.
  13109. * @param defines the list of defines
  13110. * @param lightIndex defines the index of the light for the effect
  13111. */
  13112. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13113. }
  13114. }
  13115. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  13116. declare module "babylonjs/Cameras/VR/webVRCamera" {
  13117. import { Nullable } from "babylonjs/types";
  13118. import { Observable } from "babylonjs/Misc/observable";
  13119. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  13120. import { Scene } from "babylonjs/scene";
  13121. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  13122. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  13123. import { Node } from "babylonjs/node";
  13124. import { Ray } from "babylonjs/Culling/ray";
  13125. import "babylonjs/Cameras/RigModes/webVRRigMode";
  13126. /**
  13127. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13128. * IMPORTANT!! The data is right-hand data.
  13129. * @export
  13130. * @interface DevicePose
  13131. */
  13132. export interface DevicePose {
  13133. /**
  13134. * The position of the device, values in array are [x,y,z].
  13135. */
  13136. readonly position: Nullable<Float32Array>;
  13137. /**
  13138. * The linearVelocity of the device, values in array are [x,y,z].
  13139. */
  13140. readonly linearVelocity: Nullable<Float32Array>;
  13141. /**
  13142. * The linearAcceleration of the device, values in array are [x,y,z].
  13143. */
  13144. readonly linearAcceleration: Nullable<Float32Array>;
  13145. /**
  13146. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13147. */
  13148. readonly orientation: Nullable<Float32Array>;
  13149. /**
  13150. * The angularVelocity of the device, values in array are [x,y,z].
  13151. */
  13152. readonly angularVelocity: Nullable<Float32Array>;
  13153. /**
  13154. * The angularAcceleration of the device, values in array are [x,y,z].
  13155. */
  13156. readonly angularAcceleration: Nullable<Float32Array>;
  13157. }
  13158. /**
  13159. * Interface representing a pose controlled object in Babylon.
  13160. * A pose controlled object has both regular pose values as well as pose values
  13161. * from an external device such as a VR head mounted display
  13162. */
  13163. export interface PoseControlled {
  13164. /**
  13165. * The position of the object in babylon space.
  13166. */
  13167. position: Vector3;
  13168. /**
  13169. * The rotation quaternion of the object in babylon space.
  13170. */
  13171. rotationQuaternion: Quaternion;
  13172. /**
  13173. * The position of the device in babylon space.
  13174. */
  13175. devicePosition?: Vector3;
  13176. /**
  13177. * The rotation quaternion of the device in babylon space.
  13178. */
  13179. deviceRotationQuaternion: Quaternion;
  13180. /**
  13181. * The raw pose coming from the device.
  13182. */
  13183. rawPose: Nullable<DevicePose>;
  13184. /**
  13185. * The scale of the device to be used when translating from device space to babylon space.
  13186. */
  13187. deviceScaleFactor: number;
  13188. /**
  13189. * Updates the poseControlled values based on the input device pose.
  13190. * @param poseData the pose data to update the object with
  13191. */
  13192. updateFromDevice(poseData: DevicePose): void;
  13193. }
  13194. /**
  13195. * Set of options to customize the webVRCamera
  13196. */
  13197. export interface WebVROptions {
  13198. /**
  13199. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13200. */
  13201. trackPosition?: boolean;
  13202. /**
  13203. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13204. */
  13205. positionScale?: number;
  13206. /**
  13207. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13208. */
  13209. displayName?: string;
  13210. /**
  13211. * Should the native controller meshes be initialized. (default: true)
  13212. */
  13213. controllerMeshes?: boolean;
  13214. /**
  13215. * Creating a default HemiLight only on controllers. (default: true)
  13216. */
  13217. defaultLightingOnControllers?: boolean;
  13218. /**
  13219. * If you don't want to use the default VR button of the helper. (default: false)
  13220. */
  13221. useCustomVRButton?: boolean;
  13222. /**
  13223. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13224. */
  13225. customVRButton?: HTMLButtonElement;
  13226. /**
  13227. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13228. */
  13229. rayLength?: number;
  13230. /**
  13231. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13232. */
  13233. defaultHeight?: number;
  13234. }
  13235. /**
  13236. * This represents a WebVR camera.
  13237. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13238. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13239. */
  13240. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13241. private webVROptions;
  13242. /**
  13243. * @hidden
  13244. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13245. */
  13246. _vrDevice: any;
  13247. /**
  13248. * The rawPose of the vrDevice.
  13249. */
  13250. rawPose: Nullable<DevicePose>;
  13251. private _onVREnabled;
  13252. private _specsVersion;
  13253. private _attached;
  13254. private _frameData;
  13255. protected _descendants: Array<Node>;
  13256. private _deviceRoomPosition;
  13257. /** @hidden */
  13258. _deviceRoomRotationQuaternion: Quaternion;
  13259. private _standingMatrix;
  13260. /**
  13261. * Represents device position in babylon space.
  13262. */
  13263. devicePosition: Vector3;
  13264. /**
  13265. * Represents device rotation in babylon space.
  13266. */
  13267. deviceRotationQuaternion: Quaternion;
  13268. /**
  13269. * The scale of the device to be used when translating from device space to babylon space.
  13270. */
  13271. deviceScaleFactor: number;
  13272. private _deviceToWorld;
  13273. private _worldToDevice;
  13274. /**
  13275. * References to the webVR controllers for the vrDevice.
  13276. */
  13277. controllers: Array<WebVRController>;
  13278. /**
  13279. * Emits an event when a controller is attached.
  13280. */
  13281. onControllersAttachedObservable: Observable<WebVRController[]>;
  13282. /**
  13283. * Emits an event when a controller's mesh has been loaded;
  13284. */
  13285. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13286. /**
  13287. * Emits an event when the HMD's pose has been updated.
  13288. */
  13289. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13290. private _poseSet;
  13291. /**
  13292. * If the rig cameras be used as parent instead of this camera.
  13293. */
  13294. rigParenting: boolean;
  13295. private _lightOnControllers;
  13296. private _defaultHeight?;
  13297. /**
  13298. * Instantiates a WebVRFreeCamera.
  13299. * @param name The name of the WebVRFreeCamera
  13300. * @param position The starting anchor position for the camera
  13301. * @param scene The scene the camera belongs to
  13302. * @param webVROptions a set of customizable options for the webVRCamera
  13303. */
  13304. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13305. /**
  13306. * Gets the device distance from the ground in meters.
  13307. * @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.
  13308. */
  13309. deviceDistanceToRoomGround(): number;
  13310. /**
  13311. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13312. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13313. */
  13314. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13315. /**
  13316. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13317. * @returns A promise with a boolean set to if the standing matrix is supported.
  13318. */
  13319. useStandingMatrixAsync(): Promise<boolean>;
  13320. /**
  13321. * Disposes the camera
  13322. */
  13323. dispose(): void;
  13324. /**
  13325. * Gets a vrController by name.
  13326. * @param name The name of the controller to retreive
  13327. * @returns the controller matching the name specified or null if not found
  13328. */
  13329. getControllerByName(name: string): Nullable<WebVRController>;
  13330. private _leftController;
  13331. /**
  13332. * The controller corrisponding to the users left hand.
  13333. */
  13334. readonly leftController: Nullable<WebVRController>;
  13335. private _rightController;
  13336. /**
  13337. * The controller corrisponding to the users right hand.
  13338. */
  13339. readonly rightController: Nullable<WebVRController>;
  13340. /**
  13341. * Casts a ray forward from the vrCamera's gaze.
  13342. * @param length Length of the ray (default: 100)
  13343. * @returns the ray corrisponding to the gaze
  13344. */
  13345. getForwardRay(length?: number): Ray;
  13346. /**
  13347. * @hidden
  13348. * Updates the camera based on device's frame data
  13349. */
  13350. _checkInputs(): void;
  13351. /**
  13352. * Updates the poseControlled values based on the input device pose.
  13353. * @param poseData Pose coming from the device
  13354. */
  13355. updateFromDevice(poseData: DevicePose): void;
  13356. private _htmlElementAttached;
  13357. private _detachIfAttached;
  13358. /**
  13359. * WebVR's attach control will start broadcasting frames to the device.
  13360. * Note that in certain browsers (chrome for example) this function must be called
  13361. * within a user-interaction callback. Example:
  13362. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13363. *
  13364. * @param element html element to attach the vrDevice to
  13365. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13366. */
  13367. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13368. /**
  13369. * Detaches the camera from the html element and disables VR
  13370. *
  13371. * @param element html element to detach from
  13372. */
  13373. detachControl(element: HTMLElement): void;
  13374. /**
  13375. * @returns the name of this class
  13376. */
  13377. getClassName(): string;
  13378. /**
  13379. * Calls resetPose on the vrDisplay
  13380. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13381. */
  13382. resetToCurrentRotation(): void;
  13383. /**
  13384. * @hidden
  13385. * Updates the rig cameras (left and right eye)
  13386. */
  13387. _updateRigCameras(): void;
  13388. private _workingVector;
  13389. private _oneVector;
  13390. private _workingMatrix;
  13391. private updateCacheCalled;
  13392. private _correctPositionIfNotTrackPosition;
  13393. /**
  13394. * @hidden
  13395. * Updates the cached values of the camera
  13396. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13397. */
  13398. _updateCache(ignoreParentClass?: boolean): void;
  13399. /**
  13400. * @hidden
  13401. * Get current device position in babylon world
  13402. */
  13403. _computeDevicePosition(): void;
  13404. /**
  13405. * Updates the current device position and rotation in the babylon world
  13406. */
  13407. update(): void;
  13408. /**
  13409. * @hidden
  13410. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13411. * @returns an identity matrix
  13412. */
  13413. _getViewMatrix(): Matrix;
  13414. private _tmpMatrix;
  13415. /**
  13416. * This function is called by the two RIG cameras.
  13417. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13418. * @hidden
  13419. */
  13420. _getWebVRViewMatrix(): Matrix;
  13421. /** @hidden */
  13422. _getWebVRProjectionMatrix(): Matrix;
  13423. private _onGamepadConnectedObserver;
  13424. private _onGamepadDisconnectedObserver;
  13425. private _updateCacheWhenTrackingDisabledObserver;
  13426. /**
  13427. * Initializes the controllers and their meshes
  13428. */
  13429. initControllers(): void;
  13430. }
  13431. }
  13432. declare module "babylonjs/PostProcesses/postProcess" {
  13433. import { Nullable } from "babylonjs/types";
  13434. import { SmartArray } from "babylonjs/Misc/smartArray";
  13435. import { Observable } from "babylonjs/Misc/observable";
  13436. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13437. import { Camera } from "babylonjs/Cameras/camera";
  13438. import { Effect } from "babylonjs/Materials/effect";
  13439. import "babylonjs/Shaders/postprocess.vertex";
  13440. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13441. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13442. import { Engine } from "babylonjs/Engines/engine";
  13443. /**
  13444. * Size options for a post process
  13445. */
  13446. export type PostProcessOptions = {
  13447. width: number;
  13448. height: number;
  13449. };
  13450. /**
  13451. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13452. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13453. */
  13454. export class PostProcess {
  13455. /** Name of the PostProcess. */
  13456. name: string;
  13457. /**
  13458. * Gets or sets the unique id of the post process
  13459. */
  13460. uniqueId: number;
  13461. /**
  13462. * Width of the texture to apply the post process on
  13463. */
  13464. width: number;
  13465. /**
  13466. * Height of the texture to apply the post process on
  13467. */
  13468. height: number;
  13469. /**
  13470. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13471. * @hidden
  13472. */
  13473. _outputTexture: Nullable<InternalTexture>;
  13474. /**
  13475. * Sampling mode used by the shader
  13476. * See https://doc.babylonjs.com/classes/3.1/texture
  13477. */
  13478. renderTargetSamplingMode: number;
  13479. /**
  13480. * Clear color to use when screen clearing
  13481. */
  13482. clearColor: Color4;
  13483. /**
  13484. * If the buffer needs to be cleared before applying the post process. (default: true)
  13485. * Should be set to false if shader will overwrite all previous pixels.
  13486. */
  13487. autoClear: boolean;
  13488. /**
  13489. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13490. */
  13491. alphaMode: number;
  13492. /**
  13493. * Sets the setAlphaBlendConstants of the babylon engine
  13494. */
  13495. alphaConstants: Color4;
  13496. /**
  13497. * Animations to be used for the post processing
  13498. */
  13499. animations: import("babylonjs/Animations/animation").Animation[];
  13500. /**
  13501. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13502. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13503. */
  13504. enablePixelPerfectMode: boolean;
  13505. /**
  13506. * Force the postprocess to be applied without taking in account viewport
  13507. */
  13508. forceFullscreenViewport: boolean;
  13509. /**
  13510. * List of inspectable custom properties (used by the Inspector)
  13511. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13512. */
  13513. inspectableCustomProperties: IInspectable[];
  13514. /**
  13515. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13516. *
  13517. * | Value | Type | Description |
  13518. * | ----- | ----------------------------------- | ----------- |
  13519. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13520. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13521. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13522. *
  13523. */
  13524. scaleMode: number;
  13525. /**
  13526. * Force textures to be a power of two (default: false)
  13527. */
  13528. alwaysForcePOT: boolean;
  13529. private _samples;
  13530. /**
  13531. * Number of sample textures (default: 1)
  13532. */
  13533. samples: number;
  13534. /**
  13535. * Modify the scale of the post process to be the same as the viewport (default: false)
  13536. */
  13537. adaptScaleToCurrentViewport: boolean;
  13538. private _camera;
  13539. private _scene;
  13540. private _engine;
  13541. private _options;
  13542. private _reusable;
  13543. private _textureType;
  13544. /**
  13545. * Smart array of input and output textures for the post process.
  13546. * @hidden
  13547. */
  13548. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13549. /**
  13550. * The index in _textures that corresponds to the output texture.
  13551. * @hidden
  13552. */
  13553. _currentRenderTextureInd: number;
  13554. private _effect;
  13555. private _samplers;
  13556. private _fragmentUrl;
  13557. private _vertexUrl;
  13558. private _parameters;
  13559. private _scaleRatio;
  13560. protected _indexParameters: any;
  13561. private _shareOutputWithPostProcess;
  13562. private _texelSize;
  13563. private _forcedOutputTexture;
  13564. /**
  13565. * Returns the fragment url or shader name used in the post process.
  13566. * @returns the fragment url or name in the shader store.
  13567. */
  13568. getEffectName(): string;
  13569. /**
  13570. * An event triggered when the postprocess is activated.
  13571. */
  13572. onActivateObservable: Observable<Camera>;
  13573. private _onActivateObserver;
  13574. /**
  13575. * A function that is added to the onActivateObservable
  13576. */
  13577. onActivate: Nullable<(camera: Camera) => void>;
  13578. /**
  13579. * An event triggered when the postprocess changes its size.
  13580. */
  13581. onSizeChangedObservable: Observable<PostProcess>;
  13582. private _onSizeChangedObserver;
  13583. /**
  13584. * A function that is added to the onSizeChangedObservable
  13585. */
  13586. onSizeChanged: (postProcess: PostProcess) => void;
  13587. /**
  13588. * An event triggered when the postprocess applies its effect.
  13589. */
  13590. onApplyObservable: Observable<Effect>;
  13591. private _onApplyObserver;
  13592. /**
  13593. * A function that is added to the onApplyObservable
  13594. */
  13595. onApply: (effect: Effect) => void;
  13596. /**
  13597. * An event triggered before rendering the postprocess
  13598. */
  13599. onBeforeRenderObservable: Observable<Effect>;
  13600. private _onBeforeRenderObserver;
  13601. /**
  13602. * A function that is added to the onBeforeRenderObservable
  13603. */
  13604. onBeforeRender: (effect: Effect) => void;
  13605. /**
  13606. * An event triggered after rendering the postprocess
  13607. */
  13608. onAfterRenderObservable: Observable<Effect>;
  13609. private _onAfterRenderObserver;
  13610. /**
  13611. * A function that is added to the onAfterRenderObservable
  13612. */
  13613. onAfterRender: (efect: Effect) => void;
  13614. /**
  13615. * 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
  13616. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13617. */
  13618. inputTexture: InternalTexture;
  13619. /**
  13620. * Gets the camera which post process is applied to.
  13621. * @returns The camera the post process is applied to.
  13622. */
  13623. getCamera(): Camera;
  13624. /**
  13625. * Gets the texel size of the postprocess.
  13626. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13627. */
  13628. readonly texelSize: Vector2;
  13629. /**
  13630. * Creates a new instance PostProcess
  13631. * @param name The name of the PostProcess.
  13632. * @param fragmentUrl The url of the fragment shader to be used.
  13633. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13634. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13635. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13636. * @param camera The camera to apply the render pass to.
  13637. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13638. * @param engine The engine which the post process will be applied. (default: current engine)
  13639. * @param reusable If the post process can be reused on the same frame. (default: false)
  13640. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13641. * @param textureType Type of textures used when performing the post process. (default: 0)
  13642. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13643. * @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
  13644. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13645. */
  13646. constructor(
  13647. /** Name of the PostProcess. */
  13648. 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);
  13649. /**
  13650. * Gets a string idenfifying the name of the class
  13651. * @returns "PostProcess" string
  13652. */
  13653. getClassName(): string;
  13654. /**
  13655. * Gets the engine which this post process belongs to.
  13656. * @returns The engine the post process was enabled with.
  13657. */
  13658. getEngine(): Engine;
  13659. /**
  13660. * The effect that is created when initializing the post process.
  13661. * @returns The created effect corrisponding the the postprocess.
  13662. */
  13663. getEffect(): Effect;
  13664. /**
  13665. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13666. * @param postProcess The post process to share the output with.
  13667. * @returns This post process.
  13668. */
  13669. shareOutputWith(postProcess: PostProcess): PostProcess;
  13670. /**
  13671. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13672. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13673. */
  13674. useOwnOutput(): void;
  13675. /**
  13676. * Updates the effect with the current post process compile time values and recompiles the shader.
  13677. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13678. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13679. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13680. * @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
  13681. * @param onCompiled Called when the shader has been compiled.
  13682. * @param onError Called if there is an error when compiling a shader.
  13683. */
  13684. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13685. /**
  13686. * The post process is reusable if it can be used multiple times within one frame.
  13687. * @returns If the post process is reusable
  13688. */
  13689. isReusable(): boolean;
  13690. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13691. markTextureDirty(): void;
  13692. /**
  13693. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13694. * 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.
  13695. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13696. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13697. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13698. * @returns The target texture that was bound to be written to.
  13699. */
  13700. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13701. /**
  13702. * If the post process is supported.
  13703. */
  13704. readonly isSupported: boolean;
  13705. /**
  13706. * The aspect ratio of the output texture.
  13707. */
  13708. readonly aspectRatio: number;
  13709. /**
  13710. * Get a value indicating if the post-process is ready to be used
  13711. * @returns true if the post-process is ready (shader is compiled)
  13712. */
  13713. isReady(): boolean;
  13714. /**
  13715. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13716. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13717. */
  13718. apply(): Nullable<Effect>;
  13719. private _disposeTextures;
  13720. /**
  13721. * Disposes the post process.
  13722. * @param camera The camera to dispose the post process on.
  13723. */
  13724. dispose(camera?: Camera): void;
  13725. }
  13726. }
  13727. declare module "babylonjs/PostProcesses/postProcessManager" {
  13728. import { Nullable } from "babylonjs/types";
  13729. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13730. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13731. import { Scene } from "babylonjs/scene";
  13732. /**
  13733. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13734. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13735. */
  13736. export class PostProcessManager {
  13737. private _scene;
  13738. private _indexBuffer;
  13739. private _vertexBuffers;
  13740. /**
  13741. * Creates a new instance PostProcess
  13742. * @param scene The scene that the post process is associated with.
  13743. */
  13744. constructor(scene: Scene);
  13745. private _prepareBuffers;
  13746. private _buildIndexBuffer;
  13747. /**
  13748. * Rebuilds the vertex buffers of the manager.
  13749. * @hidden
  13750. */
  13751. _rebuild(): void;
  13752. /**
  13753. * Prepares a frame to be run through a post process.
  13754. * @param sourceTexture The input texture to the post procesess. (default: null)
  13755. * @param postProcesses An array of post processes to be run. (default: null)
  13756. * @returns True if the post processes were able to be run.
  13757. * @hidden
  13758. */
  13759. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13760. /**
  13761. * Manually render a set of post processes to a texture.
  13762. * @param postProcesses An array of post processes to be run.
  13763. * @param targetTexture The target texture to render to.
  13764. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13765. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13766. * @param lodLevel defines which lod of the texture to render to
  13767. */
  13768. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13769. /**
  13770. * Finalize the result of the output of the postprocesses.
  13771. * @param doNotPresent If true the result will not be displayed to the screen.
  13772. * @param targetTexture The target texture to render to.
  13773. * @param faceIndex The index of the face to bind the target texture to.
  13774. * @param postProcesses The array of post processes to render.
  13775. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13776. * @hidden
  13777. */
  13778. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13779. /**
  13780. * Disposes of the post process manager.
  13781. */
  13782. dispose(): void;
  13783. }
  13784. }
  13785. declare module "babylonjs/Layers/layerSceneComponent" {
  13786. import { Scene } from "babylonjs/scene";
  13787. import { ISceneComponent } from "babylonjs/sceneComponent";
  13788. import { Layer } from "babylonjs/Layers/layer";
  13789. module "babylonjs/abstractScene" {
  13790. interface AbstractScene {
  13791. /**
  13792. * The list of layers (background and foreground) of the scene
  13793. */
  13794. layers: Array<Layer>;
  13795. }
  13796. }
  13797. /**
  13798. * Defines the layer scene component responsible to manage any layers
  13799. * in a given scene.
  13800. */
  13801. export class LayerSceneComponent implements ISceneComponent {
  13802. /**
  13803. * The component name helpfull to identify the component in the list of scene components.
  13804. */
  13805. readonly name: string;
  13806. /**
  13807. * The scene the component belongs to.
  13808. */
  13809. scene: Scene;
  13810. private _engine;
  13811. /**
  13812. * Creates a new instance of the component for the given scene
  13813. * @param scene Defines the scene to register the component in
  13814. */
  13815. constructor(scene: Scene);
  13816. /**
  13817. * Registers the component in a given scene
  13818. */
  13819. register(): void;
  13820. /**
  13821. * Rebuilds the elements related to this component in case of
  13822. * context lost for instance.
  13823. */
  13824. rebuild(): void;
  13825. /**
  13826. * Disposes the component and the associated ressources.
  13827. */
  13828. dispose(): void;
  13829. private _draw;
  13830. private _drawCameraPredicate;
  13831. private _drawCameraBackground;
  13832. private _drawCameraForeground;
  13833. private _drawRenderTargetPredicate;
  13834. private _drawRenderTargetBackground;
  13835. private _drawRenderTargetForeground;
  13836. }
  13837. }
  13838. declare module "babylonjs/Shaders/layer.fragment" {
  13839. /** @hidden */
  13840. export var layerPixelShader: {
  13841. name: string;
  13842. shader: string;
  13843. };
  13844. }
  13845. declare module "babylonjs/Shaders/layer.vertex" {
  13846. /** @hidden */
  13847. export var layerVertexShader: {
  13848. name: string;
  13849. shader: string;
  13850. };
  13851. }
  13852. declare module "babylonjs/Layers/layer" {
  13853. import { Observable } from "babylonjs/Misc/observable";
  13854. import { Nullable } from "babylonjs/types";
  13855. import { Scene } from "babylonjs/scene";
  13856. import { Vector2, Color4 } from "babylonjs/Maths/math";
  13857. import { Texture } from "babylonjs/Materials/Textures/texture";
  13858. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13859. import "babylonjs/Shaders/layer.fragment";
  13860. import "babylonjs/Shaders/layer.vertex";
  13861. /**
  13862. * This represents a full screen 2d layer.
  13863. * This can be useful to display a picture in the background of your scene for instance.
  13864. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13865. */
  13866. export class Layer {
  13867. /**
  13868. * Define the name of the layer.
  13869. */
  13870. name: string;
  13871. /**
  13872. * Define the texture the layer should display.
  13873. */
  13874. texture: Nullable<Texture>;
  13875. /**
  13876. * Is the layer in background or foreground.
  13877. */
  13878. isBackground: boolean;
  13879. /**
  13880. * Define the color of the layer (instead of texture).
  13881. */
  13882. color: Color4;
  13883. /**
  13884. * Define the scale of the layer in order to zoom in out of the texture.
  13885. */
  13886. scale: Vector2;
  13887. /**
  13888. * Define an offset for the layer in order to shift the texture.
  13889. */
  13890. offset: Vector2;
  13891. /**
  13892. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13893. */
  13894. alphaBlendingMode: number;
  13895. /**
  13896. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13897. * Alpha test will not mix with the background color in case of transparency.
  13898. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13899. */
  13900. alphaTest: boolean;
  13901. /**
  13902. * Define a mask to restrict the layer to only some of the scene cameras.
  13903. */
  13904. layerMask: number;
  13905. /**
  13906. * Define the list of render target the layer is visible into.
  13907. */
  13908. renderTargetTextures: RenderTargetTexture[];
  13909. /**
  13910. * Define if the layer is only used in renderTarget or if it also
  13911. * renders in the main frame buffer of the canvas.
  13912. */
  13913. renderOnlyInRenderTargetTextures: boolean;
  13914. private _scene;
  13915. private _vertexBuffers;
  13916. private _indexBuffer;
  13917. private _effect;
  13918. private _alphaTestEffect;
  13919. /**
  13920. * An event triggered when the layer is disposed.
  13921. */
  13922. onDisposeObservable: Observable<Layer>;
  13923. private _onDisposeObserver;
  13924. /**
  13925. * Back compatibility with callback before the onDisposeObservable existed.
  13926. * The set callback will be triggered when the layer has been disposed.
  13927. */
  13928. onDispose: () => void;
  13929. /**
  13930. * An event triggered before rendering the scene
  13931. */
  13932. onBeforeRenderObservable: Observable<Layer>;
  13933. private _onBeforeRenderObserver;
  13934. /**
  13935. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13936. * The set callback will be triggered just before rendering the layer.
  13937. */
  13938. onBeforeRender: () => void;
  13939. /**
  13940. * An event triggered after rendering the scene
  13941. */
  13942. onAfterRenderObservable: Observable<Layer>;
  13943. private _onAfterRenderObserver;
  13944. /**
  13945. * Back compatibility with callback before the onAfterRenderObservable existed.
  13946. * The set callback will be triggered just after rendering the layer.
  13947. */
  13948. onAfterRender: () => void;
  13949. /**
  13950. * Instantiates a new layer.
  13951. * This represents a full screen 2d layer.
  13952. * This can be useful to display a picture in the background of your scene for instance.
  13953. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13954. * @param name Define the name of the layer in the scene
  13955. * @param imgUrl Define the url of the texture to display in the layer
  13956. * @param scene Define the scene the layer belongs to
  13957. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13958. * @param color Defines a color for the layer
  13959. */
  13960. constructor(
  13961. /**
  13962. * Define the name of the layer.
  13963. */
  13964. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13965. private _createIndexBuffer;
  13966. /** @hidden */
  13967. _rebuild(): void;
  13968. /**
  13969. * Renders the layer in the scene.
  13970. */
  13971. render(): void;
  13972. /**
  13973. * Disposes and releases the associated ressources.
  13974. */
  13975. dispose(): void;
  13976. }
  13977. }
  13978. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  13979. import { Scene } from "babylonjs/scene";
  13980. import { ISceneComponent } from "babylonjs/sceneComponent";
  13981. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  13982. module "babylonjs/abstractScene" {
  13983. interface AbstractScene {
  13984. /**
  13985. * The list of procedural textures added to the scene
  13986. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13987. */
  13988. proceduralTextures: Array<ProceduralTexture>;
  13989. }
  13990. }
  13991. /**
  13992. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13993. * in a given scene.
  13994. */
  13995. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13996. /**
  13997. * The component name helpfull to identify the component in the list of scene components.
  13998. */
  13999. readonly name: string;
  14000. /**
  14001. * The scene the component belongs to.
  14002. */
  14003. scene: Scene;
  14004. /**
  14005. * Creates a new instance of the component for the given scene
  14006. * @param scene Defines the scene to register the component in
  14007. */
  14008. constructor(scene: Scene);
  14009. /**
  14010. * Registers the component in a given scene
  14011. */
  14012. register(): void;
  14013. /**
  14014. * Rebuilds the elements related to this component in case of
  14015. * context lost for instance.
  14016. */
  14017. rebuild(): void;
  14018. /**
  14019. * Disposes the component and the associated ressources.
  14020. */
  14021. dispose(): void;
  14022. private _beforeClear;
  14023. }
  14024. }
  14025. declare module "babylonjs/Shaders/procedural.vertex" {
  14026. /** @hidden */
  14027. export var proceduralVertexShader: {
  14028. name: string;
  14029. shader: string;
  14030. };
  14031. }
  14032. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  14033. import { Observable } from "babylonjs/Misc/observable";
  14034. import { Nullable } from "babylonjs/types";
  14035. import { Scene } from "babylonjs/scene";
  14036. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  14037. import { Effect } from "babylonjs/Materials/effect";
  14038. import { Texture } from "babylonjs/Materials/Textures/texture";
  14039. import "babylonjs/Shaders/procedural.vertex";
  14040. /**
  14041. * 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.
  14042. * This is the base class of any Procedural texture and contains most of the shareable code.
  14043. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14044. */
  14045. export class ProceduralTexture extends Texture {
  14046. isCube: boolean;
  14047. /**
  14048. * Define if the texture is enabled or not (disabled texture will not render)
  14049. */
  14050. isEnabled: boolean;
  14051. /**
  14052. * Define if the texture must be cleared before rendering (default is true)
  14053. */
  14054. autoClear: boolean;
  14055. /**
  14056. * Callback called when the texture is generated
  14057. */
  14058. onGenerated: () => void;
  14059. /**
  14060. * Event raised when the texture is generated
  14061. */
  14062. onGeneratedObservable: Observable<ProceduralTexture>;
  14063. /** @hidden */
  14064. _generateMipMaps: boolean;
  14065. /** @hidden **/
  14066. _effect: Effect;
  14067. /** @hidden */
  14068. _textures: {
  14069. [key: string]: Texture;
  14070. };
  14071. private _size;
  14072. private _currentRefreshId;
  14073. private _refreshRate;
  14074. private _vertexBuffers;
  14075. private _indexBuffer;
  14076. private _uniforms;
  14077. private _samplers;
  14078. private _fragment;
  14079. private _floats;
  14080. private _ints;
  14081. private _floatsArrays;
  14082. private _colors3;
  14083. private _colors4;
  14084. private _vectors2;
  14085. private _vectors3;
  14086. private _matrices;
  14087. private _fallbackTexture;
  14088. private _fallbackTextureUsed;
  14089. private _engine;
  14090. private _cachedDefines;
  14091. private _contentUpdateId;
  14092. private _contentData;
  14093. /**
  14094. * Instantiates a new procedural texture.
  14095. * 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.
  14096. * This is the base class of any Procedural texture and contains most of the shareable code.
  14097. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14098. * @param name Define the name of the texture
  14099. * @param size Define the size of the texture to create
  14100. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14101. * @param scene Define the scene the texture belongs to
  14102. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14103. * @param generateMipMaps Define if the texture should creates mip maps or not
  14104. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14105. */
  14106. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14107. /**
  14108. * The effect that is created when initializing the post process.
  14109. * @returns The created effect corrisponding the the postprocess.
  14110. */
  14111. getEffect(): Effect;
  14112. /**
  14113. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14114. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14115. */
  14116. getContent(): Nullable<ArrayBufferView>;
  14117. private _createIndexBuffer;
  14118. /** @hidden */
  14119. _rebuild(): void;
  14120. /**
  14121. * Resets the texture in order to recreate its associated resources.
  14122. * This can be called in case of context loss
  14123. */
  14124. reset(): void;
  14125. protected _getDefines(): string;
  14126. /**
  14127. * Is the texture ready to be used ? (rendered at least once)
  14128. * @returns true if ready, otherwise, false.
  14129. */
  14130. isReady(): boolean;
  14131. /**
  14132. * Resets the refresh counter of the texture and start bak from scratch.
  14133. * Could be useful to regenerate the texture if it is setup to render only once.
  14134. */
  14135. resetRefreshCounter(): void;
  14136. /**
  14137. * Set the fragment shader to use in order to render the texture.
  14138. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14139. */
  14140. setFragment(fragment: any): void;
  14141. /**
  14142. * Define the refresh rate of the texture or the rendering frequency.
  14143. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14144. */
  14145. refreshRate: number;
  14146. /** @hidden */
  14147. _shouldRender(): boolean;
  14148. /**
  14149. * Get the size the texture is rendering at.
  14150. * @returns the size (texture is always squared)
  14151. */
  14152. getRenderSize(): number;
  14153. /**
  14154. * Resize the texture to new value.
  14155. * @param size Define the new size the texture should have
  14156. * @param generateMipMaps Define whether the new texture should create mip maps
  14157. */
  14158. resize(size: number, generateMipMaps: boolean): void;
  14159. private _checkUniform;
  14160. /**
  14161. * Set a texture in the shader program used to render.
  14162. * @param name Define the name of the uniform samplers as defined in the shader
  14163. * @param texture Define the texture to bind to this sampler
  14164. * @return the texture itself allowing "fluent" like uniform updates
  14165. */
  14166. setTexture(name: string, texture: Texture): ProceduralTexture;
  14167. /**
  14168. * Set a float in the shader.
  14169. * @param name Define the name of the uniform as defined in the shader
  14170. * @param value Define the value to give to the uniform
  14171. * @return the texture itself allowing "fluent" like uniform updates
  14172. */
  14173. setFloat(name: string, value: number): ProceduralTexture;
  14174. /**
  14175. * Set a int in the shader.
  14176. * @param name Define the name of the uniform as defined in the shader
  14177. * @param value Define the value to give to the uniform
  14178. * @return the texture itself allowing "fluent" like uniform updates
  14179. */
  14180. setInt(name: string, value: number): ProceduralTexture;
  14181. /**
  14182. * Set an array of floats in the shader.
  14183. * @param name Define the name of the uniform as defined in the shader
  14184. * @param value Define the value to give to the uniform
  14185. * @return the texture itself allowing "fluent" like uniform updates
  14186. */
  14187. setFloats(name: string, value: number[]): ProceduralTexture;
  14188. /**
  14189. * Set a vec3 in the shader from a Color3.
  14190. * @param name Define the name of the uniform as defined in the shader
  14191. * @param value Define the value to give to the uniform
  14192. * @return the texture itself allowing "fluent" like uniform updates
  14193. */
  14194. setColor3(name: string, value: Color3): ProceduralTexture;
  14195. /**
  14196. * Set a vec4 in the shader from a Color4.
  14197. * @param name Define the name of the uniform as defined in the shader
  14198. * @param value Define the value to give to the uniform
  14199. * @return the texture itself allowing "fluent" like uniform updates
  14200. */
  14201. setColor4(name: string, value: Color4): ProceduralTexture;
  14202. /**
  14203. * Set a vec2 in the shader from a Vector2.
  14204. * @param name Define the name of the uniform as defined in the shader
  14205. * @param value Define the value to give to the uniform
  14206. * @return the texture itself allowing "fluent" like uniform updates
  14207. */
  14208. setVector2(name: string, value: Vector2): ProceduralTexture;
  14209. /**
  14210. * Set a vec3 in the shader from a Vector3.
  14211. * @param name Define the name of the uniform as defined in the shader
  14212. * @param value Define the value to give to the uniform
  14213. * @return the texture itself allowing "fluent" like uniform updates
  14214. */
  14215. setVector3(name: string, value: Vector3): ProceduralTexture;
  14216. /**
  14217. * Set a mat4 in the shader from a MAtrix.
  14218. * @param name Define the name of the uniform as defined in the shader
  14219. * @param value Define the value to give to the uniform
  14220. * @return the texture itself allowing "fluent" like uniform updates
  14221. */
  14222. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14223. /**
  14224. * Render the texture to its associated render target.
  14225. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14226. */
  14227. render(useCameraPostProcess?: boolean): void;
  14228. /**
  14229. * Clone the texture.
  14230. * @returns the cloned texture
  14231. */
  14232. clone(): ProceduralTexture;
  14233. /**
  14234. * Dispose the texture and release its asoociated resources.
  14235. */
  14236. dispose(): void;
  14237. }
  14238. }
  14239. declare module "babylonjs/Particles/baseParticleSystem" {
  14240. import { Nullable } from "babylonjs/types";
  14241. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14242. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14243. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14244. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14245. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14246. import { Scene } from "babylonjs/scene";
  14247. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14248. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14249. import { Texture } from "babylonjs/Materials/Textures/texture";
  14250. import { Animation } from "babylonjs/Animations/animation";
  14251. /**
  14252. * This represents the base class for particle system in Babylon.
  14253. * 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.
  14254. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14255. * @example https://doc.babylonjs.com/babylon101/particles
  14256. */
  14257. export class BaseParticleSystem {
  14258. /**
  14259. * Source color is added to the destination color without alpha affecting the result
  14260. */
  14261. static BLENDMODE_ONEONE: number;
  14262. /**
  14263. * Blend current color and particle color using particle’s alpha
  14264. */
  14265. static BLENDMODE_STANDARD: number;
  14266. /**
  14267. * Add current color and particle color multiplied by particle’s alpha
  14268. */
  14269. static BLENDMODE_ADD: number;
  14270. /**
  14271. * Multiply current color with particle color
  14272. */
  14273. static BLENDMODE_MULTIPLY: number;
  14274. /**
  14275. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14276. */
  14277. static BLENDMODE_MULTIPLYADD: number;
  14278. /**
  14279. * List of animations used by the particle system.
  14280. */
  14281. animations: Animation[];
  14282. /**
  14283. * The id of the Particle system.
  14284. */
  14285. id: string;
  14286. /**
  14287. * The friendly name of the Particle system.
  14288. */
  14289. name: string;
  14290. /**
  14291. * The rendering group used by the Particle system to chose when to render.
  14292. */
  14293. renderingGroupId: number;
  14294. /**
  14295. * The emitter represents the Mesh or position we are attaching the particle system to.
  14296. */
  14297. emitter: Nullable<AbstractMesh | Vector3>;
  14298. /**
  14299. * The maximum number of particles to emit per frame
  14300. */
  14301. emitRate: number;
  14302. /**
  14303. * If you want to launch only a few particles at once, that can be done, as well.
  14304. */
  14305. manualEmitCount: number;
  14306. /**
  14307. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14308. */
  14309. updateSpeed: number;
  14310. /**
  14311. * The amount of time the particle system is running (depends of the overall update speed).
  14312. */
  14313. targetStopDuration: number;
  14314. /**
  14315. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14316. */
  14317. disposeOnStop: boolean;
  14318. /**
  14319. * Minimum power of emitting particles.
  14320. */
  14321. minEmitPower: number;
  14322. /**
  14323. * Maximum power of emitting particles.
  14324. */
  14325. maxEmitPower: number;
  14326. /**
  14327. * Minimum life time of emitting particles.
  14328. */
  14329. minLifeTime: number;
  14330. /**
  14331. * Maximum life time of emitting particles.
  14332. */
  14333. maxLifeTime: number;
  14334. /**
  14335. * Minimum Size of emitting particles.
  14336. */
  14337. minSize: number;
  14338. /**
  14339. * Maximum Size of emitting particles.
  14340. */
  14341. maxSize: number;
  14342. /**
  14343. * Minimum scale of emitting particles on X axis.
  14344. */
  14345. minScaleX: number;
  14346. /**
  14347. * Maximum scale of emitting particles on X axis.
  14348. */
  14349. maxScaleX: number;
  14350. /**
  14351. * Minimum scale of emitting particles on Y axis.
  14352. */
  14353. minScaleY: number;
  14354. /**
  14355. * Maximum scale of emitting particles on Y axis.
  14356. */
  14357. maxScaleY: number;
  14358. /**
  14359. * Gets or sets the minimal initial rotation in radians.
  14360. */
  14361. minInitialRotation: number;
  14362. /**
  14363. * Gets or sets the maximal initial rotation in radians.
  14364. */
  14365. maxInitialRotation: number;
  14366. /**
  14367. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14368. */
  14369. minAngularSpeed: number;
  14370. /**
  14371. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14372. */
  14373. maxAngularSpeed: number;
  14374. /**
  14375. * The texture used to render each particle. (this can be a spritesheet)
  14376. */
  14377. particleTexture: Nullable<Texture>;
  14378. /**
  14379. * The layer mask we are rendering the particles through.
  14380. */
  14381. layerMask: number;
  14382. /**
  14383. * This can help using your own shader to render the particle system.
  14384. * The according effect will be created
  14385. */
  14386. customShader: any;
  14387. /**
  14388. * By default particle system starts as soon as they are created. This prevents the
  14389. * automatic start to happen and let you decide when to start emitting particles.
  14390. */
  14391. preventAutoStart: boolean;
  14392. private _noiseTexture;
  14393. /**
  14394. * Gets or sets a texture used to add random noise to particle positions
  14395. */
  14396. noiseTexture: Nullable<ProceduralTexture>;
  14397. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14398. noiseStrength: Vector3;
  14399. /**
  14400. * Callback triggered when the particle animation is ending.
  14401. */
  14402. onAnimationEnd: Nullable<() => void>;
  14403. /**
  14404. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14405. */
  14406. blendMode: number;
  14407. /**
  14408. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14409. * to override the particles.
  14410. */
  14411. forceDepthWrite: boolean;
  14412. /** 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 */
  14413. preWarmCycles: number;
  14414. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14415. preWarmStepOffset: number;
  14416. /**
  14417. * 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)
  14418. */
  14419. spriteCellChangeSpeed: number;
  14420. /**
  14421. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14422. */
  14423. startSpriteCellID: number;
  14424. /**
  14425. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14426. */
  14427. endSpriteCellID: number;
  14428. /**
  14429. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14430. */
  14431. spriteCellWidth: number;
  14432. /**
  14433. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14434. */
  14435. spriteCellHeight: number;
  14436. /**
  14437. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14438. */
  14439. spriteRandomStartCell: boolean;
  14440. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14441. translationPivot: Vector2;
  14442. /** @hidden */
  14443. protected _isAnimationSheetEnabled: boolean;
  14444. /**
  14445. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14446. */
  14447. beginAnimationOnStart: boolean;
  14448. /**
  14449. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14450. */
  14451. beginAnimationFrom: number;
  14452. /**
  14453. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14454. */
  14455. beginAnimationTo: number;
  14456. /**
  14457. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14458. */
  14459. beginAnimationLoop: boolean;
  14460. /**
  14461. * Gets or sets a world offset applied to all particles
  14462. */
  14463. worldOffset: Vector3;
  14464. /**
  14465. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14466. */
  14467. isAnimationSheetEnabled: boolean;
  14468. /**
  14469. * Get hosting scene
  14470. * @returns the scene
  14471. */
  14472. getScene(): Scene;
  14473. /**
  14474. * You can use gravity if you want to give an orientation to your particles.
  14475. */
  14476. gravity: Vector3;
  14477. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14478. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14479. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14480. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14481. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14482. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14483. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14484. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14485. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14486. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14487. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14488. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14489. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14490. /**
  14491. * Defines the delay in milliseconds before starting the system (0 by default)
  14492. */
  14493. startDelay: number;
  14494. /**
  14495. * Gets the current list of drag gradients.
  14496. * You must use addDragGradient and removeDragGradient to udpate this list
  14497. * @returns the list of drag gradients
  14498. */
  14499. getDragGradients(): Nullable<Array<FactorGradient>>;
  14500. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14501. limitVelocityDamping: number;
  14502. /**
  14503. * Gets the current list of limit velocity gradients.
  14504. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14505. * @returns the list of limit velocity gradients
  14506. */
  14507. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14508. /**
  14509. * Gets the current list of color gradients.
  14510. * You must use addColorGradient and removeColorGradient to udpate this list
  14511. * @returns the list of color gradients
  14512. */
  14513. getColorGradients(): Nullable<Array<ColorGradient>>;
  14514. /**
  14515. * Gets the current list of size gradients.
  14516. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14517. * @returns the list of size gradients
  14518. */
  14519. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14520. /**
  14521. * Gets the current list of color remap gradients.
  14522. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14523. * @returns the list of color remap gradients
  14524. */
  14525. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14526. /**
  14527. * Gets the current list of alpha remap gradients.
  14528. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14529. * @returns the list of alpha remap gradients
  14530. */
  14531. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14532. /**
  14533. * Gets the current list of life time gradients.
  14534. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14535. * @returns the list of life time gradients
  14536. */
  14537. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14538. /**
  14539. * Gets the current list of angular speed gradients.
  14540. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14541. * @returns the list of angular speed gradients
  14542. */
  14543. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14544. /**
  14545. * Gets the current list of velocity gradients.
  14546. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14547. * @returns the list of velocity gradients
  14548. */
  14549. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14550. /**
  14551. * Gets the current list of start size gradients.
  14552. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14553. * @returns the list of start size gradients
  14554. */
  14555. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14556. /**
  14557. * Gets the current list of emit rate gradients.
  14558. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14559. * @returns the list of emit rate gradients
  14560. */
  14561. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14562. /**
  14563. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14564. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14565. */
  14566. direction1: Vector3;
  14567. /**
  14568. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14569. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14570. */
  14571. direction2: Vector3;
  14572. /**
  14573. * 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.
  14574. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14575. */
  14576. minEmitBox: Vector3;
  14577. /**
  14578. * 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.
  14579. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14580. */
  14581. maxEmitBox: Vector3;
  14582. /**
  14583. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14584. */
  14585. color1: Color4;
  14586. /**
  14587. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14588. */
  14589. color2: Color4;
  14590. /**
  14591. * Color the particle will have at the end of its lifetime
  14592. */
  14593. colorDead: Color4;
  14594. /**
  14595. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14596. */
  14597. textureMask: Color4;
  14598. /**
  14599. * The particle emitter type defines the emitter used by the particle system.
  14600. * It can be for example box, sphere, or cone...
  14601. */
  14602. particleEmitterType: IParticleEmitterType;
  14603. /** @hidden */
  14604. _isSubEmitter: boolean;
  14605. /**
  14606. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14607. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14608. */
  14609. billboardMode: number;
  14610. protected _isBillboardBased: boolean;
  14611. /**
  14612. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14613. */
  14614. isBillboardBased: boolean;
  14615. /**
  14616. * The scene the particle system belongs to.
  14617. */
  14618. protected _scene: Scene;
  14619. /**
  14620. * Local cache of defines for image processing.
  14621. */
  14622. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14623. /**
  14624. * Default configuration related to image processing available in the standard Material.
  14625. */
  14626. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14627. /**
  14628. * Gets the image processing configuration used either in this material.
  14629. */
  14630. /**
  14631. * Sets the Default image processing configuration used either in the this material.
  14632. *
  14633. * If sets to null, the scene one is in use.
  14634. */
  14635. imageProcessingConfiguration: ImageProcessingConfiguration;
  14636. /**
  14637. * Attaches a new image processing configuration to the Standard Material.
  14638. * @param configuration
  14639. */
  14640. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14641. /** @hidden */
  14642. protected _reset(): void;
  14643. /** @hidden */
  14644. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14645. /**
  14646. * Instantiates a particle system.
  14647. * 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.
  14648. * @param name The name of the particle system
  14649. */
  14650. constructor(name: string);
  14651. /**
  14652. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14653. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14654. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14655. * @returns the emitter
  14656. */
  14657. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14658. /**
  14659. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14660. * @param radius The radius of the hemisphere to emit from
  14661. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14662. * @returns the emitter
  14663. */
  14664. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14665. /**
  14666. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14667. * @param radius The radius of the sphere to emit from
  14668. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14669. * @returns the emitter
  14670. */
  14671. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14672. /**
  14673. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14674. * @param radius The radius of the sphere to emit from
  14675. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14676. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14677. * @returns the emitter
  14678. */
  14679. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14680. /**
  14681. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14682. * @param radius The radius of the emission cylinder
  14683. * @param height The height of the emission cylinder
  14684. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14685. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14686. * @returns the emitter
  14687. */
  14688. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14689. /**
  14690. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14691. * @param radius The radius of the cylinder to emit from
  14692. * @param height The height of the emission cylinder
  14693. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14694. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14695. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14696. * @returns the emitter
  14697. */
  14698. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14699. /**
  14700. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14701. * @param radius The radius of the cone to emit from
  14702. * @param angle The base angle of the cone
  14703. * @returns the emitter
  14704. */
  14705. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14706. /**
  14707. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14708. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14709. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14710. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14711. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14712. * @returns the emitter
  14713. */
  14714. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14715. }
  14716. }
  14717. declare module "babylonjs/Particles/subEmitter" {
  14718. import { Scene } from "babylonjs/scene";
  14719. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  14720. /**
  14721. * Type of sub emitter
  14722. */
  14723. export enum SubEmitterType {
  14724. /**
  14725. * Attached to the particle over it's lifetime
  14726. */
  14727. ATTACHED = 0,
  14728. /**
  14729. * Created when the particle dies
  14730. */
  14731. END = 1
  14732. }
  14733. /**
  14734. * Sub emitter class used to emit particles from an existing particle
  14735. */
  14736. export class SubEmitter {
  14737. /**
  14738. * the particle system to be used by the sub emitter
  14739. */
  14740. particleSystem: ParticleSystem;
  14741. /**
  14742. * Type of the submitter (Default: END)
  14743. */
  14744. type: SubEmitterType;
  14745. /**
  14746. * 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)
  14747. * Note: This only is supported when using an emitter of type Mesh
  14748. */
  14749. inheritDirection: boolean;
  14750. /**
  14751. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14752. */
  14753. inheritedVelocityAmount: number;
  14754. /**
  14755. * Creates a sub emitter
  14756. * @param particleSystem the particle system to be used by the sub emitter
  14757. */
  14758. constructor(
  14759. /**
  14760. * the particle system to be used by the sub emitter
  14761. */
  14762. particleSystem: ParticleSystem);
  14763. /**
  14764. * Clones the sub emitter
  14765. * @returns the cloned sub emitter
  14766. */
  14767. clone(): SubEmitter;
  14768. /**
  14769. * Serialize current object to a JSON object
  14770. * @returns the serialized object
  14771. */
  14772. serialize(): any;
  14773. /** @hidden */
  14774. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14775. /**
  14776. * Creates a new SubEmitter from a serialized JSON version
  14777. * @param serializationObject defines the JSON object to read from
  14778. * @param scene defines the hosting scene
  14779. * @param rootUrl defines the rootUrl for data loading
  14780. * @returns a new SubEmitter
  14781. */
  14782. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14783. /** Release associated resources */
  14784. dispose(): void;
  14785. }
  14786. }
  14787. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  14788. /** @hidden */
  14789. export var clipPlaneFragmentDeclaration: {
  14790. name: string;
  14791. shader: string;
  14792. };
  14793. }
  14794. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  14795. /** @hidden */
  14796. export var imageProcessingDeclaration: {
  14797. name: string;
  14798. shader: string;
  14799. };
  14800. }
  14801. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  14802. /** @hidden */
  14803. export var imageProcessingFunctions: {
  14804. name: string;
  14805. shader: string;
  14806. };
  14807. }
  14808. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  14809. /** @hidden */
  14810. export var clipPlaneFragment: {
  14811. name: string;
  14812. shader: string;
  14813. };
  14814. }
  14815. declare module "babylonjs/Shaders/particles.fragment" {
  14816. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  14817. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  14818. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  14819. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  14820. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  14821. /** @hidden */
  14822. export var particlesPixelShader: {
  14823. name: string;
  14824. shader: string;
  14825. };
  14826. }
  14827. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  14828. /** @hidden */
  14829. export var clipPlaneVertexDeclaration: {
  14830. name: string;
  14831. shader: string;
  14832. };
  14833. }
  14834. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  14835. /** @hidden */
  14836. export var clipPlaneVertex: {
  14837. name: string;
  14838. shader: string;
  14839. };
  14840. }
  14841. declare module "babylonjs/Shaders/particles.vertex" {
  14842. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  14843. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  14844. /** @hidden */
  14845. export var particlesVertexShader: {
  14846. name: string;
  14847. shader: string;
  14848. };
  14849. }
  14850. declare module "babylonjs/Particles/particleSystem" {
  14851. import { Nullable } from "babylonjs/types";
  14852. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  14853. import { Observable } from "babylonjs/Misc/observable";
  14854. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  14855. import { Effect } from "babylonjs/Materials/effect";
  14856. import { Scene, IDisposable } from "babylonjs/scene";
  14857. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  14858. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  14859. import { Particle } from "babylonjs/Particles/particle";
  14860. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  14861. import "babylonjs/Shaders/particles.fragment";
  14862. import "babylonjs/Shaders/particles.vertex";
  14863. /**
  14864. * This represents a particle system in Babylon.
  14865. * 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.
  14866. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14867. * @example https://doc.babylonjs.com/babylon101/particles
  14868. */
  14869. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14870. /**
  14871. * Billboard mode will only apply to Y axis
  14872. */
  14873. static readonly BILLBOARDMODE_Y: number;
  14874. /**
  14875. * Billboard mode will apply to all axes
  14876. */
  14877. static readonly BILLBOARDMODE_ALL: number;
  14878. /**
  14879. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14880. */
  14881. static readonly BILLBOARDMODE_STRETCHED: number;
  14882. /**
  14883. * This function can be defined to provide custom update for active particles.
  14884. * This function will be called instead of regular update (age, position, color, etc.).
  14885. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14886. */
  14887. updateFunction: (particles: Particle[]) => void;
  14888. private _emitterWorldMatrix;
  14889. /**
  14890. * This function can be defined to specify initial direction for every new particle.
  14891. * It by default use the emitterType defined function
  14892. */
  14893. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14894. /**
  14895. * This function can be defined to specify initial position for every new particle.
  14896. * It by default use the emitterType defined function
  14897. */
  14898. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14899. /**
  14900. * @hidden
  14901. */
  14902. _inheritedVelocityOffset: Vector3;
  14903. /**
  14904. * An event triggered when the system is disposed
  14905. */
  14906. onDisposeObservable: Observable<ParticleSystem>;
  14907. private _onDisposeObserver;
  14908. /**
  14909. * Sets a callback that will be triggered when the system is disposed
  14910. */
  14911. onDispose: () => void;
  14912. private _particles;
  14913. private _epsilon;
  14914. private _capacity;
  14915. private _stockParticles;
  14916. private _newPartsExcess;
  14917. private _vertexData;
  14918. private _vertexBuffer;
  14919. private _vertexBuffers;
  14920. private _spriteBuffer;
  14921. private _indexBuffer;
  14922. private _effect;
  14923. private _customEffect;
  14924. private _cachedDefines;
  14925. private _scaledColorStep;
  14926. private _colorDiff;
  14927. private _scaledDirection;
  14928. private _scaledGravity;
  14929. private _currentRenderId;
  14930. private _alive;
  14931. private _useInstancing;
  14932. private _started;
  14933. private _stopped;
  14934. private _actualFrame;
  14935. private _scaledUpdateSpeed;
  14936. private _vertexBufferSize;
  14937. /** @hidden */
  14938. _currentEmitRateGradient: Nullable<FactorGradient>;
  14939. /** @hidden */
  14940. _currentEmitRate1: number;
  14941. /** @hidden */
  14942. _currentEmitRate2: number;
  14943. /** @hidden */
  14944. _currentStartSizeGradient: Nullable<FactorGradient>;
  14945. /** @hidden */
  14946. _currentStartSize1: number;
  14947. /** @hidden */
  14948. _currentStartSize2: number;
  14949. private readonly _rawTextureWidth;
  14950. private _rampGradientsTexture;
  14951. private _useRampGradients;
  14952. /** Gets or sets a boolean indicating that ramp gradients must be used
  14953. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14954. */
  14955. useRampGradients: boolean;
  14956. /**
  14957. * 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.
  14958. * 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: [])
  14959. */
  14960. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14961. private _subEmitters;
  14962. /**
  14963. * @hidden
  14964. * If the particle systems emitter should be disposed when the particle system is disposed
  14965. */
  14966. _disposeEmitterOnDispose: boolean;
  14967. /**
  14968. * The current active Sub-systems, this property is used by the root particle system only.
  14969. */
  14970. activeSubSystems: Array<ParticleSystem>;
  14971. private _rootParticleSystem;
  14972. /**
  14973. * Gets the current list of active particles
  14974. */
  14975. readonly particles: Particle[];
  14976. /**
  14977. * Returns the string "ParticleSystem"
  14978. * @returns a string containing the class name
  14979. */
  14980. getClassName(): string;
  14981. /**
  14982. * Instantiates a particle system.
  14983. * 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.
  14984. * @param name The name of the particle system
  14985. * @param capacity The max number of particles alive at the same time
  14986. * @param scene The scene the particle system belongs to
  14987. * @param customEffect a custom effect used to change the way particles are rendered by default
  14988. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14989. * @param epsilon Offset used to render the particles
  14990. */
  14991. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14992. private _addFactorGradient;
  14993. private _removeFactorGradient;
  14994. /**
  14995. * Adds a new life time gradient
  14996. * @param gradient defines the gradient to use (between 0 and 1)
  14997. * @param factor defines the life time factor to affect to the specified gradient
  14998. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14999. * @returns the current particle system
  15000. */
  15001. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15002. /**
  15003. * Remove a specific life time gradient
  15004. * @param gradient defines the gradient to remove
  15005. * @returns the current particle system
  15006. */
  15007. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15008. /**
  15009. * Adds a new size gradient
  15010. * @param gradient defines the gradient to use (between 0 and 1)
  15011. * @param factor defines the size factor to affect to the specified gradient
  15012. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15013. * @returns the current particle system
  15014. */
  15015. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15016. /**
  15017. * Remove a specific size gradient
  15018. * @param gradient defines the gradient to remove
  15019. * @returns the current particle system
  15020. */
  15021. removeSizeGradient(gradient: number): IParticleSystem;
  15022. /**
  15023. * Adds a new color remap gradient
  15024. * @param gradient defines the gradient to use (between 0 and 1)
  15025. * @param min defines the color remap minimal range
  15026. * @param max defines the color remap maximal range
  15027. * @returns the current particle system
  15028. */
  15029. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15030. /**
  15031. * Remove a specific color remap gradient
  15032. * @param gradient defines the gradient to remove
  15033. * @returns the current particle system
  15034. */
  15035. removeColorRemapGradient(gradient: number): IParticleSystem;
  15036. /**
  15037. * Adds a new alpha remap gradient
  15038. * @param gradient defines the gradient to use (between 0 and 1)
  15039. * @param min defines the alpha remap minimal range
  15040. * @param max defines the alpha remap maximal range
  15041. * @returns the current particle system
  15042. */
  15043. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15044. /**
  15045. * Remove a specific alpha remap gradient
  15046. * @param gradient defines the gradient to remove
  15047. * @returns the current particle system
  15048. */
  15049. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15050. /**
  15051. * Adds a new angular speed gradient
  15052. * @param gradient defines the gradient to use (between 0 and 1)
  15053. * @param factor defines the angular speed to affect to the specified gradient
  15054. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15055. * @returns the current particle system
  15056. */
  15057. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15058. /**
  15059. * Remove a specific angular speed gradient
  15060. * @param gradient defines the gradient to remove
  15061. * @returns the current particle system
  15062. */
  15063. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15064. /**
  15065. * Adds a new velocity gradient
  15066. * @param gradient defines the gradient to use (between 0 and 1)
  15067. * @param factor defines the velocity to affect to the specified gradient
  15068. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15069. * @returns the current particle system
  15070. */
  15071. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15072. /**
  15073. * Remove a specific velocity gradient
  15074. * @param gradient defines the gradient to remove
  15075. * @returns the current particle system
  15076. */
  15077. removeVelocityGradient(gradient: number): IParticleSystem;
  15078. /**
  15079. * Adds a new limit velocity gradient
  15080. * @param gradient defines the gradient to use (between 0 and 1)
  15081. * @param factor defines the limit velocity value to affect to the specified gradient
  15082. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15083. * @returns the current particle system
  15084. */
  15085. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15086. /**
  15087. * Remove a specific limit velocity gradient
  15088. * @param gradient defines the gradient to remove
  15089. * @returns the current particle system
  15090. */
  15091. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15092. /**
  15093. * Adds a new drag gradient
  15094. * @param gradient defines the gradient to use (between 0 and 1)
  15095. * @param factor defines the drag value to affect to the specified gradient
  15096. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15097. * @returns the current particle system
  15098. */
  15099. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15100. /**
  15101. * Remove a specific drag gradient
  15102. * @param gradient defines the gradient to remove
  15103. * @returns the current particle system
  15104. */
  15105. removeDragGradient(gradient: number): IParticleSystem;
  15106. /**
  15107. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15108. * @param gradient defines the gradient to use (between 0 and 1)
  15109. * @param factor defines the emit rate value to affect to the specified gradient
  15110. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15111. * @returns the current particle system
  15112. */
  15113. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15114. /**
  15115. * Remove a specific emit rate gradient
  15116. * @param gradient defines the gradient to remove
  15117. * @returns the current particle system
  15118. */
  15119. removeEmitRateGradient(gradient: number): IParticleSystem;
  15120. /**
  15121. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15122. * @param gradient defines the gradient to use (between 0 and 1)
  15123. * @param factor defines the start size value to affect to the specified gradient
  15124. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15125. * @returns the current particle system
  15126. */
  15127. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15128. /**
  15129. * Remove a specific start size gradient
  15130. * @param gradient defines the gradient to remove
  15131. * @returns the current particle system
  15132. */
  15133. removeStartSizeGradient(gradient: number): IParticleSystem;
  15134. private _createRampGradientTexture;
  15135. /**
  15136. * Gets the current list of ramp gradients.
  15137. * You must use addRampGradient and removeRampGradient to udpate this list
  15138. * @returns the list of ramp gradients
  15139. */
  15140. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15141. /**
  15142. * Adds a new ramp gradient used to remap particle colors
  15143. * @param gradient defines the gradient to use (between 0 and 1)
  15144. * @param color defines the color to affect to the specified gradient
  15145. * @returns the current particle system
  15146. */
  15147. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15148. /**
  15149. * Remove a specific ramp gradient
  15150. * @param gradient defines the gradient to remove
  15151. * @returns the current particle system
  15152. */
  15153. removeRampGradient(gradient: number): ParticleSystem;
  15154. /**
  15155. * Adds a new color gradient
  15156. * @param gradient defines the gradient to use (between 0 and 1)
  15157. * @param color1 defines the color to affect to the specified gradient
  15158. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15159. * @returns this particle system
  15160. */
  15161. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15162. /**
  15163. * Remove a specific color gradient
  15164. * @param gradient defines the gradient to remove
  15165. * @returns this particle system
  15166. */
  15167. removeColorGradient(gradient: number): IParticleSystem;
  15168. private _fetchR;
  15169. protected _reset(): void;
  15170. private _resetEffect;
  15171. private _createVertexBuffers;
  15172. private _createIndexBuffer;
  15173. /**
  15174. * Gets the maximum number of particles active at the same time.
  15175. * @returns The max number of active particles.
  15176. */
  15177. getCapacity(): number;
  15178. /**
  15179. * Gets whether there are still active particles in the system.
  15180. * @returns True if it is alive, otherwise false.
  15181. */
  15182. isAlive(): boolean;
  15183. /**
  15184. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15185. * @returns True if it has been started, otherwise false.
  15186. */
  15187. isStarted(): boolean;
  15188. private _prepareSubEmitterInternalArray;
  15189. /**
  15190. * Starts the particle system and begins to emit
  15191. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15192. */
  15193. start(delay?: number): void;
  15194. /**
  15195. * Stops the particle system.
  15196. * @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.
  15197. */
  15198. stop(stopSubEmitters?: boolean): void;
  15199. /**
  15200. * Remove all active particles
  15201. */
  15202. reset(): void;
  15203. /**
  15204. * @hidden (for internal use only)
  15205. */
  15206. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15207. /**
  15208. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15209. * Its lifetime will start back at 0.
  15210. */
  15211. recycleParticle: (particle: Particle) => void;
  15212. private _stopSubEmitters;
  15213. private _createParticle;
  15214. private _removeFromRoot;
  15215. private _emitFromParticle;
  15216. private _update;
  15217. /** @hidden */
  15218. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15219. /** @hidden */
  15220. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15221. /** @hidden */
  15222. private _getEffect;
  15223. /**
  15224. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15225. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15226. */
  15227. animate(preWarmOnly?: boolean): void;
  15228. private _appendParticleVertices;
  15229. /**
  15230. * Rebuilds the particle system.
  15231. */
  15232. rebuild(): void;
  15233. /**
  15234. * Is this system ready to be used/rendered
  15235. * @return true if the system is ready
  15236. */
  15237. isReady(): boolean;
  15238. private _render;
  15239. /**
  15240. * Renders the particle system in its current state.
  15241. * @returns the current number of particles
  15242. */
  15243. render(): number;
  15244. /**
  15245. * Disposes the particle system and free the associated resources
  15246. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15247. */
  15248. dispose(disposeTexture?: boolean): void;
  15249. /**
  15250. * Clones the particle system.
  15251. * @param name The name of the cloned object
  15252. * @param newEmitter The new emitter to use
  15253. * @returns the cloned particle system
  15254. */
  15255. clone(name: string, newEmitter: any): ParticleSystem;
  15256. /**
  15257. * Serializes the particle system to a JSON object.
  15258. * @returns the JSON object
  15259. */
  15260. serialize(): any;
  15261. /** @hidden */
  15262. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15263. /** @hidden */
  15264. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15265. /**
  15266. * Parses a JSON object to create a particle system.
  15267. * @param parsedParticleSystem The JSON object to parse
  15268. * @param scene The scene to create the particle system in
  15269. * @param rootUrl The root url to use to load external dependencies like texture
  15270. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15271. * @returns the Parsed particle system
  15272. */
  15273. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15274. }
  15275. }
  15276. declare module "babylonjs/Particles/particle" {
  15277. import { Nullable } from "babylonjs/types";
  15278. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15279. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15280. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15281. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15282. /**
  15283. * A particle represents one of the element emitted by a particle system.
  15284. * This is mainly define by its coordinates, direction, velocity and age.
  15285. */
  15286. export class Particle {
  15287. /**
  15288. * The particle system the particle belongs to.
  15289. */
  15290. particleSystem: ParticleSystem;
  15291. private static _Count;
  15292. /**
  15293. * Unique ID of the particle
  15294. */
  15295. id: number;
  15296. /**
  15297. * The world position of the particle in the scene.
  15298. */
  15299. position: Vector3;
  15300. /**
  15301. * The world direction of the particle in the scene.
  15302. */
  15303. direction: Vector3;
  15304. /**
  15305. * The color of the particle.
  15306. */
  15307. color: Color4;
  15308. /**
  15309. * The color change of the particle per step.
  15310. */
  15311. colorStep: Color4;
  15312. /**
  15313. * Defines how long will the life of the particle be.
  15314. */
  15315. lifeTime: number;
  15316. /**
  15317. * The current age of the particle.
  15318. */
  15319. age: number;
  15320. /**
  15321. * The current size of the particle.
  15322. */
  15323. size: number;
  15324. /**
  15325. * The current scale of the particle.
  15326. */
  15327. scale: Vector2;
  15328. /**
  15329. * The current angle of the particle.
  15330. */
  15331. angle: number;
  15332. /**
  15333. * Defines how fast is the angle changing.
  15334. */
  15335. angularSpeed: number;
  15336. /**
  15337. * Defines the cell index used by the particle to be rendered from a sprite.
  15338. */
  15339. cellIndex: number;
  15340. /**
  15341. * The information required to support color remapping
  15342. */
  15343. remapData: Vector4;
  15344. /** @hidden */
  15345. _randomCellOffset?: number;
  15346. /** @hidden */
  15347. _initialDirection: Nullable<Vector3>;
  15348. /** @hidden */
  15349. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15350. /** @hidden */
  15351. _initialStartSpriteCellID: number;
  15352. /** @hidden */
  15353. _initialEndSpriteCellID: number;
  15354. /** @hidden */
  15355. _currentColorGradient: Nullable<ColorGradient>;
  15356. /** @hidden */
  15357. _currentColor1: Color4;
  15358. /** @hidden */
  15359. _currentColor2: Color4;
  15360. /** @hidden */
  15361. _currentSizeGradient: Nullable<FactorGradient>;
  15362. /** @hidden */
  15363. _currentSize1: number;
  15364. /** @hidden */
  15365. _currentSize2: number;
  15366. /** @hidden */
  15367. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15368. /** @hidden */
  15369. _currentAngularSpeed1: number;
  15370. /** @hidden */
  15371. _currentAngularSpeed2: number;
  15372. /** @hidden */
  15373. _currentVelocityGradient: Nullable<FactorGradient>;
  15374. /** @hidden */
  15375. _currentVelocity1: number;
  15376. /** @hidden */
  15377. _currentVelocity2: number;
  15378. /** @hidden */
  15379. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15380. /** @hidden */
  15381. _currentLimitVelocity1: number;
  15382. /** @hidden */
  15383. _currentLimitVelocity2: number;
  15384. /** @hidden */
  15385. _currentDragGradient: Nullable<FactorGradient>;
  15386. /** @hidden */
  15387. _currentDrag1: number;
  15388. /** @hidden */
  15389. _currentDrag2: number;
  15390. /** @hidden */
  15391. _randomNoiseCoordinates1: Vector3;
  15392. /** @hidden */
  15393. _randomNoiseCoordinates2: Vector3;
  15394. /**
  15395. * Creates a new instance Particle
  15396. * @param particleSystem the particle system the particle belongs to
  15397. */
  15398. constructor(
  15399. /**
  15400. * The particle system the particle belongs to.
  15401. */
  15402. particleSystem: ParticleSystem);
  15403. private updateCellInfoFromSystem;
  15404. /**
  15405. * Defines how the sprite cell index is updated for the particle
  15406. */
  15407. updateCellIndex(): void;
  15408. /** @hidden */
  15409. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15410. /** @hidden */
  15411. _inheritParticleInfoToSubEmitters(): void;
  15412. /** @hidden */
  15413. _reset(): void;
  15414. /**
  15415. * Copy the properties of particle to another one.
  15416. * @param other the particle to copy the information to.
  15417. */
  15418. copyTo(other: Particle): void;
  15419. }
  15420. }
  15421. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15422. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15423. import { Effect } from "babylonjs/Materials/effect";
  15424. import { Particle } from "babylonjs/Particles/particle";
  15425. /**
  15426. * Particle emitter represents a volume emitting particles.
  15427. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15428. */
  15429. export interface IParticleEmitterType {
  15430. /**
  15431. * Called by the particle System when the direction is computed for the created particle.
  15432. * @param worldMatrix is the world matrix of the particle system
  15433. * @param directionToUpdate is the direction vector to update with the result
  15434. * @param particle is the particle we are computed the direction for
  15435. */
  15436. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15437. /**
  15438. * Called by the particle System when the position is computed for the created particle.
  15439. * @param worldMatrix is the world matrix of the particle system
  15440. * @param positionToUpdate is the position vector to update with the result
  15441. * @param particle is the particle we are computed the position for
  15442. */
  15443. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15444. /**
  15445. * Clones the current emitter and returns a copy of it
  15446. * @returns the new emitter
  15447. */
  15448. clone(): IParticleEmitterType;
  15449. /**
  15450. * Called by the GPUParticleSystem to setup the update shader
  15451. * @param effect defines the update shader
  15452. */
  15453. applyToShader(effect: Effect): void;
  15454. /**
  15455. * Returns a string to use to update the GPU particles update shader
  15456. * @returns the effect defines string
  15457. */
  15458. getEffectDefines(): string;
  15459. /**
  15460. * Returns a string representing the class name
  15461. * @returns a string containing the class name
  15462. */
  15463. getClassName(): string;
  15464. /**
  15465. * Serializes the particle system to a JSON object.
  15466. * @returns the JSON object
  15467. */
  15468. serialize(): any;
  15469. /**
  15470. * Parse properties from a JSON object
  15471. * @param serializationObject defines the JSON object
  15472. */
  15473. parse(serializationObject: any): void;
  15474. }
  15475. }
  15476. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15477. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15478. import { Effect } from "babylonjs/Materials/effect";
  15479. import { Particle } from "babylonjs/Particles/particle";
  15480. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15481. /**
  15482. * Particle emitter emitting particles from the inside of a box.
  15483. * It emits the particles randomly between 2 given directions.
  15484. */
  15485. export class BoxParticleEmitter implements IParticleEmitterType {
  15486. /**
  15487. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15488. */
  15489. direction1: Vector3;
  15490. /**
  15491. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15492. */
  15493. direction2: Vector3;
  15494. /**
  15495. * 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.
  15496. */
  15497. minEmitBox: Vector3;
  15498. /**
  15499. * 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.
  15500. */
  15501. maxEmitBox: Vector3;
  15502. /**
  15503. * Creates a new instance BoxParticleEmitter
  15504. */
  15505. constructor();
  15506. /**
  15507. * Called by the particle System when the direction is computed for the created particle.
  15508. * @param worldMatrix is the world matrix of the particle system
  15509. * @param directionToUpdate is the direction vector to update with the result
  15510. * @param particle is the particle we are computed the direction for
  15511. */
  15512. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15513. /**
  15514. * Called by the particle System when the position is computed for the created particle.
  15515. * @param worldMatrix is the world matrix of the particle system
  15516. * @param positionToUpdate is the position vector to update with the result
  15517. * @param particle is the particle we are computed the position for
  15518. */
  15519. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15520. /**
  15521. * Clones the current emitter and returns a copy of it
  15522. * @returns the new emitter
  15523. */
  15524. clone(): BoxParticleEmitter;
  15525. /**
  15526. * Called by the GPUParticleSystem to setup the update shader
  15527. * @param effect defines the update shader
  15528. */
  15529. applyToShader(effect: Effect): void;
  15530. /**
  15531. * Returns a string to use to update the GPU particles update shader
  15532. * @returns a string containng the defines string
  15533. */
  15534. getEffectDefines(): string;
  15535. /**
  15536. * Returns the string "BoxParticleEmitter"
  15537. * @returns a string containing the class name
  15538. */
  15539. getClassName(): string;
  15540. /**
  15541. * Serializes the particle system to a JSON object.
  15542. * @returns the JSON object
  15543. */
  15544. serialize(): any;
  15545. /**
  15546. * Parse properties from a JSON object
  15547. * @param serializationObject defines the JSON object
  15548. */
  15549. parse(serializationObject: any): void;
  15550. }
  15551. }
  15552. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  15553. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15554. import { Effect } from "babylonjs/Materials/effect";
  15555. import { Particle } from "babylonjs/Particles/particle";
  15556. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15557. /**
  15558. * Particle emitter emitting particles from the inside of a cone.
  15559. * It emits the particles alongside the cone volume from the base to the particle.
  15560. * The emission direction might be randomized.
  15561. */
  15562. export class ConeParticleEmitter implements IParticleEmitterType {
  15563. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15564. directionRandomizer: number;
  15565. private _radius;
  15566. private _angle;
  15567. private _height;
  15568. /**
  15569. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15570. */
  15571. radiusRange: number;
  15572. /**
  15573. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15574. */
  15575. heightRange: number;
  15576. /**
  15577. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15578. */
  15579. emitFromSpawnPointOnly: boolean;
  15580. /**
  15581. * Gets or sets the radius of the emission cone
  15582. */
  15583. radius: number;
  15584. /**
  15585. * Gets or sets the angle of the emission cone
  15586. */
  15587. angle: number;
  15588. private _buildHeight;
  15589. /**
  15590. * Creates a new instance ConeParticleEmitter
  15591. * @param radius the radius of the emission cone (1 by default)
  15592. * @param angle the cone base angle (PI by default)
  15593. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15594. */
  15595. constructor(radius?: number, angle?: number,
  15596. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15597. directionRandomizer?: number);
  15598. /**
  15599. * Called by the particle System when the direction is computed for the created particle.
  15600. * @param worldMatrix is the world matrix of the particle system
  15601. * @param directionToUpdate is the direction vector to update with the result
  15602. * @param particle is the particle we are computed the direction for
  15603. */
  15604. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15605. /**
  15606. * Called by the particle System when the position is computed for the created particle.
  15607. * @param worldMatrix is the world matrix of the particle system
  15608. * @param positionToUpdate is the position vector to update with the result
  15609. * @param particle is the particle we are computed the position for
  15610. */
  15611. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15612. /**
  15613. * Clones the current emitter and returns a copy of it
  15614. * @returns the new emitter
  15615. */
  15616. clone(): ConeParticleEmitter;
  15617. /**
  15618. * Called by the GPUParticleSystem to setup the update shader
  15619. * @param effect defines the update shader
  15620. */
  15621. applyToShader(effect: Effect): void;
  15622. /**
  15623. * Returns a string to use to update the GPU particles update shader
  15624. * @returns a string containng the defines string
  15625. */
  15626. getEffectDefines(): string;
  15627. /**
  15628. * Returns the string "ConeParticleEmitter"
  15629. * @returns a string containing the class name
  15630. */
  15631. getClassName(): string;
  15632. /**
  15633. * Serializes the particle system to a JSON object.
  15634. * @returns the JSON object
  15635. */
  15636. serialize(): any;
  15637. /**
  15638. * Parse properties from a JSON object
  15639. * @param serializationObject defines the JSON object
  15640. */
  15641. parse(serializationObject: any): void;
  15642. }
  15643. }
  15644. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  15645. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15646. import { Effect } from "babylonjs/Materials/effect";
  15647. import { Particle } from "babylonjs/Particles/particle";
  15648. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15649. /**
  15650. * Particle emitter emitting particles from the inside of a cylinder.
  15651. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15652. */
  15653. export class CylinderParticleEmitter implements IParticleEmitterType {
  15654. /**
  15655. * The radius of the emission cylinder.
  15656. */
  15657. radius: number;
  15658. /**
  15659. * The height of the emission cylinder.
  15660. */
  15661. height: number;
  15662. /**
  15663. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15664. */
  15665. radiusRange: number;
  15666. /**
  15667. * How much to randomize the particle direction [0-1].
  15668. */
  15669. directionRandomizer: number;
  15670. /**
  15671. * Creates a new instance CylinderParticleEmitter
  15672. * @param radius the radius of the emission cylinder (1 by default)
  15673. * @param height the height of the emission cylinder (1 by default)
  15674. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15675. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15676. */
  15677. constructor(
  15678. /**
  15679. * The radius of the emission cylinder.
  15680. */
  15681. radius?: number,
  15682. /**
  15683. * The height of the emission cylinder.
  15684. */
  15685. height?: number,
  15686. /**
  15687. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15688. */
  15689. radiusRange?: number,
  15690. /**
  15691. * How much to randomize the particle direction [0-1].
  15692. */
  15693. directionRandomizer?: number);
  15694. /**
  15695. * Called by the particle System when the direction is computed for the created particle.
  15696. * @param worldMatrix is the world matrix of the particle system
  15697. * @param directionToUpdate is the direction vector to update with the result
  15698. * @param particle is the particle we are computed the direction for
  15699. */
  15700. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15701. /**
  15702. * Called by the particle System when the position is computed for the created particle.
  15703. * @param worldMatrix is the world matrix of the particle system
  15704. * @param positionToUpdate is the position vector to update with the result
  15705. * @param particle is the particle we are computed the position for
  15706. */
  15707. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15708. /**
  15709. * Clones the current emitter and returns a copy of it
  15710. * @returns the new emitter
  15711. */
  15712. clone(): CylinderParticleEmitter;
  15713. /**
  15714. * Called by the GPUParticleSystem to setup the update shader
  15715. * @param effect defines the update shader
  15716. */
  15717. applyToShader(effect: Effect): void;
  15718. /**
  15719. * Returns a string to use to update the GPU particles update shader
  15720. * @returns a string containng the defines string
  15721. */
  15722. getEffectDefines(): string;
  15723. /**
  15724. * Returns the string "CylinderParticleEmitter"
  15725. * @returns a string containing the class name
  15726. */
  15727. getClassName(): string;
  15728. /**
  15729. * Serializes the particle system to a JSON object.
  15730. * @returns the JSON object
  15731. */
  15732. serialize(): any;
  15733. /**
  15734. * Parse properties from a JSON object
  15735. * @param serializationObject defines the JSON object
  15736. */
  15737. parse(serializationObject: any): void;
  15738. }
  15739. /**
  15740. * Particle emitter emitting particles from the inside of a cylinder.
  15741. * It emits the particles randomly between two vectors.
  15742. */
  15743. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15744. /**
  15745. * The min limit of the emission direction.
  15746. */
  15747. direction1: Vector3;
  15748. /**
  15749. * The max limit of the emission direction.
  15750. */
  15751. direction2: Vector3;
  15752. /**
  15753. * Creates a new instance CylinderDirectedParticleEmitter
  15754. * @param radius the radius of the emission cylinder (1 by default)
  15755. * @param height the height of the emission cylinder (1 by default)
  15756. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15757. * @param direction1 the min limit of the emission direction (up vector by default)
  15758. * @param direction2 the max limit of the emission direction (up vector by default)
  15759. */
  15760. constructor(radius?: number, height?: number, radiusRange?: number,
  15761. /**
  15762. * The min limit of the emission direction.
  15763. */
  15764. direction1?: Vector3,
  15765. /**
  15766. * The max limit of the emission direction.
  15767. */
  15768. direction2?: Vector3);
  15769. /**
  15770. * Called by the particle System when the direction is computed for the created particle.
  15771. * @param worldMatrix is the world matrix of the particle system
  15772. * @param directionToUpdate is the direction vector to update with the result
  15773. * @param particle is the particle we are computed the direction for
  15774. */
  15775. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15776. /**
  15777. * Clones the current emitter and returns a copy of it
  15778. * @returns the new emitter
  15779. */
  15780. clone(): CylinderDirectedParticleEmitter;
  15781. /**
  15782. * Called by the GPUParticleSystem to setup the update shader
  15783. * @param effect defines the update shader
  15784. */
  15785. applyToShader(effect: Effect): void;
  15786. /**
  15787. * Returns a string to use to update the GPU particles update shader
  15788. * @returns a string containng the defines string
  15789. */
  15790. getEffectDefines(): string;
  15791. /**
  15792. * Returns the string "CylinderDirectedParticleEmitter"
  15793. * @returns a string containing the class name
  15794. */
  15795. getClassName(): string;
  15796. /**
  15797. * Serializes the particle system to a JSON object.
  15798. * @returns the JSON object
  15799. */
  15800. serialize(): any;
  15801. /**
  15802. * Parse properties from a JSON object
  15803. * @param serializationObject defines the JSON object
  15804. */
  15805. parse(serializationObject: any): void;
  15806. }
  15807. }
  15808. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  15809. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15810. import { Effect } from "babylonjs/Materials/effect";
  15811. import { Particle } from "babylonjs/Particles/particle";
  15812. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15813. /**
  15814. * Particle emitter emitting particles from the inside of a hemisphere.
  15815. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15816. */
  15817. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15818. /**
  15819. * The radius of the emission hemisphere.
  15820. */
  15821. radius: number;
  15822. /**
  15823. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15824. */
  15825. radiusRange: number;
  15826. /**
  15827. * How much to randomize the particle direction [0-1].
  15828. */
  15829. directionRandomizer: number;
  15830. /**
  15831. * Creates a new instance HemisphericParticleEmitter
  15832. * @param radius the radius of the emission hemisphere (1 by default)
  15833. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15834. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15835. */
  15836. constructor(
  15837. /**
  15838. * The radius of the emission hemisphere.
  15839. */
  15840. radius?: number,
  15841. /**
  15842. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15843. */
  15844. radiusRange?: number,
  15845. /**
  15846. * How much to randomize the particle direction [0-1].
  15847. */
  15848. directionRandomizer?: number);
  15849. /**
  15850. * Called by the particle System when the direction is computed for the created particle.
  15851. * @param worldMatrix is the world matrix of the particle system
  15852. * @param directionToUpdate is the direction vector to update with the result
  15853. * @param particle is the particle we are computed the direction for
  15854. */
  15855. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15856. /**
  15857. * Called by the particle System when the position is computed for the created particle.
  15858. * @param worldMatrix is the world matrix of the particle system
  15859. * @param positionToUpdate is the position vector to update with the result
  15860. * @param particle is the particle we are computed the position for
  15861. */
  15862. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15863. /**
  15864. * Clones the current emitter and returns a copy of it
  15865. * @returns the new emitter
  15866. */
  15867. clone(): HemisphericParticleEmitter;
  15868. /**
  15869. * Called by the GPUParticleSystem to setup the update shader
  15870. * @param effect defines the update shader
  15871. */
  15872. applyToShader(effect: Effect): void;
  15873. /**
  15874. * Returns a string to use to update the GPU particles update shader
  15875. * @returns a string containng the defines string
  15876. */
  15877. getEffectDefines(): string;
  15878. /**
  15879. * Returns the string "HemisphericParticleEmitter"
  15880. * @returns a string containing the class name
  15881. */
  15882. getClassName(): string;
  15883. /**
  15884. * Serializes the particle system to a JSON object.
  15885. * @returns the JSON object
  15886. */
  15887. serialize(): any;
  15888. /**
  15889. * Parse properties from a JSON object
  15890. * @param serializationObject defines the JSON object
  15891. */
  15892. parse(serializationObject: any): void;
  15893. }
  15894. }
  15895. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  15896. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15897. import { Effect } from "babylonjs/Materials/effect";
  15898. import { Particle } from "babylonjs/Particles/particle";
  15899. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15900. /**
  15901. * Particle emitter emitting particles from a point.
  15902. * It emits the particles randomly between 2 given directions.
  15903. */
  15904. export class PointParticleEmitter implements IParticleEmitterType {
  15905. /**
  15906. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15907. */
  15908. direction1: Vector3;
  15909. /**
  15910. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15911. */
  15912. direction2: Vector3;
  15913. /**
  15914. * Creates a new instance PointParticleEmitter
  15915. */
  15916. constructor();
  15917. /**
  15918. * Called by the particle System when the direction is computed for the created particle.
  15919. * @param worldMatrix is the world matrix of the particle system
  15920. * @param directionToUpdate is the direction vector to update with the result
  15921. * @param particle is the particle we are computed the direction for
  15922. */
  15923. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15924. /**
  15925. * Called by the particle System when the position is computed for the created particle.
  15926. * @param worldMatrix is the world matrix of the particle system
  15927. * @param positionToUpdate is the position vector to update with the result
  15928. * @param particle is the particle we are computed the position for
  15929. */
  15930. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15931. /**
  15932. * Clones the current emitter and returns a copy of it
  15933. * @returns the new emitter
  15934. */
  15935. clone(): PointParticleEmitter;
  15936. /**
  15937. * Called by the GPUParticleSystem to setup the update shader
  15938. * @param effect defines the update shader
  15939. */
  15940. applyToShader(effect: Effect): void;
  15941. /**
  15942. * Returns a string to use to update the GPU particles update shader
  15943. * @returns a string containng the defines string
  15944. */
  15945. getEffectDefines(): string;
  15946. /**
  15947. * Returns the string "PointParticleEmitter"
  15948. * @returns a string containing the class name
  15949. */
  15950. getClassName(): string;
  15951. /**
  15952. * Serializes the particle system to a JSON object.
  15953. * @returns the JSON object
  15954. */
  15955. serialize(): any;
  15956. /**
  15957. * Parse properties from a JSON object
  15958. * @param serializationObject defines the JSON object
  15959. */
  15960. parse(serializationObject: any): void;
  15961. }
  15962. }
  15963. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  15964. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15965. import { Effect } from "babylonjs/Materials/effect";
  15966. import { Particle } from "babylonjs/Particles/particle";
  15967. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15968. /**
  15969. * Particle emitter emitting particles from the inside of a sphere.
  15970. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15971. */
  15972. export class SphereParticleEmitter implements IParticleEmitterType {
  15973. /**
  15974. * The radius of the emission sphere.
  15975. */
  15976. radius: number;
  15977. /**
  15978. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15979. */
  15980. radiusRange: number;
  15981. /**
  15982. * How much to randomize the particle direction [0-1].
  15983. */
  15984. directionRandomizer: number;
  15985. /**
  15986. * Creates a new instance SphereParticleEmitter
  15987. * @param radius the radius of the emission sphere (1 by default)
  15988. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15989. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15990. */
  15991. constructor(
  15992. /**
  15993. * The radius of the emission sphere.
  15994. */
  15995. radius?: number,
  15996. /**
  15997. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15998. */
  15999. radiusRange?: number,
  16000. /**
  16001. * How much to randomize the particle direction [0-1].
  16002. */
  16003. directionRandomizer?: number);
  16004. /**
  16005. * Called by the particle System when the direction is computed for the created particle.
  16006. * @param worldMatrix is the world matrix of the particle system
  16007. * @param directionToUpdate is the direction vector to update with the result
  16008. * @param particle is the particle we are computed the direction for
  16009. */
  16010. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16011. /**
  16012. * Called by the particle System when the position is computed for the created particle.
  16013. * @param worldMatrix is the world matrix of the particle system
  16014. * @param positionToUpdate is the position vector to update with the result
  16015. * @param particle is the particle we are computed the position for
  16016. */
  16017. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16018. /**
  16019. * Clones the current emitter and returns a copy of it
  16020. * @returns the new emitter
  16021. */
  16022. clone(): SphereParticleEmitter;
  16023. /**
  16024. * Called by the GPUParticleSystem to setup the update shader
  16025. * @param effect defines the update shader
  16026. */
  16027. applyToShader(effect: Effect): void;
  16028. /**
  16029. * Returns a string to use to update the GPU particles update shader
  16030. * @returns a string containng the defines string
  16031. */
  16032. getEffectDefines(): string;
  16033. /**
  16034. * Returns the string "SphereParticleEmitter"
  16035. * @returns a string containing the class name
  16036. */
  16037. getClassName(): string;
  16038. /**
  16039. * Serializes the particle system to a JSON object.
  16040. * @returns the JSON object
  16041. */
  16042. serialize(): any;
  16043. /**
  16044. * Parse properties from a JSON object
  16045. * @param serializationObject defines the JSON object
  16046. */
  16047. parse(serializationObject: any): void;
  16048. }
  16049. /**
  16050. * Particle emitter emitting particles from the inside of a sphere.
  16051. * It emits the particles randomly between two vectors.
  16052. */
  16053. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16054. /**
  16055. * The min limit of the emission direction.
  16056. */
  16057. direction1: Vector3;
  16058. /**
  16059. * The max limit of the emission direction.
  16060. */
  16061. direction2: Vector3;
  16062. /**
  16063. * Creates a new instance SphereDirectedParticleEmitter
  16064. * @param radius the radius of the emission sphere (1 by default)
  16065. * @param direction1 the min limit of the emission direction (up vector by default)
  16066. * @param direction2 the max limit of the emission direction (up vector by default)
  16067. */
  16068. constructor(radius?: number,
  16069. /**
  16070. * The min limit of the emission direction.
  16071. */
  16072. direction1?: Vector3,
  16073. /**
  16074. * The max limit of the emission direction.
  16075. */
  16076. direction2?: Vector3);
  16077. /**
  16078. * Called by the particle System when the direction is computed for the created particle.
  16079. * @param worldMatrix is the world matrix of the particle system
  16080. * @param directionToUpdate is the direction vector to update with the result
  16081. * @param particle is the particle we are computed the direction for
  16082. */
  16083. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16084. /**
  16085. * Clones the current emitter and returns a copy of it
  16086. * @returns the new emitter
  16087. */
  16088. clone(): SphereDirectedParticleEmitter;
  16089. /**
  16090. * Called by the GPUParticleSystem to setup the update shader
  16091. * @param effect defines the update shader
  16092. */
  16093. applyToShader(effect: Effect): void;
  16094. /**
  16095. * Returns a string to use to update the GPU particles update shader
  16096. * @returns a string containng the defines string
  16097. */
  16098. getEffectDefines(): string;
  16099. /**
  16100. * Returns the string "SphereDirectedParticleEmitter"
  16101. * @returns a string containing the class name
  16102. */
  16103. getClassName(): string;
  16104. /**
  16105. * Serializes the particle system to a JSON object.
  16106. * @returns the JSON object
  16107. */
  16108. serialize(): any;
  16109. /**
  16110. * Parse properties from a JSON object
  16111. * @param serializationObject defines the JSON object
  16112. */
  16113. parse(serializationObject: any): void;
  16114. }
  16115. }
  16116. declare module "babylonjs/Particles/EmitterTypes/index" {
  16117. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  16118. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  16119. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  16120. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  16121. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16122. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  16123. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  16124. }
  16125. declare module "babylonjs/Particles/IParticleSystem" {
  16126. import { Nullable } from "babylonjs/types";
  16127. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  16128. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16129. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16130. import { Texture } from "babylonjs/Materials/Textures/texture";
  16131. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16132. import { Scene } from "babylonjs/scene";
  16133. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  16134. import { Animation } from "babylonjs/Animations/animation";
  16135. /**
  16136. * Interface representing a particle system in Babylon.js.
  16137. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16138. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16139. */
  16140. export interface IParticleSystem {
  16141. /**
  16142. * List of animations used by the particle system.
  16143. */
  16144. animations: Animation[];
  16145. /**
  16146. * The id of the Particle system.
  16147. */
  16148. id: string;
  16149. /**
  16150. * The name of the Particle system.
  16151. */
  16152. name: string;
  16153. /**
  16154. * The emitter represents the Mesh or position we are attaching the particle system to.
  16155. */
  16156. emitter: Nullable<AbstractMesh | Vector3>;
  16157. /**
  16158. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16159. */
  16160. isBillboardBased: boolean;
  16161. /**
  16162. * The rendering group used by the Particle system to chose when to render.
  16163. */
  16164. renderingGroupId: number;
  16165. /**
  16166. * The layer mask we are rendering the particles through.
  16167. */
  16168. layerMask: number;
  16169. /**
  16170. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16171. */
  16172. updateSpeed: number;
  16173. /**
  16174. * The amount of time the particle system is running (depends of the overall update speed).
  16175. */
  16176. targetStopDuration: number;
  16177. /**
  16178. * The texture used to render each particle. (this can be a spritesheet)
  16179. */
  16180. particleTexture: Nullable<Texture>;
  16181. /**
  16182. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16183. */
  16184. blendMode: number;
  16185. /**
  16186. * Minimum life time of emitting particles.
  16187. */
  16188. minLifeTime: number;
  16189. /**
  16190. * Maximum life time of emitting particles.
  16191. */
  16192. maxLifeTime: number;
  16193. /**
  16194. * Minimum Size of emitting particles.
  16195. */
  16196. minSize: number;
  16197. /**
  16198. * Maximum Size of emitting particles.
  16199. */
  16200. maxSize: number;
  16201. /**
  16202. * Minimum scale of emitting particles on X axis.
  16203. */
  16204. minScaleX: number;
  16205. /**
  16206. * Maximum scale of emitting particles on X axis.
  16207. */
  16208. maxScaleX: number;
  16209. /**
  16210. * Minimum scale of emitting particles on Y axis.
  16211. */
  16212. minScaleY: number;
  16213. /**
  16214. * Maximum scale of emitting particles on Y axis.
  16215. */
  16216. maxScaleY: number;
  16217. /**
  16218. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16219. */
  16220. color1: Color4;
  16221. /**
  16222. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16223. */
  16224. color2: Color4;
  16225. /**
  16226. * Color the particle will have at the end of its lifetime.
  16227. */
  16228. colorDead: Color4;
  16229. /**
  16230. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16231. */
  16232. emitRate: number;
  16233. /**
  16234. * You can use gravity if you want to give an orientation to your particles.
  16235. */
  16236. gravity: Vector3;
  16237. /**
  16238. * Minimum power of emitting particles.
  16239. */
  16240. minEmitPower: number;
  16241. /**
  16242. * Maximum power of emitting particles.
  16243. */
  16244. maxEmitPower: number;
  16245. /**
  16246. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16247. */
  16248. minAngularSpeed: number;
  16249. /**
  16250. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16251. */
  16252. maxAngularSpeed: number;
  16253. /**
  16254. * Gets or sets the minimal initial rotation in radians.
  16255. */
  16256. minInitialRotation: number;
  16257. /**
  16258. * Gets or sets the maximal initial rotation in radians.
  16259. */
  16260. maxInitialRotation: number;
  16261. /**
  16262. * The particle emitter type defines the emitter used by the particle system.
  16263. * It can be for example box, sphere, or cone...
  16264. */
  16265. particleEmitterType: Nullable<IParticleEmitterType>;
  16266. /**
  16267. * Defines the delay in milliseconds before starting the system (0 by default)
  16268. */
  16269. startDelay: number;
  16270. /**
  16271. * 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
  16272. */
  16273. preWarmCycles: number;
  16274. /**
  16275. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16276. */
  16277. preWarmStepOffset: number;
  16278. /**
  16279. * 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)
  16280. */
  16281. spriteCellChangeSpeed: number;
  16282. /**
  16283. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16284. */
  16285. startSpriteCellID: number;
  16286. /**
  16287. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16288. */
  16289. endSpriteCellID: number;
  16290. /**
  16291. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16292. */
  16293. spriteCellWidth: number;
  16294. /**
  16295. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16296. */
  16297. spriteCellHeight: number;
  16298. /**
  16299. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16300. */
  16301. spriteRandomStartCell: boolean;
  16302. /**
  16303. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16304. */
  16305. isAnimationSheetEnabled: boolean;
  16306. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16307. translationPivot: Vector2;
  16308. /**
  16309. * Gets or sets a texture used to add random noise to particle positions
  16310. */
  16311. noiseTexture: Nullable<BaseTexture>;
  16312. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16313. noiseStrength: Vector3;
  16314. /**
  16315. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16316. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16317. */
  16318. billboardMode: number;
  16319. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16320. limitVelocityDamping: number;
  16321. /**
  16322. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16323. */
  16324. beginAnimationOnStart: boolean;
  16325. /**
  16326. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16327. */
  16328. beginAnimationFrom: number;
  16329. /**
  16330. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16331. */
  16332. beginAnimationTo: number;
  16333. /**
  16334. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16335. */
  16336. beginAnimationLoop: boolean;
  16337. /**
  16338. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16339. */
  16340. disposeOnStop: boolean;
  16341. /**
  16342. * Gets the maximum number of particles active at the same time.
  16343. * @returns The max number of active particles.
  16344. */
  16345. getCapacity(): number;
  16346. /**
  16347. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16348. * @returns True if it has been started, otherwise false.
  16349. */
  16350. isStarted(): boolean;
  16351. /**
  16352. * Animates the particle system for this frame.
  16353. */
  16354. animate(): void;
  16355. /**
  16356. * Renders the particle system in its current state.
  16357. * @returns the current number of particles
  16358. */
  16359. render(): number;
  16360. /**
  16361. * Dispose the particle system and frees its associated resources.
  16362. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16363. */
  16364. dispose(disposeTexture?: boolean): void;
  16365. /**
  16366. * Clones the particle system.
  16367. * @param name The name of the cloned object
  16368. * @param newEmitter The new emitter to use
  16369. * @returns the cloned particle system
  16370. */
  16371. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16372. /**
  16373. * Serializes the particle system to a JSON object.
  16374. * @returns the JSON object
  16375. */
  16376. serialize(): any;
  16377. /**
  16378. * Rebuild the particle system
  16379. */
  16380. rebuild(): void;
  16381. /**
  16382. * Starts the particle system and begins to emit
  16383. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16384. */
  16385. start(delay?: number): void;
  16386. /**
  16387. * Stops the particle system.
  16388. */
  16389. stop(): void;
  16390. /**
  16391. * Remove all active particles
  16392. */
  16393. reset(): void;
  16394. /**
  16395. * Is this system ready to be used/rendered
  16396. * @return true if the system is ready
  16397. */
  16398. isReady(): boolean;
  16399. /**
  16400. * Adds a new color gradient
  16401. * @param gradient defines the gradient to use (between 0 and 1)
  16402. * @param color1 defines the color to affect to the specified gradient
  16403. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16404. * @returns the current particle system
  16405. */
  16406. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16407. /**
  16408. * Remove a specific color gradient
  16409. * @param gradient defines the gradient to remove
  16410. * @returns the current particle system
  16411. */
  16412. removeColorGradient(gradient: number): IParticleSystem;
  16413. /**
  16414. * Adds a new size gradient
  16415. * @param gradient defines the gradient to use (between 0 and 1)
  16416. * @param factor defines the size factor to affect to the specified gradient
  16417. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16418. * @returns the current particle system
  16419. */
  16420. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16421. /**
  16422. * Remove a specific size gradient
  16423. * @param gradient defines the gradient to remove
  16424. * @returns the current particle system
  16425. */
  16426. removeSizeGradient(gradient: number): IParticleSystem;
  16427. /**
  16428. * Gets the current list of color gradients.
  16429. * You must use addColorGradient and removeColorGradient to udpate this list
  16430. * @returns the list of color gradients
  16431. */
  16432. getColorGradients(): Nullable<Array<ColorGradient>>;
  16433. /**
  16434. * Gets the current list of size gradients.
  16435. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16436. * @returns the list of size gradients
  16437. */
  16438. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16439. /**
  16440. * Gets the current list of angular speed gradients.
  16441. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16442. * @returns the list of angular speed gradients
  16443. */
  16444. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16445. /**
  16446. * Adds a new angular speed gradient
  16447. * @param gradient defines the gradient to use (between 0 and 1)
  16448. * @param factor defines the angular speed to affect to the specified gradient
  16449. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16450. * @returns the current particle system
  16451. */
  16452. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16453. /**
  16454. * Remove a specific angular speed gradient
  16455. * @param gradient defines the gradient to remove
  16456. * @returns the current particle system
  16457. */
  16458. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16459. /**
  16460. * Gets the current list of velocity gradients.
  16461. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16462. * @returns the list of velocity gradients
  16463. */
  16464. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16465. /**
  16466. * Adds a new velocity gradient
  16467. * @param gradient defines the gradient to use (between 0 and 1)
  16468. * @param factor defines the velocity to affect to the specified gradient
  16469. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16470. * @returns the current particle system
  16471. */
  16472. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16473. /**
  16474. * Remove a specific velocity gradient
  16475. * @param gradient defines the gradient to remove
  16476. * @returns the current particle system
  16477. */
  16478. removeVelocityGradient(gradient: number): IParticleSystem;
  16479. /**
  16480. * Gets the current list of limit velocity gradients.
  16481. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16482. * @returns the list of limit velocity gradients
  16483. */
  16484. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16485. /**
  16486. * Adds a new limit velocity gradient
  16487. * @param gradient defines the gradient to use (between 0 and 1)
  16488. * @param factor defines the limit velocity to affect to the specified gradient
  16489. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16490. * @returns the current particle system
  16491. */
  16492. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16493. /**
  16494. * Remove a specific limit velocity gradient
  16495. * @param gradient defines the gradient to remove
  16496. * @returns the current particle system
  16497. */
  16498. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16499. /**
  16500. * Adds a new drag gradient
  16501. * @param gradient defines the gradient to use (between 0 and 1)
  16502. * @param factor defines the drag to affect to the specified gradient
  16503. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16504. * @returns the current particle system
  16505. */
  16506. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16507. /**
  16508. * Remove a specific drag gradient
  16509. * @param gradient defines the gradient to remove
  16510. * @returns the current particle system
  16511. */
  16512. removeDragGradient(gradient: number): IParticleSystem;
  16513. /**
  16514. * Gets the current list of drag gradients.
  16515. * You must use addDragGradient and removeDragGradient to udpate this list
  16516. * @returns the list of drag gradients
  16517. */
  16518. getDragGradients(): Nullable<Array<FactorGradient>>;
  16519. /**
  16520. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16521. * @param gradient defines the gradient to use (between 0 and 1)
  16522. * @param factor defines the emit rate to affect to the specified gradient
  16523. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16524. * @returns the current particle system
  16525. */
  16526. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16527. /**
  16528. * Remove a specific emit rate gradient
  16529. * @param gradient defines the gradient to remove
  16530. * @returns the current particle system
  16531. */
  16532. removeEmitRateGradient(gradient: number): IParticleSystem;
  16533. /**
  16534. * Gets the current list of emit rate gradients.
  16535. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16536. * @returns the list of emit rate gradients
  16537. */
  16538. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16539. /**
  16540. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16541. * @param gradient defines the gradient to use (between 0 and 1)
  16542. * @param factor defines the start size to affect to the specified gradient
  16543. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16544. * @returns the current particle system
  16545. */
  16546. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16547. /**
  16548. * Remove a specific start size gradient
  16549. * @param gradient defines the gradient to remove
  16550. * @returns the current particle system
  16551. */
  16552. removeStartSizeGradient(gradient: number): IParticleSystem;
  16553. /**
  16554. * Gets the current list of start size gradients.
  16555. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16556. * @returns the list of start size gradients
  16557. */
  16558. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16559. /**
  16560. * Adds a new life time gradient
  16561. * @param gradient defines the gradient to use (between 0 and 1)
  16562. * @param factor defines the life time factor to affect to the specified gradient
  16563. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16564. * @returns the current particle system
  16565. */
  16566. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16567. /**
  16568. * Remove a specific life time gradient
  16569. * @param gradient defines the gradient to remove
  16570. * @returns the current particle system
  16571. */
  16572. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16573. /**
  16574. * Gets the current list of life time gradients.
  16575. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16576. * @returns the list of life time gradients
  16577. */
  16578. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16579. /**
  16580. * Gets the current list of color gradients.
  16581. * You must use addColorGradient and removeColorGradient to udpate this list
  16582. * @returns the list of color gradients
  16583. */
  16584. getColorGradients(): Nullable<Array<ColorGradient>>;
  16585. /**
  16586. * Adds a new ramp gradient used to remap particle colors
  16587. * @param gradient defines the gradient to use (between 0 and 1)
  16588. * @param color defines the color to affect to the specified gradient
  16589. * @returns the current particle system
  16590. */
  16591. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16592. /**
  16593. * Gets the current list of ramp gradients.
  16594. * You must use addRampGradient and removeRampGradient to udpate this list
  16595. * @returns the list of ramp gradients
  16596. */
  16597. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16598. /** Gets or sets a boolean indicating that ramp gradients must be used
  16599. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16600. */
  16601. useRampGradients: boolean;
  16602. /**
  16603. * Adds a new color remap gradient
  16604. * @param gradient defines the gradient to use (between 0 and 1)
  16605. * @param min defines the color remap minimal range
  16606. * @param max defines the color remap maximal range
  16607. * @returns the current particle system
  16608. */
  16609. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16610. /**
  16611. * Gets the current list of color remap gradients.
  16612. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16613. * @returns the list of color remap gradients
  16614. */
  16615. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16616. /**
  16617. * Adds a new alpha remap gradient
  16618. * @param gradient defines the gradient to use (between 0 and 1)
  16619. * @param min defines the alpha remap minimal range
  16620. * @param max defines the alpha remap maximal range
  16621. * @returns the current particle system
  16622. */
  16623. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16624. /**
  16625. * Gets the current list of alpha remap gradients.
  16626. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16627. * @returns the list of alpha remap gradients
  16628. */
  16629. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16630. /**
  16631. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16632. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16633. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16634. * @returns the emitter
  16635. */
  16636. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16637. /**
  16638. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16639. * @param radius The radius of the hemisphere to emit from
  16640. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16641. * @returns the emitter
  16642. */
  16643. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16644. /**
  16645. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16646. * @param radius The radius of the sphere to emit from
  16647. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16648. * @returns the emitter
  16649. */
  16650. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16651. /**
  16652. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16653. * @param radius The radius of the sphere to emit from
  16654. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16655. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16656. * @returns the emitter
  16657. */
  16658. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16659. /**
  16660. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16661. * @param radius The radius of the emission cylinder
  16662. * @param height The height of the emission cylinder
  16663. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16664. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16665. * @returns the emitter
  16666. */
  16667. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16668. /**
  16669. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16670. * @param radius The radius of the cylinder to emit from
  16671. * @param height The height of the emission cylinder
  16672. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16673. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16674. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16675. * @returns the emitter
  16676. */
  16677. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16678. /**
  16679. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16680. * @param radius The radius of the cone to emit from
  16681. * @param angle The base angle of the cone
  16682. * @returns the emitter
  16683. */
  16684. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16685. /**
  16686. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16687. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16688. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16689. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16690. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16691. * @returns the emitter
  16692. */
  16693. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16694. /**
  16695. * Get hosting scene
  16696. * @returns the scene
  16697. */
  16698. getScene(): Scene;
  16699. }
  16700. }
  16701. declare module "babylonjs/Meshes/instancedMesh" {
  16702. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16703. import { Vector3 } from "babylonjs/Maths/math";
  16704. import { Camera } from "babylonjs/Cameras/camera";
  16705. import { Node } from "babylonjs/node";
  16706. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16707. import { Mesh } from "babylonjs/Meshes/mesh";
  16708. import { Material } from "babylonjs/Materials/material";
  16709. import { Skeleton } from "babylonjs/Bones/skeleton";
  16710. /**
  16711. * Creates an instance based on a source mesh.
  16712. */
  16713. export class InstancedMesh extends AbstractMesh {
  16714. private _sourceMesh;
  16715. private _currentLOD;
  16716. /** @hidden */
  16717. _indexInSourceMeshInstanceArray: number;
  16718. constructor(name: string, source: Mesh);
  16719. /**
  16720. * Returns the string "InstancedMesh".
  16721. */
  16722. getClassName(): string;
  16723. /**
  16724. * If the source mesh receives shadows
  16725. */
  16726. readonly receiveShadows: boolean;
  16727. /**
  16728. * The material of the source mesh
  16729. */
  16730. readonly material: Nullable<Material>;
  16731. /**
  16732. * Visibility of the source mesh
  16733. */
  16734. readonly visibility: number;
  16735. /**
  16736. * Skeleton of the source mesh
  16737. */
  16738. readonly skeleton: Nullable<Skeleton>;
  16739. /**
  16740. * Rendering ground id of the source mesh
  16741. */
  16742. renderingGroupId: number;
  16743. /**
  16744. * Returns the total number of vertices (integer).
  16745. */
  16746. getTotalVertices(): number;
  16747. /**
  16748. * Returns a positive integer : the total number of indices in this mesh geometry.
  16749. * @returns the numner of indices or zero if the mesh has no geometry.
  16750. */
  16751. getTotalIndices(): number;
  16752. /**
  16753. * The source mesh of the instance
  16754. */
  16755. readonly sourceMesh: Mesh;
  16756. /**
  16757. * Is this node ready to be used/rendered
  16758. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16759. * @return {boolean} is it ready
  16760. */
  16761. isReady(completeCheck?: boolean): boolean;
  16762. /**
  16763. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16764. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16765. * @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.
  16766. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16767. */
  16768. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16769. /**
  16770. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16771. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16772. * The `data` are either a numeric array either a Float32Array.
  16773. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16774. * 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).
  16775. * Note that a new underlying VertexBuffer object is created each call.
  16776. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16777. *
  16778. * Possible `kind` values :
  16779. * - VertexBuffer.PositionKind
  16780. * - VertexBuffer.UVKind
  16781. * - VertexBuffer.UV2Kind
  16782. * - VertexBuffer.UV3Kind
  16783. * - VertexBuffer.UV4Kind
  16784. * - VertexBuffer.UV5Kind
  16785. * - VertexBuffer.UV6Kind
  16786. * - VertexBuffer.ColorKind
  16787. * - VertexBuffer.MatricesIndicesKind
  16788. * - VertexBuffer.MatricesIndicesExtraKind
  16789. * - VertexBuffer.MatricesWeightsKind
  16790. * - VertexBuffer.MatricesWeightsExtraKind
  16791. *
  16792. * Returns the Mesh.
  16793. */
  16794. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16795. /**
  16796. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16797. * If the mesh has no geometry, it is simply returned as it is.
  16798. * The `data` are either a numeric array either a Float32Array.
  16799. * No new underlying VertexBuffer object is created.
  16800. * 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.
  16801. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16802. *
  16803. * Possible `kind` values :
  16804. * - VertexBuffer.PositionKind
  16805. * - VertexBuffer.UVKind
  16806. * - VertexBuffer.UV2Kind
  16807. * - VertexBuffer.UV3Kind
  16808. * - VertexBuffer.UV4Kind
  16809. * - VertexBuffer.UV5Kind
  16810. * - VertexBuffer.UV6Kind
  16811. * - VertexBuffer.ColorKind
  16812. * - VertexBuffer.MatricesIndicesKind
  16813. * - VertexBuffer.MatricesIndicesExtraKind
  16814. * - VertexBuffer.MatricesWeightsKind
  16815. * - VertexBuffer.MatricesWeightsExtraKind
  16816. *
  16817. * Returns the Mesh.
  16818. */
  16819. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16820. /**
  16821. * Sets the mesh indices.
  16822. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16823. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16824. * This method creates a new index buffer each call.
  16825. * Returns the Mesh.
  16826. */
  16827. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16828. /**
  16829. * Boolean : True if the mesh owns the requested kind of data.
  16830. */
  16831. isVerticesDataPresent(kind: string): boolean;
  16832. /**
  16833. * Returns an array of indices (IndicesArray).
  16834. */
  16835. getIndices(): Nullable<IndicesArray>;
  16836. readonly _positions: Nullable<Vector3[]>;
  16837. /**
  16838. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16839. * This means the mesh underlying bounding box and sphere are recomputed.
  16840. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16841. * @returns the current mesh
  16842. */
  16843. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16844. /** @hidden */
  16845. _preActivate(): InstancedMesh;
  16846. /** @hidden */
  16847. _activate(renderId: number): InstancedMesh;
  16848. /**
  16849. * Returns the current associated LOD AbstractMesh.
  16850. */
  16851. getLOD(camera: Camera): AbstractMesh;
  16852. /** @hidden */
  16853. _syncSubMeshes(): InstancedMesh;
  16854. /** @hidden */
  16855. _generatePointsArray(): boolean;
  16856. /**
  16857. * Creates a new InstancedMesh from the current mesh.
  16858. * - name (string) : the cloned mesh name
  16859. * - newParent (optional Node) : the optional Node to parent the clone to.
  16860. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16861. *
  16862. * Returns the clone.
  16863. */
  16864. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16865. /**
  16866. * Disposes the InstancedMesh.
  16867. * Returns nothing.
  16868. */
  16869. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16870. }
  16871. }
  16872. declare module "babylonjs/Materials/shaderMaterial" {
  16873. import { Scene } from "babylonjs/scene";
  16874. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  16875. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16876. import { Mesh } from "babylonjs/Meshes/mesh";
  16877. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16878. import { Texture } from "babylonjs/Materials/Textures/texture";
  16879. import { Material } from "babylonjs/Materials/material";
  16880. /**
  16881. * Defines the options associated with the creation of a shader material.
  16882. */
  16883. export interface IShaderMaterialOptions {
  16884. /**
  16885. * Does the material work in alpha blend mode
  16886. */
  16887. needAlphaBlending: boolean;
  16888. /**
  16889. * Does the material work in alpha test mode
  16890. */
  16891. needAlphaTesting: boolean;
  16892. /**
  16893. * The list of attribute names used in the shader
  16894. */
  16895. attributes: string[];
  16896. /**
  16897. * The list of unifrom names used in the shader
  16898. */
  16899. uniforms: string[];
  16900. /**
  16901. * The list of UBO names used in the shader
  16902. */
  16903. uniformBuffers: string[];
  16904. /**
  16905. * The list of sampler names used in the shader
  16906. */
  16907. samplers: string[];
  16908. /**
  16909. * The list of defines used in the shader
  16910. */
  16911. defines: string[];
  16912. }
  16913. /**
  16914. * 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.
  16915. *
  16916. * This returned material effects how the mesh will look based on the code in the shaders.
  16917. *
  16918. * @see http://doc.babylonjs.com/how_to/shader_material
  16919. */
  16920. export class ShaderMaterial extends Material {
  16921. private _shaderPath;
  16922. private _options;
  16923. private _textures;
  16924. private _textureArrays;
  16925. private _floats;
  16926. private _ints;
  16927. private _floatsArrays;
  16928. private _colors3;
  16929. private _colors3Arrays;
  16930. private _colors4;
  16931. private _vectors2;
  16932. private _vectors3;
  16933. private _vectors4;
  16934. private _matrices;
  16935. private _matrices3x3;
  16936. private _matrices2x2;
  16937. private _vectors2Arrays;
  16938. private _vectors3Arrays;
  16939. private _cachedWorldViewMatrix;
  16940. private _renderId;
  16941. /**
  16942. * Instantiate a new shader material.
  16943. * 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.
  16944. * This returned material effects how the mesh will look based on the code in the shaders.
  16945. * @see http://doc.babylonjs.com/how_to/shader_material
  16946. * @param name Define the name of the material in the scene
  16947. * @param scene Define the scene the material belongs to
  16948. * @param shaderPath Defines the route to the shader code in one of three ways:
  16949. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16950. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16951. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16952. * @param options Define the options used to create the shader
  16953. */
  16954. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16955. /**
  16956. * Gets the options used to compile the shader.
  16957. * They can be modified to trigger a new compilation
  16958. */
  16959. readonly options: IShaderMaterialOptions;
  16960. /**
  16961. * Gets the current class name of the material e.g. "ShaderMaterial"
  16962. * Mainly use in serialization.
  16963. * @returns the class name
  16964. */
  16965. getClassName(): string;
  16966. /**
  16967. * Specifies if the material will require alpha blending
  16968. * @returns a boolean specifying if alpha blending is needed
  16969. */
  16970. needAlphaBlending(): boolean;
  16971. /**
  16972. * Specifies if this material should be rendered in alpha test mode
  16973. * @returns a boolean specifying if an alpha test is needed.
  16974. */
  16975. needAlphaTesting(): boolean;
  16976. private _checkUniform;
  16977. /**
  16978. * Set a texture in the shader.
  16979. * @param name Define the name of the uniform samplers as defined in the shader
  16980. * @param texture Define the texture to bind to this sampler
  16981. * @return the material itself allowing "fluent" like uniform updates
  16982. */
  16983. setTexture(name: string, texture: Texture): ShaderMaterial;
  16984. /**
  16985. * Set a texture array in the shader.
  16986. * @param name Define the name of the uniform sampler array as defined in the shader
  16987. * @param textures Define the list of textures to bind to this sampler
  16988. * @return the material itself allowing "fluent" like uniform updates
  16989. */
  16990. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16991. /**
  16992. * Set a float in the shader.
  16993. * @param name Define the name of the uniform as defined in the shader
  16994. * @param value Define the value to give to the uniform
  16995. * @return the material itself allowing "fluent" like uniform updates
  16996. */
  16997. setFloat(name: string, value: number): ShaderMaterial;
  16998. /**
  16999. * Set a int in the shader.
  17000. * @param name Define the name of the uniform as defined in the shader
  17001. * @param value Define the value to give to the uniform
  17002. * @return the material itself allowing "fluent" like uniform updates
  17003. */
  17004. setInt(name: string, value: number): ShaderMaterial;
  17005. /**
  17006. * Set an array of floats in the shader.
  17007. * @param name Define the name of the uniform as defined in the shader
  17008. * @param value Define the value to give to the uniform
  17009. * @return the material itself allowing "fluent" like uniform updates
  17010. */
  17011. setFloats(name: string, value: number[]): ShaderMaterial;
  17012. /**
  17013. * Set a vec3 in the shader from a Color3.
  17014. * @param name Define the name of the uniform as defined in the shader
  17015. * @param value Define the value to give to the uniform
  17016. * @return the material itself allowing "fluent" like uniform updates
  17017. */
  17018. setColor3(name: string, value: Color3): ShaderMaterial;
  17019. /**
  17020. * Set a vec3 array in the shader from a Color3 array.
  17021. * @param name Define the name of the uniform as defined in the shader
  17022. * @param value Define the value to give to the uniform
  17023. * @return the material itself allowing "fluent" like uniform updates
  17024. */
  17025. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17026. /**
  17027. * Set a vec4 in the shader from a Color4.
  17028. * @param name Define the name of the uniform as defined in the shader
  17029. * @param value Define the value to give to the uniform
  17030. * @return the material itself allowing "fluent" like uniform updates
  17031. */
  17032. setColor4(name: string, value: Color4): ShaderMaterial;
  17033. /**
  17034. * Set a vec2 in the shader from a Vector2.
  17035. * @param name Define the name of the uniform as defined in the shader
  17036. * @param value Define the value to give to the uniform
  17037. * @return the material itself allowing "fluent" like uniform updates
  17038. */
  17039. setVector2(name: string, value: Vector2): ShaderMaterial;
  17040. /**
  17041. * Set a vec3 in the shader from a Vector3.
  17042. * @param name Define the name of the uniform as defined in the shader
  17043. * @param value Define the value to give to the uniform
  17044. * @return the material itself allowing "fluent" like uniform updates
  17045. */
  17046. setVector3(name: string, value: Vector3): ShaderMaterial;
  17047. /**
  17048. * Set a vec4 in the shader from a Vector4.
  17049. * @param name Define the name of the uniform as defined in the shader
  17050. * @param value Define the value to give to the uniform
  17051. * @return the material itself allowing "fluent" like uniform updates
  17052. */
  17053. setVector4(name: string, value: Vector4): ShaderMaterial;
  17054. /**
  17055. * Set a mat4 in the shader from a Matrix.
  17056. * @param name Define the name of the uniform as defined in the shader
  17057. * @param value Define the value to give to the uniform
  17058. * @return the material itself allowing "fluent" like uniform updates
  17059. */
  17060. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17061. /**
  17062. * Set a mat3 in the shader from a Float32Array.
  17063. * @param name Define the name of the uniform as defined in the shader
  17064. * @param value Define the value to give to the uniform
  17065. * @return the material itself allowing "fluent" like uniform updates
  17066. */
  17067. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17068. /**
  17069. * Set a mat2 in the shader from a Float32Array.
  17070. * @param name Define the name of the uniform as defined in the shader
  17071. * @param value Define the value to give to the uniform
  17072. * @return the material itself allowing "fluent" like uniform updates
  17073. */
  17074. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17075. /**
  17076. * Set a vec2 array in the shader from a number array.
  17077. * @param name Define the name of the uniform as defined in the shader
  17078. * @param value Define the value to give to the uniform
  17079. * @return the material itself allowing "fluent" like uniform updates
  17080. */
  17081. setArray2(name: string, value: number[]): ShaderMaterial;
  17082. /**
  17083. * Set a vec3 array in the shader from a number array.
  17084. * @param name Define the name of the uniform as defined in the shader
  17085. * @param value Define the value to give to the uniform
  17086. * @return the material itself allowing "fluent" like uniform updates
  17087. */
  17088. setArray3(name: string, value: number[]): ShaderMaterial;
  17089. private _checkCache;
  17090. /**
  17091. * Checks if the material is ready to render the requested mesh
  17092. * @param mesh Define the mesh to render
  17093. * @param useInstances Define whether or not the material is used with instances
  17094. * @returns true if ready, otherwise false
  17095. */
  17096. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17097. /**
  17098. * Binds the world matrix to the material
  17099. * @param world defines the world transformation matrix
  17100. */
  17101. bindOnlyWorldMatrix(world: Matrix): void;
  17102. /**
  17103. * Binds the material to the mesh
  17104. * @param world defines the world transformation matrix
  17105. * @param mesh defines the mesh to bind the material to
  17106. */
  17107. bind(world: Matrix, mesh?: Mesh): void;
  17108. /**
  17109. * Gets the active textures from the material
  17110. * @returns an array of textures
  17111. */
  17112. getActiveTextures(): BaseTexture[];
  17113. /**
  17114. * Specifies if the material uses a texture
  17115. * @param texture defines the texture to check against the material
  17116. * @returns a boolean specifying if the material uses the texture
  17117. */
  17118. hasTexture(texture: BaseTexture): boolean;
  17119. /**
  17120. * Makes a duplicate of the material, and gives it a new name
  17121. * @param name defines the new name for the duplicated material
  17122. * @returns the cloned material
  17123. */
  17124. clone(name: string): ShaderMaterial;
  17125. /**
  17126. * Disposes the material
  17127. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17128. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17129. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17130. */
  17131. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17132. /**
  17133. * Serializes this material in a JSON representation
  17134. * @returns the serialized material object
  17135. */
  17136. serialize(): any;
  17137. /**
  17138. * Creates a shader material from parsed shader material data
  17139. * @param source defines the JSON represnetation of the material
  17140. * @param scene defines the hosting scene
  17141. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17142. * @returns a new material
  17143. */
  17144. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17145. }
  17146. }
  17147. declare module "babylonjs/Shaders/color.fragment" {
  17148. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17149. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17150. /** @hidden */
  17151. export var colorPixelShader: {
  17152. name: string;
  17153. shader: string;
  17154. };
  17155. }
  17156. declare module "babylonjs/Shaders/color.vertex" {
  17157. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17158. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17159. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17160. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17161. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17162. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17163. /** @hidden */
  17164. export var colorVertexShader: {
  17165. name: string;
  17166. shader: string;
  17167. };
  17168. }
  17169. declare module "babylonjs/Meshes/linesMesh" {
  17170. import { Nullable } from "babylonjs/types";
  17171. import { Scene } from "babylonjs/scene";
  17172. import { Color3 } from "babylonjs/Maths/math";
  17173. import { Node } from "babylonjs/node";
  17174. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17175. import { Mesh } from "babylonjs/Meshes/mesh";
  17176. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17177. import { Effect } from "babylonjs/Materials/effect";
  17178. import { Material } from "babylonjs/Materials/material";
  17179. import "babylonjs/Shaders/color.fragment";
  17180. import "babylonjs/Shaders/color.vertex";
  17181. /**
  17182. * Line mesh
  17183. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17184. */
  17185. export class LinesMesh extends Mesh {
  17186. /**
  17187. * If vertex color should be applied to the mesh
  17188. */
  17189. useVertexColor?: boolean | undefined;
  17190. /**
  17191. * If vertex alpha should be applied to the mesh
  17192. */
  17193. useVertexAlpha?: boolean | undefined;
  17194. /**
  17195. * Color of the line (Default: White)
  17196. */
  17197. color: Color3;
  17198. /**
  17199. * Alpha of the line (Default: 1)
  17200. */
  17201. alpha: number;
  17202. /**
  17203. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17204. * This margin is expressed in world space coordinates, so its value may vary.
  17205. * Default value is 0.1
  17206. */
  17207. intersectionThreshold: number;
  17208. private _colorShader;
  17209. /**
  17210. * Creates a new LinesMesh
  17211. * @param name defines the name
  17212. * @param scene defines the hosting scene
  17213. * @param parent defines the parent mesh if any
  17214. * @param source defines the optional source LinesMesh used to clone data from
  17215. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17216. * When false, achieved by calling a clone(), also passing False.
  17217. * This will make creation of children, recursive.
  17218. * @param useVertexColor defines if this LinesMesh supports vertex color
  17219. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17220. */
  17221. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17222. /**
  17223. * If vertex color should be applied to the mesh
  17224. */
  17225. useVertexColor?: boolean | undefined,
  17226. /**
  17227. * If vertex alpha should be applied to the mesh
  17228. */
  17229. useVertexAlpha?: boolean | undefined);
  17230. private _addClipPlaneDefine;
  17231. private _removeClipPlaneDefine;
  17232. isReady(): boolean;
  17233. /**
  17234. * Returns the string "LineMesh"
  17235. */
  17236. getClassName(): string;
  17237. /**
  17238. * @hidden
  17239. */
  17240. /**
  17241. * @hidden
  17242. */
  17243. material: Material;
  17244. /**
  17245. * @hidden
  17246. */
  17247. readonly checkCollisions: boolean;
  17248. /** @hidden */
  17249. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17250. /** @hidden */
  17251. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17252. /**
  17253. * Disposes of the line mesh
  17254. * @param doNotRecurse If children should be disposed
  17255. */
  17256. dispose(doNotRecurse?: boolean): void;
  17257. /**
  17258. * Returns a new LineMesh object cloned from the current one.
  17259. */
  17260. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17261. /**
  17262. * Creates a new InstancedLinesMesh object from the mesh model.
  17263. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17264. * @param name defines the name of the new instance
  17265. * @returns a new InstancedLinesMesh
  17266. */
  17267. createInstance(name: string): InstancedLinesMesh;
  17268. }
  17269. /**
  17270. * Creates an instance based on a source LinesMesh
  17271. */
  17272. export class InstancedLinesMesh extends InstancedMesh {
  17273. /**
  17274. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17275. * This margin is expressed in world space coordinates, so its value may vary.
  17276. * Initilized with the intersectionThreshold value of the source LinesMesh
  17277. */
  17278. intersectionThreshold: number;
  17279. constructor(name: string, source: LinesMesh);
  17280. /**
  17281. * Returns the string "InstancedLinesMesh".
  17282. */
  17283. getClassName(): string;
  17284. }
  17285. }
  17286. declare module "babylonjs/Shaders/line.fragment" {
  17287. /** @hidden */
  17288. export var linePixelShader: {
  17289. name: string;
  17290. shader: string;
  17291. };
  17292. }
  17293. declare module "babylonjs/Shaders/line.vertex" {
  17294. /** @hidden */
  17295. export var lineVertexShader: {
  17296. name: string;
  17297. shader: string;
  17298. };
  17299. }
  17300. declare module "babylonjs/Rendering/edgesRenderer" {
  17301. import { Nullable } from "babylonjs/types";
  17302. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17303. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17304. import { Vector3 } from "babylonjs/Maths/math";
  17305. import { IDisposable } from "babylonjs/scene";
  17306. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17307. import "babylonjs/Shaders/line.fragment";
  17308. import "babylonjs/Shaders/line.vertex";
  17309. module "babylonjs/Meshes/abstractMesh" {
  17310. interface AbstractMesh {
  17311. /**
  17312. * Disables the mesh edge rendering mode
  17313. * @returns the currentAbstractMesh
  17314. */
  17315. disableEdgesRendering(): AbstractMesh;
  17316. /**
  17317. * Enables the edge rendering mode on the mesh.
  17318. * This mode makes the mesh edges visible
  17319. * @param epsilon defines the maximal distance between two angles to detect a face
  17320. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17321. * @returns the currentAbstractMesh
  17322. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17323. */
  17324. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17325. /**
  17326. * Gets the edgesRenderer associated with the mesh
  17327. */
  17328. edgesRenderer: Nullable<EdgesRenderer>;
  17329. }
  17330. }
  17331. module "babylonjs/Meshes/linesMesh" {
  17332. interface LinesMesh {
  17333. /**
  17334. * Enables the edge rendering mode on the mesh.
  17335. * This mode makes the mesh edges visible
  17336. * @param epsilon defines the maximal distance between two angles to detect a face
  17337. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17338. * @returns the currentAbstractMesh
  17339. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17340. */
  17341. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17342. }
  17343. }
  17344. module "babylonjs/Meshes/linesMesh" {
  17345. interface InstancedLinesMesh {
  17346. /**
  17347. * Enables the edge rendering mode on the mesh.
  17348. * This mode makes the mesh edges visible
  17349. * @param epsilon defines the maximal distance between two angles to detect a face
  17350. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17351. * @returns the current InstancedLinesMesh
  17352. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17353. */
  17354. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17355. }
  17356. }
  17357. /**
  17358. * Defines the minimum contract an Edges renderer should follow.
  17359. */
  17360. export interface IEdgesRenderer extends IDisposable {
  17361. /**
  17362. * Gets or sets a boolean indicating if the edgesRenderer is active
  17363. */
  17364. isEnabled: boolean;
  17365. /**
  17366. * Renders the edges of the attached mesh,
  17367. */
  17368. render(): void;
  17369. /**
  17370. * Checks wether or not the edges renderer is ready to render.
  17371. * @return true if ready, otherwise false.
  17372. */
  17373. isReady(): boolean;
  17374. }
  17375. /**
  17376. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17377. */
  17378. export class EdgesRenderer implements IEdgesRenderer {
  17379. /**
  17380. * Define the size of the edges with an orthographic camera
  17381. */
  17382. edgesWidthScalerForOrthographic: number;
  17383. /**
  17384. * Define the size of the edges with a perspective camera
  17385. */
  17386. edgesWidthScalerForPerspective: number;
  17387. protected _source: AbstractMesh;
  17388. protected _linesPositions: number[];
  17389. protected _linesNormals: number[];
  17390. protected _linesIndices: number[];
  17391. protected _epsilon: number;
  17392. protected _indicesCount: number;
  17393. protected _lineShader: ShaderMaterial;
  17394. protected _ib: WebGLBuffer;
  17395. protected _buffers: {
  17396. [key: string]: Nullable<VertexBuffer>;
  17397. };
  17398. protected _checkVerticesInsteadOfIndices: boolean;
  17399. private _meshRebuildObserver;
  17400. private _meshDisposeObserver;
  17401. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17402. isEnabled: boolean;
  17403. /**
  17404. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17405. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17406. * @param source Mesh used to create edges
  17407. * @param epsilon sum of angles in adjacency to check for edge
  17408. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17409. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17410. */
  17411. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17412. protected _prepareRessources(): void;
  17413. /** @hidden */
  17414. _rebuild(): void;
  17415. /**
  17416. * Releases the required resources for the edges renderer
  17417. */
  17418. dispose(): void;
  17419. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17420. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17421. /**
  17422. * Checks if the pair of p0 and p1 is en edge
  17423. * @param faceIndex
  17424. * @param edge
  17425. * @param faceNormals
  17426. * @param p0
  17427. * @param p1
  17428. * @private
  17429. */
  17430. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17431. /**
  17432. * push line into the position, normal and index buffer
  17433. * @protected
  17434. */
  17435. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17436. /**
  17437. * Generates lines edges from adjacencjes
  17438. * @private
  17439. */
  17440. _generateEdgesLines(): void;
  17441. /**
  17442. * Checks wether or not the edges renderer is ready to render.
  17443. * @return true if ready, otherwise false.
  17444. */
  17445. isReady(): boolean;
  17446. /**
  17447. * Renders the edges of the attached mesh,
  17448. */
  17449. render(): void;
  17450. }
  17451. /**
  17452. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17453. */
  17454. export class LineEdgesRenderer extends EdgesRenderer {
  17455. /**
  17456. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17457. * @param source LineMesh used to generate edges
  17458. * @param epsilon not important (specified angle for edge detection)
  17459. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17460. */
  17461. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17462. /**
  17463. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17464. */
  17465. _generateEdgesLines(): void;
  17466. }
  17467. }
  17468. declare module "babylonjs/Rendering/renderingGroup" {
  17469. import { SmartArray } from "babylonjs/Misc/smartArray";
  17470. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17471. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17472. import { Nullable } from "babylonjs/types";
  17473. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17474. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17475. import { Material } from "babylonjs/Materials/material";
  17476. import { Scene } from "babylonjs/scene";
  17477. /**
  17478. * This represents the object necessary to create a rendering group.
  17479. * This is exclusively used and created by the rendering manager.
  17480. * To modify the behavior, you use the available helpers in your scene or meshes.
  17481. * @hidden
  17482. */
  17483. export class RenderingGroup {
  17484. index: number;
  17485. private _scene;
  17486. private _opaqueSubMeshes;
  17487. private _transparentSubMeshes;
  17488. private _alphaTestSubMeshes;
  17489. private _depthOnlySubMeshes;
  17490. private _particleSystems;
  17491. private _spriteManagers;
  17492. private _opaqueSortCompareFn;
  17493. private _alphaTestSortCompareFn;
  17494. private _transparentSortCompareFn;
  17495. private _renderOpaque;
  17496. private _renderAlphaTest;
  17497. private _renderTransparent;
  17498. private _edgesRenderers;
  17499. onBeforeTransparentRendering: () => void;
  17500. /**
  17501. * Set the opaque sort comparison function.
  17502. * If null the sub meshes will be render in the order they were created
  17503. */
  17504. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17505. /**
  17506. * Set the alpha test sort comparison function.
  17507. * If null the sub meshes will be render in the order they were created
  17508. */
  17509. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17510. /**
  17511. * Set the transparent sort comparison function.
  17512. * If null the sub meshes will be render in the order they were created
  17513. */
  17514. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17515. /**
  17516. * Creates a new rendering group.
  17517. * @param index The rendering group index
  17518. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17519. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17520. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17521. */
  17522. 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>);
  17523. /**
  17524. * Render all the sub meshes contained in the group.
  17525. * @param customRenderFunction Used to override the default render behaviour of the group.
  17526. * @returns true if rendered some submeshes.
  17527. */
  17528. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17529. /**
  17530. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17531. * @param subMeshes The submeshes to render
  17532. */
  17533. private renderOpaqueSorted;
  17534. /**
  17535. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17536. * @param subMeshes The submeshes to render
  17537. */
  17538. private renderAlphaTestSorted;
  17539. /**
  17540. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17541. * @param subMeshes The submeshes to render
  17542. */
  17543. private renderTransparentSorted;
  17544. /**
  17545. * Renders the submeshes in a specified order.
  17546. * @param subMeshes The submeshes to sort before render
  17547. * @param sortCompareFn The comparison function use to sort
  17548. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17549. * @param transparent Specifies to activate blending if true
  17550. */
  17551. private static renderSorted;
  17552. /**
  17553. * Renders the submeshes in the order they were dispatched (no sort applied).
  17554. * @param subMeshes The submeshes to render
  17555. */
  17556. private static renderUnsorted;
  17557. /**
  17558. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17559. * are rendered back to front if in the same alpha index.
  17560. *
  17561. * @param a The first submesh
  17562. * @param b The second submesh
  17563. * @returns The result of the comparison
  17564. */
  17565. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17566. /**
  17567. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17568. * are rendered back to front.
  17569. *
  17570. * @param a The first submesh
  17571. * @param b The second submesh
  17572. * @returns The result of the comparison
  17573. */
  17574. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17575. /**
  17576. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17577. * are rendered front to back (prevent overdraw).
  17578. *
  17579. * @param a The first submesh
  17580. * @param b The second submesh
  17581. * @returns The result of the comparison
  17582. */
  17583. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17584. /**
  17585. * Resets the different lists of submeshes to prepare a new frame.
  17586. */
  17587. prepare(): void;
  17588. dispose(): void;
  17589. /**
  17590. * Inserts the submesh in its correct queue depending on its material.
  17591. * @param subMesh The submesh to dispatch
  17592. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17593. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17594. */
  17595. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17596. dispatchSprites(spriteManager: ISpriteManager): void;
  17597. dispatchParticles(particleSystem: IParticleSystem): void;
  17598. private _renderParticles;
  17599. private _renderSprites;
  17600. }
  17601. }
  17602. declare module "babylonjs/Rendering/renderingManager" {
  17603. import { Nullable } from "babylonjs/types";
  17604. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17605. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17606. import { SmartArray } from "babylonjs/Misc/smartArray";
  17607. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17608. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17609. import { Material } from "babylonjs/Materials/material";
  17610. import { Scene } from "babylonjs/scene";
  17611. import { Camera } from "babylonjs/Cameras/camera";
  17612. /**
  17613. * Interface describing the different options available in the rendering manager
  17614. * regarding Auto Clear between groups.
  17615. */
  17616. export interface IRenderingManagerAutoClearSetup {
  17617. /**
  17618. * Defines whether or not autoclear is enable.
  17619. */
  17620. autoClear: boolean;
  17621. /**
  17622. * Defines whether or not to autoclear the depth buffer.
  17623. */
  17624. depth: boolean;
  17625. /**
  17626. * Defines whether or not to autoclear the stencil buffer.
  17627. */
  17628. stencil: boolean;
  17629. }
  17630. /**
  17631. * This class is used by the onRenderingGroupObservable
  17632. */
  17633. export class RenderingGroupInfo {
  17634. /**
  17635. * The Scene that being rendered
  17636. */
  17637. scene: Scene;
  17638. /**
  17639. * The camera currently used for the rendering pass
  17640. */
  17641. camera: Nullable<Camera>;
  17642. /**
  17643. * The ID of the renderingGroup being processed
  17644. */
  17645. renderingGroupId: number;
  17646. }
  17647. /**
  17648. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17649. * It is enable to manage the different groups as well as the different necessary sort functions.
  17650. * This should not be used directly aside of the few static configurations
  17651. */
  17652. export class RenderingManager {
  17653. /**
  17654. * The max id used for rendering groups (not included)
  17655. */
  17656. static MAX_RENDERINGGROUPS: number;
  17657. /**
  17658. * The min id used for rendering groups (included)
  17659. */
  17660. static MIN_RENDERINGGROUPS: number;
  17661. /**
  17662. * Used to globally prevent autoclearing scenes.
  17663. */
  17664. static AUTOCLEAR: boolean;
  17665. /**
  17666. * @hidden
  17667. */
  17668. _useSceneAutoClearSetup: boolean;
  17669. private _scene;
  17670. private _renderingGroups;
  17671. private _depthStencilBufferAlreadyCleaned;
  17672. private _autoClearDepthStencil;
  17673. private _customOpaqueSortCompareFn;
  17674. private _customAlphaTestSortCompareFn;
  17675. private _customTransparentSortCompareFn;
  17676. private _renderingGroupInfo;
  17677. /**
  17678. * Instantiates a new rendering group for a particular scene
  17679. * @param scene Defines the scene the groups belongs to
  17680. */
  17681. constructor(scene: Scene);
  17682. private _clearDepthStencilBuffer;
  17683. /**
  17684. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17685. * @hidden
  17686. */
  17687. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17688. /**
  17689. * Resets the different information of the group to prepare a new frame
  17690. * @hidden
  17691. */
  17692. reset(): void;
  17693. /**
  17694. * Dispose and release the group and its associated resources.
  17695. * @hidden
  17696. */
  17697. dispose(): void;
  17698. /**
  17699. * Clear the info related to rendering groups preventing retention points during dispose.
  17700. */
  17701. freeRenderingGroups(): void;
  17702. private _prepareRenderingGroup;
  17703. /**
  17704. * Add a sprite manager to the rendering manager in order to render it this frame.
  17705. * @param spriteManager Define the sprite manager to render
  17706. */
  17707. dispatchSprites(spriteManager: ISpriteManager): void;
  17708. /**
  17709. * Add a particle system to the rendering manager in order to render it this frame.
  17710. * @param particleSystem Define the particle system to render
  17711. */
  17712. dispatchParticles(particleSystem: IParticleSystem): void;
  17713. /**
  17714. * Add a submesh to the manager in order to render it this frame
  17715. * @param subMesh The submesh to dispatch
  17716. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17717. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17718. */
  17719. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17720. /**
  17721. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17722. * This allowed control for front to back rendering or reversly depending of the special needs.
  17723. *
  17724. * @param renderingGroupId The rendering group id corresponding to its index
  17725. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17726. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17727. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17728. */
  17729. 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;
  17730. /**
  17731. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17732. *
  17733. * @param renderingGroupId The rendering group id corresponding to its index
  17734. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17735. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17736. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17737. */
  17738. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17739. /**
  17740. * Gets the current auto clear configuration for one rendering group of the rendering
  17741. * manager.
  17742. * @param index the rendering group index to get the information for
  17743. * @returns The auto clear setup for the requested rendering group
  17744. */
  17745. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17746. }
  17747. }
  17748. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  17749. import { Observable } from "babylonjs/Misc/observable";
  17750. import { SmartArray } from "babylonjs/Misc/smartArray";
  17751. import { Nullable } from "babylonjs/types";
  17752. import { Camera } from "babylonjs/Cameras/camera";
  17753. import { Scene } from "babylonjs/scene";
  17754. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  17755. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  17756. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17757. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17758. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17759. import { Texture } from "babylonjs/Materials/Textures/texture";
  17760. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17761. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  17762. import { Engine } from "babylonjs/Engines/engine";
  17763. /**
  17764. * This Helps creating a texture that will be created from a camera in your scene.
  17765. * It is basically a dynamic texture that could be used to create special effects for instance.
  17766. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17767. */
  17768. export class RenderTargetTexture extends Texture {
  17769. isCube: boolean;
  17770. /**
  17771. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17772. */
  17773. static readonly REFRESHRATE_RENDER_ONCE: number;
  17774. /**
  17775. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17776. */
  17777. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17778. /**
  17779. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17780. * the central point of your effect and can save a lot of performances.
  17781. */
  17782. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17783. /**
  17784. * Use this predicate to dynamically define the list of mesh you want to render.
  17785. * If set, the renderList property will be overwritten.
  17786. */
  17787. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17788. private _renderList;
  17789. /**
  17790. * Use this list to define the list of mesh you want to render.
  17791. */
  17792. renderList: Nullable<Array<AbstractMesh>>;
  17793. private _hookArray;
  17794. /**
  17795. * Define if particles should be rendered in your texture.
  17796. */
  17797. renderParticles: boolean;
  17798. /**
  17799. * Define if sprites should be rendered in your texture.
  17800. */
  17801. renderSprites: boolean;
  17802. /**
  17803. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17804. */
  17805. coordinatesMode: number;
  17806. /**
  17807. * Define the camera used to render the texture.
  17808. */
  17809. activeCamera: Nullable<Camera>;
  17810. /**
  17811. * Override the render function of the texture with your own one.
  17812. */
  17813. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17814. /**
  17815. * Define if camera post processes should be use while rendering the texture.
  17816. */
  17817. useCameraPostProcesses: boolean;
  17818. /**
  17819. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17820. */
  17821. ignoreCameraViewport: boolean;
  17822. private _postProcessManager;
  17823. private _postProcesses;
  17824. private _resizeObserver;
  17825. /**
  17826. * An event triggered when the texture is unbind.
  17827. */
  17828. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17829. /**
  17830. * An event triggered when the texture is unbind.
  17831. */
  17832. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17833. private _onAfterUnbindObserver;
  17834. /**
  17835. * Set a after unbind callback in the texture.
  17836. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17837. */
  17838. onAfterUnbind: () => void;
  17839. /**
  17840. * An event triggered before rendering the texture
  17841. */
  17842. onBeforeRenderObservable: Observable<number>;
  17843. private _onBeforeRenderObserver;
  17844. /**
  17845. * Set a before render callback in the texture.
  17846. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17847. */
  17848. onBeforeRender: (faceIndex: number) => void;
  17849. /**
  17850. * An event triggered after rendering the texture
  17851. */
  17852. onAfterRenderObservable: Observable<number>;
  17853. private _onAfterRenderObserver;
  17854. /**
  17855. * Set a after render callback in the texture.
  17856. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17857. */
  17858. onAfterRender: (faceIndex: number) => void;
  17859. /**
  17860. * An event triggered after the texture clear
  17861. */
  17862. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  17863. private _onClearObserver;
  17864. /**
  17865. * Set a clear callback in the texture.
  17866. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17867. */
  17868. onClear: (Engine: Engine) => void;
  17869. /**
  17870. * Define the clear color of the Render Target if it should be different from the scene.
  17871. */
  17872. clearColor: Color4;
  17873. protected _size: number | {
  17874. width: number;
  17875. height: number;
  17876. };
  17877. protected _initialSizeParameter: number | {
  17878. width: number;
  17879. height: number;
  17880. } | {
  17881. ratio: number;
  17882. };
  17883. protected _sizeRatio: Nullable<number>;
  17884. /** @hidden */
  17885. _generateMipMaps: boolean;
  17886. protected _renderingManager: RenderingManager;
  17887. /** @hidden */
  17888. _waitingRenderList: string[];
  17889. protected _doNotChangeAspectRatio: boolean;
  17890. protected _currentRefreshId: number;
  17891. protected _refreshRate: number;
  17892. protected _textureMatrix: Matrix;
  17893. protected _samples: number;
  17894. protected _renderTargetOptions: RenderTargetCreationOptions;
  17895. /**
  17896. * Gets render target creation options that were used.
  17897. */
  17898. readonly renderTargetOptions: RenderTargetCreationOptions;
  17899. protected _engine: Engine;
  17900. protected _onRatioRescale(): void;
  17901. /**
  17902. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17903. * It must define where the camera used to render the texture is set
  17904. */
  17905. boundingBoxPosition: Vector3;
  17906. private _boundingBoxSize;
  17907. /**
  17908. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17909. * When defined, the cubemap will switch to local mode
  17910. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17911. * @example https://www.babylonjs-playground.com/#RNASML
  17912. */
  17913. boundingBoxSize: Vector3;
  17914. /**
  17915. * In case the RTT has been created with a depth texture, get the associated
  17916. * depth texture.
  17917. * Otherwise, return null.
  17918. */
  17919. depthStencilTexture: Nullable<InternalTexture>;
  17920. /**
  17921. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17922. * or used a shadow, depth texture...
  17923. * @param name The friendly name of the texture
  17924. * @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)
  17925. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17926. * @param generateMipMaps True if mip maps need to be generated after render.
  17927. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17928. * @param type The type of the buffer in the RTT (int, half float, float...)
  17929. * @param isCube True if a cube texture needs to be created
  17930. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17931. * @param generateDepthBuffer True to generate a depth buffer
  17932. * @param generateStencilBuffer True to generate a stencil buffer
  17933. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17934. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17935. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17936. */
  17937. constructor(name: string, size: number | {
  17938. width: number;
  17939. height: number;
  17940. } | {
  17941. ratio: number;
  17942. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17943. /**
  17944. * Creates a depth stencil texture.
  17945. * This is only available in WebGL 2 or with the depth texture extension available.
  17946. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17947. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17948. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17949. */
  17950. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17951. private _processSizeParameter;
  17952. /**
  17953. * Define the number of samples to use in case of MSAA.
  17954. * It defaults to one meaning no MSAA has been enabled.
  17955. */
  17956. samples: number;
  17957. /**
  17958. * Resets the refresh counter of the texture and start bak from scratch.
  17959. * Could be useful to regenerate the texture if it is setup to render only once.
  17960. */
  17961. resetRefreshCounter(): void;
  17962. /**
  17963. * Define the refresh rate of the texture or the rendering frequency.
  17964. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17965. */
  17966. refreshRate: number;
  17967. /**
  17968. * Adds a post process to the render target rendering passes.
  17969. * @param postProcess define the post process to add
  17970. */
  17971. addPostProcess(postProcess: PostProcess): void;
  17972. /**
  17973. * Clear all the post processes attached to the render target
  17974. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17975. */
  17976. clearPostProcesses(dispose?: boolean): void;
  17977. /**
  17978. * Remove one of the post process from the list of attached post processes to the texture
  17979. * @param postProcess define the post process to remove from the list
  17980. */
  17981. removePostProcess(postProcess: PostProcess): void;
  17982. /** @hidden */
  17983. _shouldRender(): boolean;
  17984. /**
  17985. * Gets the actual render size of the texture.
  17986. * @returns the width of the render size
  17987. */
  17988. getRenderSize(): number;
  17989. /**
  17990. * Gets the actual render width of the texture.
  17991. * @returns the width of the render size
  17992. */
  17993. getRenderWidth(): number;
  17994. /**
  17995. * Gets the actual render height of the texture.
  17996. * @returns the height of the render size
  17997. */
  17998. getRenderHeight(): number;
  17999. /**
  18000. * Get if the texture can be rescaled or not.
  18001. */
  18002. readonly canRescale: boolean;
  18003. /**
  18004. * Resize the texture using a ratio.
  18005. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  18006. */
  18007. scale(ratio: number): void;
  18008. /**
  18009. * Get the texture reflection matrix used to rotate/transform the reflection.
  18010. * @returns the reflection matrix
  18011. */
  18012. getReflectionTextureMatrix(): Matrix;
  18013. /**
  18014. * Resize the texture to a new desired size.
  18015. * Be carrefull as it will recreate all the data in the new texture.
  18016. * @param size Define the new size. It can be:
  18017. * - a number for squared texture,
  18018. * - an object containing { width: number, height: number }
  18019. * - or an object containing a ratio { ratio: number }
  18020. */
  18021. resize(size: number | {
  18022. width: number;
  18023. height: number;
  18024. } | {
  18025. ratio: number;
  18026. }): void;
  18027. /**
  18028. * Renders all the objects from the render list into the texture.
  18029. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  18030. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  18031. */
  18032. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  18033. private _bestReflectionRenderTargetDimension;
  18034. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18035. private renderToTarget;
  18036. /**
  18037. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18038. * This allowed control for front to back rendering or reversly depending of the special needs.
  18039. *
  18040. * @param renderingGroupId The rendering group id corresponding to its index
  18041. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18042. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18043. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18044. */
  18045. 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;
  18046. /**
  18047. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18048. *
  18049. * @param renderingGroupId The rendering group id corresponding to its index
  18050. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18051. */
  18052. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  18053. /**
  18054. * Clones the texture.
  18055. * @returns the cloned texture
  18056. */
  18057. clone(): RenderTargetTexture;
  18058. /**
  18059. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18060. * @returns The JSON representation of the texture
  18061. */
  18062. serialize(): any;
  18063. /**
  18064. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  18065. */
  18066. disposeFramebufferObjects(): void;
  18067. /**
  18068. * Dispose the texture and release its associated resources.
  18069. */
  18070. dispose(): void;
  18071. /** @hidden */
  18072. _rebuild(): void;
  18073. /**
  18074. * Clear the info related to rendering groups preventing retention point in material dispose.
  18075. */
  18076. freeRenderingGroups(): void;
  18077. }
  18078. }
  18079. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18080. import { Scene } from "babylonjs/scene";
  18081. import { Plane } from "babylonjs/Maths/math";
  18082. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18083. /**
  18084. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18085. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18086. * You can then easily use it as a reflectionTexture on a flat surface.
  18087. * In case the surface is not a plane, please consider relying on reflection probes.
  18088. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18089. */
  18090. export class MirrorTexture extends RenderTargetTexture {
  18091. private scene;
  18092. /**
  18093. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18094. * 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.
  18095. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18096. */
  18097. mirrorPlane: Plane;
  18098. /**
  18099. * Define the blur ratio used to blur the reflection if needed.
  18100. */
  18101. blurRatio: number;
  18102. /**
  18103. * Define the adaptive blur kernel used to blur the reflection if needed.
  18104. * This will autocompute the closest best match for the `blurKernel`
  18105. */
  18106. adaptiveBlurKernel: number;
  18107. /**
  18108. * Define the blur kernel used to blur the reflection if needed.
  18109. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18110. */
  18111. blurKernel: number;
  18112. /**
  18113. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18114. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18115. */
  18116. blurKernelX: number;
  18117. /**
  18118. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18119. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18120. */
  18121. blurKernelY: number;
  18122. private _autoComputeBlurKernel;
  18123. protected _onRatioRescale(): void;
  18124. private _updateGammaSpace;
  18125. private _imageProcessingConfigChangeObserver;
  18126. private _transformMatrix;
  18127. private _mirrorMatrix;
  18128. private _savedViewMatrix;
  18129. private _blurX;
  18130. private _blurY;
  18131. private _adaptiveBlurKernel;
  18132. private _blurKernelX;
  18133. private _blurKernelY;
  18134. private _blurRatio;
  18135. /**
  18136. * Instantiates a Mirror Texture.
  18137. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18138. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18139. * You can then easily use it as a reflectionTexture on a flat surface.
  18140. * In case the surface is not a plane, please consider relying on reflection probes.
  18141. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18142. * @param name
  18143. * @param size
  18144. * @param scene
  18145. * @param generateMipMaps
  18146. * @param type
  18147. * @param samplingMode
  18148. * @param generateDepthBuffer
  18149. */
  18150. constructor(name: string, size: number | {
  18151. width: number;
  18152. height: number;
  18153. } | {
  18154. ratio: number;
  18155. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18156. private _preparePostProcesses;
  18157. /**
  18158. * Clone the mirror texture.
  18159. * @returns the cloned texture
  18160. */
  18161. clone(): MirrorTexture;
  18162. /**
  18163. * Serialize the texture to a JSON representation you could use in Parse later on
  18164. * @returns the serialized JSON representation
  18165. */
  18166. serialize(): any;
  18167. /**
  18168. * Dispose the texture and release its associated resources.
  18169. */
  18170. dispose(): void;
  18171. }
  18172. }
  18173. declare module "babylonjs/Materials/Textures/texture" {
  18174. import { Observable } from "babylonjs/Misc/observable";
  18175. import { Nullable } from "babylonjs/types";
  18176. import { Scene } from "babylonjs/scene";
  18177. import { Matrix } from "babylonjs/Maths/math";
  18178. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18179. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18180. /**
  18181. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18182. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18183. */
  18184. export class Texture extends BaseTexture {
  18185. /** @hidden */
  18186. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18187. /** @hidden */
  18188. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18189. /** @hidden */
  18190. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18191. /** nearest is mag = nearest and min = nearest and mip = linear */
  18192. static readonly NEAREST_SAMPLINGMODE: number;
  18193. /** nearest is mag = nearest and min = nearest and mip = linear */
  18194. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18195. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18196. static readonly BILINEAR_SAMPLINGMODE: number;
  18197. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18198. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18199. /** Trilinear is mag = linear and min = linear and mip = linear */
  18200. static readonly TRILINEAR_SAMPLINGMODE: number;
  18201. /** Trilinear is mag = linear and min = linear and mip = linear */
  18202. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18203. /** mag = nearest and min = nearest and mip = nearest */
  18204. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18205. /** mag = nearest and min = linear and mip = nearest */
  18206. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18207. /** mag = nearest and min = linear and mip = linear */
  18208. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18209. /** mag = nearest and min = linear and mip = none */
  18210. static readonly NEAREST_LINEAR: number;
  18211. /** mag = nearest and min = nearest and mip = none */
  18212. static readonly NEAREST_NEAREST: number;
  18213. /** mag = linear and min = nearest and mip = nearest */
  18214. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18215. /** mag = linear and min = nearest and mip = linear */
  18216. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18217. /** mag = linear and min = linear and mip = none */
  18218. static readonly LINEAR_LINEAR: number;
  18219. /** mag = linear and min = nearest and mip = none */
  18220. static readonly LINEAR_NEAREST: number;
  18221. /** Explicit coordinates mode */
  18222. static readonly EXPLICIT_MODE: number;
  18223. /** Spherical coordinates mode */
  18224. static readonly SPHERICAL_MODE: number;
  18225. /** Planar coordinates mode */
  18226. static readonly PLANAR_MODE: number;
  18227. /** Cubic coordinates mode */
  18228. static readonly CUBIC_MODE: number;
  18229. /** Projection coordinates mode */
  18230. static readonly PROJECTION_MODE: number;
  18231. /** Inverse Cubic coordinates mode */
  18232. static readonly SKYBOX_MODE: number;
  18233. /** Inverse Cubic coordinates mode */
  18234. static readonly INVCUBIC_MODE: number;
  18235. /** Equirectangular coordinates mode */
  18236. static readonly EQUIRECTANGULAR_MODE: number;
  18237. /** Equirectangular Fixed coordinates mode */
  18238. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18239. /** Equirectangular Fixed Mirrored coordinates mode */
  18240. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18241. /** Texture is not repeating outside of 0..1 UVs */
  18242. static readonly CLAMP_ADDRESSMODE: number;
  18243. /** Texture is repeating outside of 0..1 UVs */
  18244. static readonly WRAP_ADDRESSMODE: number;
  18245. /** Texture is repeating and mirrored */
  18246. static readonly MIRROR_ADDRESSMODE: number;
  18247. /**
  18248. * 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
  18249. */
  18250. static UseSerializedUrlIfAny: boolean;
  18251. /**
  18252. * Define the url of the texture.
  18253. */
  18254. url: Nullable<string>;
  18255. /**
  18256. * Define an offset on the texture to offset the u coordinates of the UVs
  18257. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18258. */
  18259. uOffset: number;
  18260. /**
  18261. * Define an offset on the texture to offset the v coordinates of the UVs
  18262. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18263. */
  18264. vOffset: number;
  18265. /**
  18266. * Define an offset on the texture to scale the u coordinates of the UVs
  18267. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18268. */
  18269. uScale: number;
  18270. /**
  18271. * Define an offset on the texture to scale the v coordinates of the UVs
  18272. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18273. */
  18274. vScale: number;
  18275. /**
  18276. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18277. * @see http://doc.babylonjs.com/how_to/more_materials
  18278. */
  18279. uAng: number;
  18280. /**
  18281. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18282. * @see http://doc.babylonjs.com/how_to/more_materials
  18283. */
  18284. vAng: number;
  18285. /**
  18286. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18287. * @see http://doc.babylonjs.com/how_to/more_materials
  18288. */
  18289. wAng: number;
  18290. /**
  18291. * Defines the center of rotation (U)
  18292. */
  18293. uRotationCenter: number;
  18294. /**
  18295. * Defines the center of rotation (V)
  18296. */
  18297. vRotationCenter: number;
  18298. /**
  18299. * Defines the center of rotation (W)
  18300. */
  18301. wRotationCenter: number;
  18302. /**
  18303. * Are mip maps generated for this texture or not.
  18304. */
  18305. readonly noMipmap: boolean;
  18306. /**
  18307. * List of inspectable custom properties (used by the Inspector)
  18308. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18309. */
  18310. inspectableCustomProperties: IInspectable[];
  18311. private _noMipmap;
  18312. /** @hidden */
  18313. _invertY: boolean;
  18314. private _rowGenerationMatrix;
  18315. private _cachedTextureMatrix;
  18316. private _projectionModeMatrix;
  18317. private _t0;
  18318. private _t1;
  18319. private _t2;
  18320. private _cachedUOffset;
  18321. private _cachedVOffset;
  18322. private _cachedUScale;
  18323. private _cachedVScale;
  18324. private _cachedUAng;
  18325. private _cachedVAng;
  18326. private _cachedWAng;
  18327. private _cachedProjectionMatrixId;
  18328. private _cachedCoordinatesMode;
  18329. /** @hidden */
  18330. protected _initialSamplingMode: number;
  18331. /** @hidden */
  18332. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18333. private _deleteBuffer;
  18334. protected _format: Nullable<number>;
  18335. private _delayedOnLoad;
  18336. private _delayedOnError;
  18337. /**
  18338. * Observable triggered once the texture has been loaded.
  18339. */
  18340. onLoadObservable: Observable<Texture>;
  18341. protected _isBlocking: boolean;
  18342. /**
  18343. * Is the texture preventing material to render while loading.
  18344. * If false, a default texture will be used instead of the loading one during the preparation step.
  18345. */
  18346. isBlocking: boolean;
  18347. /**
  18348. * Get the current sampling mode associated with the texture.
  18349. */
  18350. readonly samplingMode: number;
  18351. /**
  18352. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18353. */
  18354. readonly invertY: boolean;
  18355. /**
  18356. * Instantiates a new texture.
  18357. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18358. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18359. * @param url define the url of the picture to load as a texture
  18360. * @param scene define the scene the texture will belong to
  18361. * @param noMipmap define if the texture will require mip maps or not
  18362. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18363. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18364. * @param onLoad define a callback triggered when the texture has been loaded
  18365. * @param onError define a callback triggered when an error occurred during the loading session
  18366. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18367. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18368. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18369. */
  18370. 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);
  18371. /**
  18372. * Update the url (and optional buffer) of this texture if url was null during construction.
  18373. * @param url the url of the texture
  18374. * @param buffer the buffer of the texture (defaults to null)
  18375. * @param onLoad callback called when the texture is loaded (defaults to null)
  18376. */
  18377. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18378. /**
  18379. * Finish the loading sequence of a texture flagged as delayed load.
  18380. * @hidden
  18381. */
  18382. delayLoad(): void;
  18383. private _prepareRowForTextureGeneration;
  18384. /**
  18385. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18386. * @returns the transform matrix of the texture.
  18387. */
  18388. getTextureMatrix(): Matrix;
  18389. /**
  18390. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18391. * @returns The reflection texture transform
  18392. */
  18393. getReflectionTextureMatrix(): Matrix;
  18394. /**
  18395. * Clones the texture.
  18396. * @returns the cloned texture
  18397. */
  18398. clone(): Texture;
  18399. /**
  18400. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18401. * @returns The JSON representation of the texture
  18402. */
  18403. serialize(): any;
  18404. /**
  18405. * Get the current class name of the texture useful for serialization or dynamic coding.
  18406. * @returns "Texture"
  18407. */
  18408. getClassName(): string;
  18409. /**
  18410. * Dispose the texture and release its associated resources.
  18411. */
  18412. dispose(): void;
  18413. /**
  18414. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18415. * @param parsedTexture Define the JSON representation of the texture
  18416. * @param scene Define the scene the parsed texture should be instantiated in
  18417. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18418. * @returns The parsed texture if successful
  18419. */
  18420. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18421. /**
  18422. * Creates a texture from its base 64 representation.
  18423. * @param data Define the base64 payload without the data: prefix
  18424. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18425. * @param scene Define the scene the texture should belong to
  18426. * @param noMipmap Forces the texture to not create mip map information if true
  18427. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18428. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18429. * @param onLoad define a callback triggered when the texture has been loaded
  18430. * @param onError define a callback triggered when an error occurred during the loading session
  18431. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18432. * @returns the created texture
  18433. */
  18434. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18435. /**
  18436. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18437. * @param data Define the base64 payload without the data: prefix
  18438. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18439. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18440. * @param scene Define the scene the texture should belong to
  18441. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18442. * @param noMipmap Forces the texture to not create mip map information if true
  18443. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18444. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18445. * @param onLoad define a callback triggered when the texture has been loaded
  18446. * @param onError define a callback triggered when an error occurred during the loading session
  18447. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18448. * @returns the created texture
  18449. */
  18450. 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;
  18451. }
  18452. }
  18453. declare module "babylonjs/Materials/Textures/rawTexture" {
  18454. import { Scene } from "babylonjs/scene";
  18455. import { Texture } from "babylonjs/Materials/Textures/texture";
  18456. /**
  18457. * Raw texture can help creating a texture directly from an array of data.
  18458. * This can be super useful if you either get the data from an uncompressed source or
  18459. * if you wish to create your texture pixel by pixel.
  18460. */
  18461. export class RawTexture extends Texture {
  18462. /**
  18463. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18464. */
  18465. format: number;
  18466. private _engine;
  18467. /**
  18468. * Instantiates a new RawTexture.
  18469. * Raw texture can help creating a texture directly from an array of data.
  18470. * This can be super useful if you either get the data from an uncompressed source or
  18471. * if you wish to create your texture pixel by pixel.
  18472. * @param data define the array of data to use to create the texture
  18473. * @param width define the width of the texture
  18474. * @param height define the height of the texture
  18475. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18476. * @param scene define the scene the texture belongs to
  18477. * @param generateMipMaps define whether mip maps should be generated or not
  18478. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18479. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18480. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18481. */
  18482. constructor(data: ArrayBufferView, width: number, height: number,
  18483. /**
  18484. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18485. */
  18486. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18487. /**
  18488. * Updates the texture underlying data.
  18489. * @param data Define the new data of the texture
  18490. */
  18491. update(data: ArrayBufferView): void;
  18492. /**
  18493. * Creates a luminance texture from some data.
  18494. * @param data Define the texture data
  18495. * @param width Define the width of the texture
  18496. * @param height Define the height of the texture
  18497. * @param scene Define the scene the texture belongs to
  18498. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18499. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18500. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18501. * @returns the luminance texture
  18502. */
  18503. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18504. /**
  18505. * Creates a luminance alpha texture from some data.
  18506. * @param data Define the texture data
  18507. * @param width Define the width of the texture
  18508. * @param height Define the height of the texture
  18509. * @param scene Define the scene the texture belongs to
  18510. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18511. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18512. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18513. * @returns the luminance alpha texture
  18514. */
  18515. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18516. /**
  18517. * Creates an alpha texture from some data.
  18518. * @param data Define the texture data
  18519. * @param width Define the width of the texture
  18520. * @param height Define the height of the texture
  18521. * @param scene Define the scene the texture belongs to
  18522. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18523. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18524. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18525. * @returns the alpha texture
  18526. */
  18527. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18528. /**
  18529. * Creates a RGB texture from some data.
  18530. * @param data Define the texture data
  18531. * @param width Define the width of the texture
  18532. * @param height Define the height of the texture
  18533. * @param scene Define the scene the texture belongs to
  18534. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18535. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18536. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18537. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18538. * @returns the RGB alpha texture
  18539. */
  18540. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18541. /**
  18542. * Creates a RGBA texture from some data.
  18543. * @param data Define the texture data
  18544. * @param width Define the width of the texture
  18545. * @param height Define the height of the texture
  18546. * @param scene Define the scene the texture belongs to
  18547. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18548. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18549. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18550. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18551. * @returns the RGBA texture
  18552. */
  18553. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18554. /**
  18555. * Creates a R texture from some data.
  18556. * @param data Define the texture data
  18557. * @param width Define the width of the texture
  18558. * @param height Define the height of the texture
  18559. * @param scene Define the scene the texture belongs to
  18560. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18561. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18562. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18563. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18564. * @returns the R texture
  18565. */
  18566. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18567. }
  18568. }
  18569. declare module "babylonjs/Animations/runtimeAnimation" {
  18570. import { Animation } from "babylonjs/Animations/animation";
  18571. import { Animatable } from "babylonjs/Animations/animatable";
  18572. import { Scene } from "babylonjs/scene";
  18573. /**
  18574. * Defines a runtime animation
  18575. */
  18576. export class RuntimeAnimation {
  18577. private _events;
  18578. /**
  18579. * The current frame of the runtime animation
  18580. */
  18581. private _currentFrame;
  18582. /**
  18583. * The animation used by the runtime animation
  18584. */
  18585. private _animation;
  18586. /**
  18587. * The target of the runtime animation
  18588. */
  18589. private _target;
  18590. /**
  18591. * The initiating animatable
  18592. */
  18593. private _host;
  18594. /**
  18595. * The original value of the runtime animation
  18596. */
  18597. private _originalValue;
  18598. /**
  18599. * The original blend value of the runtime animation
  18600. */
  18601. private _originalBlendValue;
  18602. /**
  18603. * The offsets cache of the runtime animation
  18604. */
  18605. private _offsetsCache;
  18606. /**
  18607. * The high limits cache of the runtime animation
  18608. */
  18609. private _highLimitsCache;
  18610. /**
  18611. * Specifies if the runtime animation has been stopped
  18612. */
  18613. private _stopped;
  18614. /**
  18615. * The blending factor of the runtime animation
  18616. */
  18617. private _blendingFactor;
  18618. /**
  18619. * The BabylonJS scene
  18620. */
  18621. private _scene;
  18622. /**
  18623. * The current value of the runtime animation
  18624. */
  18625. private _currentValue;
  18626. /** @hidden */
  18627. _workValue: any;
  18628. /**
  18629. * The active target of the runtime animation
  18630. */
  18631. private _activeTarget;
  18632. /**
  18633. * The target path of the runtime animation
  18634. */
  18635. private _targetPath;
  18636. /**
  18637. * The weight of the runtime animation
  18638. */
  18639. private _weight;
  18640. /**
  18641. * The ratio offset of the runtime animation
  18642. */
  18643. private _ratioOffset;
  18644. /**
  18645. * The previous delay of the runtime animation
  18646. */
  18647. private _previousDelay;
  18648. /**
  18649. * The previous ratio of the runtime animation
  18650. */
  18651. private _previousRatio;
  18652. /**
  18653. * Gets the current frame of the runtime animation
  18654. */
  18655. readonly currentFrame: number;
  18656. /**
  18657. * Gets the weight of the runtime animation
  18658. */
  18659. readonly weight: number;
  18660. /**
  18661. * Gets the current value of the runtime animation
  18662. */
  18663. readonly currentValue: any;
  18664. /**
  18665. * Gets the target path of the runtime animation
  18666. */
  18667. readonly targetPath: string;
  18668. /**
  18669. * Gets the actual target of the runtime animation
  18670. */
  18671. readonly target: any;
  18672. /**
  18673. * Create a new RuntimeAnimation object
  18674. * @param target defines the target of the animation
  18675. * @param animation defines the source animation object
  18676. * @param scene defines the hosting scene
  18677. * @param host defines the initiating Animatable
  18678. */
  18679. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18680. /**
  18681. * Gets the animation from the runtime animation
  18682. */
  18683. readonly animation: Animation;
  18684. /**
  18685. * Resets the runtime animation to the beginning
  18686. * @param restoreOriginal defines whether to restore the target property to the original value
  18687. */
  18688. reset(restoreOriginal?: boolean): void;
  18689. /**
  18690. * Specifies if the runtime animation is stopped
  18691. * @returns Boolean specifying if the runtime animation is stopped
  18692. */
  18693. isStopped(): boolean;
  18694. /**
  18695. * Disposes of the runtime animation
  18696. */
  18697. dispose(): void;
  18698. /**
  18699. * Interpolates the animation from the current frame
  18700. * @param currentFrame The frame to interpolate the animation to
  18701. * @param repeatCount The number of times that the animation should loop
  18702. * @param loopMode The type of looping mode to use
  18703. * @param offsetValue Animation offset value
  18704. * @param highLimitValue The high limit value
  18705. * @returns The interpolated value
  18706. */
  18707. private _interpolate;
  18708. /**
  18709. * Apply the interpolated value to the target
  18710. * @param currentValue defines the value computed by the animation
  18711. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18712. */
  18713. setValue(currentValue: any, weight?: number): void;
  18714. private _setValue;
  18715. /**
  18716. * Gets the loop pmode of the runtime animation
  18717. * @returns Loop Mode
  18718. */
  18719. private _getCorrectLoopMode;
  18720. /**
  18721. * Move the current animation to a given frame
  18722. * @param frame defines the frame to move to
  18723. */
  18724. goToFrame(frame: number): void;
  18725. /**
  18726. * @hidden Internal use only
  18727. */
  18728. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18729. /**
  18730. * Execute the current animation
  18731. * @param delay defines the delay to add to the current frame
  18732. * @param from defines the lower bound of the animation range
  18733. * @param to defines the upper bound of the animation range
  18734. * @param loop defines if the current animation must loop
  18735. * @param speedRatio defines the current speed ratio
  18736. * @param weight defines the weight of the animation (default is -1 so no weight)
  18737. * @param onLoop optional callback called when animation loops
  18738. * @returns a boolean indicating if the animation is running
  18739. */
  18740. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  18741. }
  18742. }
  18743. declare module "babylonjs/Animations/animatable" {
  18744. import { Animation } from "babylonjs/Animations/animation";
  18745. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  18746. import { Nullable } from "babylonjs/types";
  18747. import { Observable } from "babylonjs/Misc/observable";
  18748. import { Scene } from "babylonjs/scene";
  18749. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  18750. import { Node } from "babylonjs/node";
  18751. /**
  18752. * Class used to store an actual running animation
  18753. */
  18754. export class Animatable {
  18755. /** defines the target object */
  18756. target: any;
  18757. /** defines the starting frame number (default is 0) */
  18758. fromFrame: number;
  18759. /** defines the ending frame number (default is 100) */
  18760. toFrame: number;
  18761. /** defines if the animation must loop (default is false) */
  18762. loopAnimation: boolean;
  18763. /** defines a callback to call when animation ends if it is not looping */
  18764. onAnimationEnd?: (() => void) | null | undefined;
  18765. /** defines a callback to call when animation loops */
  18766. onAnimationLoop?: (() => void) | null | undefined;
  18767. private _localDelayOffset;
  18768. private _pausedDelay;
  18769. private _runtimeAnimations;
  18770. private _paused;
  18771. private _scene;
  18772. private _speedRatio;
  18773. private _weight;
  18774. private _syncRoot;
  18775. /**
  18776. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18777. * This will only apply for non looping animation (default is true)
  18778. */
  18779. disposeOnEnd: boolean;
  18780. /**
  18781. * Gets a boolean indicating if the animation has started
  18782. */
  18783. animationStarted: boolean;
  18784. /**
  18785. * Observer raised when the animation ends
  18786. */
  18787. onAnimationEndObservable: Observable<Animatable>;
  18788. /**
  18789. * Observer raised when the animation loops
  18790. */
  18791. onAnimationLoopObservable: Observable<Animatable>;
  18792. /**
  18793. * Gets the root Animatable used to synchronize and normalize animations
  18794. */
  18795. readonly syncRoot: Animatable;
  18796. /**
  18797. * Gets the current frame of the first RuntimeAnimation
  18798. * Used to synchronize Animatables
  18799. */
  18800. readonly masterFrame: number;
  18801. /**
  18802. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18803. */
  18804. weight: number;
  18805. /**
  18806. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18807. */
  18808. speedRatio: number;
  18809. /**
  18810. * Creates a new Animatable
  18811. * @param scene defines the hosting scene
  18812. * @param target defines the target object
  18813. * @param fromFrame defines the starting frame number (default is 0)
  18814. * @param toFrame defines the ending frame number (default is 100)
  18815. * @param loopAnimation defines if the animation must loop (default is false)
  18816. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18817. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18818. * @param animations defines a group of animation to add to the new Animatable
  18819. * @param onAnimationLoop defines a callback to call when animation loops
  18820. */
  18821. constructor(scene: Scene,
  18822. /** defines the target object */
  18823. target: any,
  18824. /** defines the starting frame number (default is 0) */
  18825. fromFrame?: number,
  18826. /** defines the ending frame number (default is 100) */
  18827. toFrame?: number,
  18828. /** defines if the animation must loop (default is false) */
  18829. loopAnimation?: boolean, speedRatio?: number,
  18830. /** defines a callback to call when animation ends if it is not looping */
  18831. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18832. /** defines a callback to call when animation loops */
  18833. onAnimationLoop?: (() => void) | null | undefined);
  18834. /**
  18835. * Synchronize and normalize current Animatable with a source Animatable
  18836. * This is useful when using animation weights and when animations are not of the same length
  18837. * @param root defines the root Animatable to synchronize with
  18838. * @returns the current Animatable
  18839. */
  18840. syncWith(root: Animatable): Animatable;
  18841. /**
  18842. * Gets the list of runtime animations
  18843. * @returns an array of RuntimeAnimation
  18844. */
  18845. getAnimations(): RuntimeAnimation[];
  18846. /**
  18847. * Adds more animations to the current animatable
  18848. * @param target defines the target of the animations
  18849. * @param animations defines the new animations to add
  18850. */
  18851. appendAnimations(target: any, animations: Animation[]): void;
  18852. /**
  18853. * Gets the source animation for a specific property
  18854. * @param property defines the propertyu to look for
  18855. * @returns null or the source animation for the given property
  18856. */
  18857. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18858. /**
  18859. * Gets the runtime animation for a specific property
  18860. * @param property defines the propertyu to look for
  18861. * @returns null or the runtime animation for the given property
  18862. */
  18863. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18864. /**
  18865. * Resets the animatable to its original state
  18866. */
  18867. reset(): void;
  18868. /**
  18869. * Allows the animatable to blend with current running animations
  18870. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18871. * @param blendingSpeed defines the blending speed to use
  18872. */
  18873. enableBlending(blendingSpeed: number): void;
  18874. /**
  18875. * Disable animation blending
  18876. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18877. */
  18878. disableBlending(): void;
  18879. /**
  18880. * Jump directly to a given frame
  18881. * @param frame defines the frame to jump to
  18882. */
  18883. goToFrame(frame: number): void;
  18884. /**
  18885. * Pause the animation
  18886. */
  18887. pause(): void;
  18888. /**
  18889. * Restart the animation
  18890. */
  18891. restart(): void;
  18892. private _raiseOnAnimationEnd;
  18893. /**
  18894. * Stop and delete the current animation
  18895. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  18896. * @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)
  18897. */
  18898. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  18899. /**
  18900. * Wait asynchronously for the animation to end
  18901. * @returns a promise which will be fullfilled when the animation ends
  18902. */
  18903. waitAsync(): Promise<Animatable>;
  18904. /** @hidden */
  18905. _animate(delay: number): boolean;
  18906. }
  18907. module "babylonjs/scene" {
  18908. interface Scene {
  18909. /** @hidden */
  18910. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  18911. /** @hidden */
  18912. _processLateAnimationBindingsForMatrices(holder: {
  18913. totalWeight: number;
  18914. animations: RuntimeAnimation[];
  18915. originalValue: Matrix;
  18916. }): any;
  18917. /** @hidden */
  18918. _processLateAnimationBindingsForQuaternions(holder: {
  18919. totalWeight: number;
  18920. animations: RuntimeAnimation[];
  18921. originalValue: Quaternion;
  18922. }, refQuaternion: Quaternion): Quaternion;
  18923. /** @hidden */
  18924. _processLateAnimationBindings(): void;
  18925. /**
  18926. * Will start the animation sequence of a given target
  18927. * @param target defines the target
  18928. * @param from defines from which frame should animation start
  18929. * @param to defines until which frame should animation run.
  18930. * @param weight defines the weight to apply to the animation (1.0 by default)
  18931. * @param loop defines if the animation loops
  18932. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18933. * @param onAnimationEnd defines the function to be executed when the animation ends
  18934. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18935. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18936. * @param onAnimationLoop defines the callback to call when an animation loops
  18937. * @returns the animatable object created for this animation
  18938. */
  18939. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18940. /**
  18941. * Will start the animation sequence of a given target
  18942. * @param target defines the target
  18943. * @param from defines from which frame should animation start
  18944. * @param to defines until which frame should animation run.
  18945. * @param loop defines if the animation loops
  18946. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18947. * @param onAnimationEnd defines the function to be executed when the animation ends
  18948. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18949. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18950. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  18951. * @param onAnimationLoop defines the callback to call when an animation loops
  18952. * @returns the animatable object created for this animation
  18953. */
  18954. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18955. /**
  18956. * Will start the animation sequence of a given target and its hierarchy
  18957. * @param target defines the target
  18958. * @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.
  18959. * @param from defines from which frame should animation start
  18960. * @param to defines until which frame should animation run.
  18961. * @param loop defines if the animation loops
  18962. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18963. * @param onAnimationEnd defines the function to be executed when the animation ends
  18964. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18965. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18966. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18967. * @param onAnimationLoop defines the callback to call when an animation loops
  18968. * @returns the list of created animatables
  18969. */
  18970. 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[];
  18971. /**
  18972. * Begin a new animation on a given node
  18973. * @param target defines the target where the animation will take place
  18974. * @param animations defines the list of animations to start
  18975. * @param from defines the initial value
  18976. * @param to defines the final value
  18977. * @param loop defines if you want animation to loop (off by default)
  18978. * @param speedRatio defines the speed ratio to apply to all animations
  18979. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18980. * @param onAnimationLoop defines the callback to call when an animation loops
  18981. * @returns the list of created animatables
  18982. */
  18983. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  18984. /**
  18985. * Begin a new animation on a given node and its hierarchy
  18986. * @param target defines the root node where the animation will take place
  18987. * @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.
  18988. * @param animations defines the list of animations to start
  18989. * @param from defines the initial value
  18990. * @param to defines the final value
  18991. * @param loop defines if you want animation to loop (off by default)
  18992. * @param speedRatio defines the speed ratio to apply to all animations
  18993. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18994. * @param onAnimationLoop defines the callback to call when an animation loops
  18995. * @returns the list of animatables created for all nodes
  18996. */
  18997. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  18998. /**
  18999. * Gets the animatable associated with a specific target
  19000. * @param target defines the target of the animatable
  19001. * @returns the required animatable if found
  19002. */
  19003. getAnimatableByTarget(target: any): Nullable<Animatable>;
  19004. /**
  19005. * Gets all animatables associated with a given target
  19006. * @param target defines the target to look animatables for
  19007. * @returns an array of Animatables
  19008. */
  19009. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  19010. /**
  19011. * Will stop the animation of the given target
  19012. * @param target - the target
  19013. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  19014. * @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)
  19015. */
  19016. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  19017. /**
  19018. * Stops and removes all animations that have been applied to the scene
  19019. */
  19020. stopAllAnimations(): void;
  19021. }
  19022. }
  19023. module "babylonjs/Bones/bone" {
  19024. interface Bone {
  19025. /**
  19026. * Copy an animation range from another bone
  19027. * @param source defines the source bone
  19028. * @param rangeName defines the range name to copy
  19029. * @param frameOffset defines the frame offset
  19030. * @param rescaleAsRequired defines if rescaling must be applied if required
  19031. * @param skelDimensionsRatio defines the scaling ratio
  19032. * @returns true if operation was successful
  19033. */
  19034. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  19035. }
  19036. }
  19037. }
  19038. declare module "babylonjs/Bones/skeleton" {
  19039. import { Bone } from "babylonjs/Bones/bone";
  19040. import { IAnimatable } from "babylonjs/Misc/tools";
  19041. import { Observable } from "babylonjs/Misc/observable";
  19042. import { Vector3, Matrix } from "babylonjs/Maths/math";
  19043. import { Scene } from "babylonjs/scene";
  19044. import { Nullable } from "babylonjs/types";
  19045. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19046. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  19047. import { Animatable } from "babylonjs/Animations/animatable";
  19048. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19049. import { Animation } from "babylonjs/Animations/animation";
  19050. import { AnimationRange } from "babylonjs/Animations/animationRange";
  19051. import { IInspectable } from "babylonjs/Misc/iInspectable";
  19052. /**
  19053. * Class used to handle skinning animations
  19054. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19055. */
  19056. export class Skeleton implements IAnimatable {
  19057. /** defines the skeleton name */
  19058. name: string;
  19059. /** defines the skeleton Id */
  19060. id: string;
  19061. /**
  19062. * Defines the list of child bones
  19063. */
  19064. bones: Bone[];
  19065. /**
  19066. * Defines an estimate of the dimension of the skeleton at rest
  19067. */
  19068. dimensionsAtRest: Vector3;
  19069. /**
  19070. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  19071. */
  19072. needInitialSkinMatrix: boolean;
  19073. /**
  19074. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  19075. */
  19076. overrideMesh: Nullable<AbstractMesh>;
  19077. /**
  19078. * Gets the list of animations attached to this skeleton
  19079. */
  19080. animations: Array<Animation>;
  19081. private _scene;
  19082. private _isDirty;
  19083. private _transformMatrices;
  19084. private _transformMatrixTexture;
  19085. private _meshesWithPoseMatrix;
  19086. private _animatables;
  19087. private _identity;
  19088. private _synchronizedWithMesh;
  19089. private _ranges;
  19090. private _lastAbsoluteTransformsUpdateId;
  19091. private _canUseTextureForBones;
  19092. private _uniqueId;
  19093. /** @hidden */
  19094. _numBonesWithLinkedTransformNode: number;
  19095. /**
  19096. * Specifies if the skeleton should be serialized
  19097. */
  19098. doNotSerialize: boolean;
  19099. private _useTextureToStoreBoneMatrices;
  19100. /**
  19101. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  19102. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  19103. */
  19104. useTextureToStoreBoneMatrices: boolean;
  19105. private _animationPropertiesOverride;
  19106. /**
  19107. * Gets or sets the animation properties override
  19108. */
  19109. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19110. /**
  19111. * List of inspectable custom properties (used by the Inspector)
  19112. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19113. */
  19114. inspectableCustomProperties: IInspectable[];
  19115. /**
  19116. * An observable triggered before computing the skeleton's matrices
  19117. */
  19118. onBeforeComputeObservable: Observable<Skeleton>;
  19119. /**
  19120. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  19121. */
  19122. readonly isUsingTextureForMatrices: boolean;
  19123. /**
  19124. * Gets the unique ID of this skeleton
  19125. */
  19126. readonly uniqueId: number;
  19127. /**
  19128. * Creates a new skeleton
  19129. * @param name defines the skeleton name
  19130. * @param id defines the skeleton Id
  19131. * @param scene defines the hosting scene
  19132. */
  19133. constructor(
  19134. /** defines the skeleton name */
  19135. name: string,
  19136. /** defines the skeleton Id */
  19137. id: string, scene: Scene);
  19138. /**
  19139. * Gets the current object class name.
  19140. * @return the class name
  19141. */
  19142. getClassName(): string;
  19143. /**
  19144. * Returns an array containing the root bones
  19145. * @returns an array containing the root bones
  19146. */
  19147. getChildren(): Array<Bone>;
  19148. /**
  19149. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19150. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19151. * @returns a Float32Array containing matrices data
  19152. */
  19153. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19154. /**
  19155. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19156. * @returns a raw texture containing the data
  19157. */
  19158. getTransformMatrixTexture(): Nullable<RawTexture>;
  19159. /**
  19160. * Gets the current hosting scene
  19161. * @returns a scene object
  19162. */
  19163. getScene(): Scene;
  19164. /**
  19165. * Gets a string representing the current skeleton data
  19166. * @param fullDetails defines a boolean indicating if we want a verbose version
  19167. * @returns a string representing the current skeleton data
  19168. */
  19169. toString(fullDetails?: boolean): string;
  19170. /**
  19171. * Get bone's index searching by name
  19172. * @param name defines bone's name to search for
  19173. * @return the indice of the bone. Returns -1 if not found
  19174. */
  19175. getBoneIndexByName(name: string): number;
  19176. /**
  19177. * Creater a new animation range
  19178. * @param name defines the name of the range
  19179. * @param from defines the start key
  19180. * @param to defines the end key
  19181. */
  19182. createAnimationRange(name: string, from: number, to: number): void;
  19183. /**
  19184. * Delete a specific animation range
  19185. * @param name defines the name of the range
  19186. * @param deleteFrames defines if frames must be removed as well
  19187. */
  19188. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19189. /**
  19190. * Gets a specific animation range
  19191. * @param name defines the name of the range to look for
  19192. * @returns the requested animation range or null if not found
  19193. */
  19194. getAnimationRange(name: string): Nullable<AnimationRange>;
  19195. /**
  19196. * Gets the list of all animation ranges defined on this skeleton
  19197. * @returns an array
  19198. */
  19199. getAnimationRanges(): Nullable<AnimationRange>[];
  19200. /**
  19201. * Copy animation range from a source skeleton.
  19202. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19203. * @param source defines the source skeleton
  19204. * @param name defines the name of the range to copy
  19205. * @param rescaleAsRequired defines if rescaling must be applied if required
  19206. * @returns true if operation was successful
  19207. */
  19208. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19209. /**
  19210. * Forces the skeleton to go to rest pose
  19211. */
  19212. returnToRest(): void;
  19213. private _getHighestAnimationFrame;
  19214. /**
  19215. * Begin a specific animation range
  19216. * @param name defines the name of the range to start
  19217. * @param loop defines if looping must be turned on (false by default)
  19218. * @param speedRatio defines the speed ratio to apply (1 by default)
  19219. * @param onAnimationEnd defines a callback which will be called when animation will end
  19220. * @returns a new animatable
  19221. */
  19222. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19223. /** @hidden */
  19224. _markAsDirty(): void;
  19225. /** @hidden */
  19226. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19227. /** @hidden */
  19228. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19229. private _computeTransformMatrices;
  19230. /**
  19231. * Build all resources required to render a skeleton
  19232. */
  19233. prepare(): void;
  19234. /**
  19235. * Gets the list of animatables currently running for this skeleton
  19236. * @returns an array of animatables
  19237. */
  19238. getAnimatables(): IAnimatable[];
  19239. /**
  19240. * Clone the current skeleton
  19241. * @param name defines the name of the new skeleton
  19242. * @param id defines the id of the enw skeleton
  19243. * @returns the new skeleton
  19244. */
  19245. clone(name: string, id: string): Skeleton;
  19246. /**
  19247. * Enable animation blending for this skeleton
  19248. * @param blendingSpeed defines the blending speed to apply
  19249. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19250. */
  19251. enableBlending(blendingSpeed?: number): void;
  19252. /**
  19253. * Releases all resources associated with the current skeleton
  19254. */
  19255. dispose(): void;
  19256. /**
  19257. * Serialize the skeleton in a JSON object
  19258. * @returns a JSON object
  19259. */
  19260. serialize(): any;
  19261. /**
  19262. * Creates a new skeleton from serialized data
  19263. * @param parsedSkeleton defines the serialized data
  19264. * @param scene defines the hosting scene
  19265. * @returns a new skeleton
  19266. */
  19267. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19268. /**
  19269. * Compute all node absolute transforms
  19270. * @param forceUpdate defines if computation must be done even if cache is up to date
  19271. */
  19272. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19273. /**
  19274. * Gets the root pose matrix
  19275. * @returns a matrix
  19276. */
  19277. getPoseMatrix(): Nullable<Matrix>;
  19278. /**
  19279. * Sorts bones per internal index
  19280. */
  19281. sortBones(): void;
  19282. private _sortBones;
  19283. }
  19284. }
  19285. declare module "babylonjs/Morph/morphTarget" {
  19286. import { IAnimatable } from "babylonjs/Misc/tools";
  19287. import { Observable } from "babylonjs/Misc/observable";
  19288. import { Nullable, FloatArray } from "babylonjs/types";
  19289. import { Scene } from "babylonjs/scene";
  19290. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19291. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19292. /**
  19293. * Defines a target to use with MorphTargetManager
  19294. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19295. */
  19296. export class MorphTarget implements IAnimatable {
  19297. /** defines the name of the target */
  19298. name: string;
  19299. /**
  19300. * Gets or sets the list of animations
  19301. */
  19302. animations: import("babylonjs/Animations/animation").Animation[];
  19303. private _scene;
  19304. private _positions;
  19305. private _normals;
  19306. private _tangents;
  19307. private _influence;
  19308. /**
  19309. * Observable raised when the influence changes
  19310. */
  19311. onInfluenceChanged: Observable<boolean>;
  19312. /** @hidden */
  19313. _onDataLayoutChanged: Observable<void>;
  19314. /**
  19315. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19316. */
  19317. influence: number;
  19318. /**
  19319. * Gets or sets the id of the morph Target
  19320. */
  19321. id: string;
  19322. private _animationPropertiesOverride;
  19323. /**
  19324. * Gets or sets the animation properties override
  19325. */
  19326. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19327. /**
  19328. * Creates a new MorphTarget
  19329. * @param name defines the name of the target
  19330. * @param influence defines the influence to use
  19331. * @param scene defines the scene the morphtarget belongs to
  19332. */
  19333. constructor(
  19334. /** defines the name of the target */
  19335. name: string, influence?: number, scene?: Nullable<Scene>);
  19336. /**
  19337. * Gets a boolean defining if the target contains position data
  19338. */
  19339. readonly hasPositions: boolean;
  19340. /**
  19341. * Gets a boolean defining if the target contains normal data
  19342. */
  19343. readonly hasNormals: boolean;
  19344. /**
  19345. * Gets a boolean defining if the target contains tangent data
  19346. */
  19347. readonly hasTangents: boolean;
  19348. /**
  19349. * Affects position data to this target
  19350. * @param data defines the position data to use
  19351. */
  19352. setPositions(data: Nullable<FloatArray>): void;
  19353. /**
  19354. * Gets the position data stored in this target
  19355. * @returns a FloatArray containing the position data (or null if not present)
  19356. */
  19357. getPositions(): Nullable<FloatArray>;
  19358. /**
  19359. * Affects normal data to this target
  19360. * @param data defines the normal data to use
  19361. */
  19362. setNormals(data: Nullable<FloatArray>): void;
  19363. /**
  19364. * Gets the normal data stored in this target
  19365. * @returns a FloatArray containing the normal data (or null if not present)
  19366. */
  19367. getNormals(): Nullable<FloatArray>;
  19368. /**
  19369. * Affects tangent data to this target
  19370. * @param data defines the tangent data to use
  19371. */
  19372. setTangents(data: Nullable<FloatArray>): void;
  19373. /**
  19374. * Gets the tangent data stored in this target
  19375. * @returns a FloatArray containing the tangent data (or null if not present)
  19376. */
  19377. getTangents(): Nullable<FloatArray>;
  19378. /**
  19379. * Serializes the current target into a Serialization object
  19380. * @returns the serialized object
  19381. */
  19382. serialize(): any;
  19383. /**
  19384. * Returns the string "MorphTarget"
  19385. * @returns "MorphTarget"
  19386. */
  19387. getClassName(): string;
  19388. /**
  19389. * Creates a new target from serialized data
  19390. * @param serializationObject defines the serialized data to use
  19391. * @returns a new MorphTarget
  19392. */
  19393. static Parse(serializationObject: any): MorphTarget;
  19394. /**
  19395. * Creates a MorphTarget from mesh data
  19396. * @param mesh defines the source mesh
  19397. * @param name defines the name to use for the new target
  19398. * @param influence defines the influence to attach to the target
  19399. * @returns a new MorphTarget
  19400. */
  19401. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19402. }
  19403. }
  19404. declare module "babylonjs/Morph/morphTargetManager" {
  19405. import { Nullable } from "babylonjs/types";
  19406. import { Scene } from "babylonjs/scene";
  19407. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  19408. /**
  19409. * This class is used to deform meshes using morphing between different targets
  19410. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19411. */
  19412. export class MorphTargetManager {
  19413. private _targets;
  19414. private _targetInfluenceChangedObservers;
  19415. private _targetDataLayoutChangedObservers;
  19416. private _activeTargets;
  19417. private _scene;
  19418. private _influences;
  19419. private _supportsNormals;
  19420. private _supportsTangents;
  19421. private _vertexCount;
  19422. private _uniqueId;
  19423. private _tempInfluences;
  19424. /**
  19425. * Creates a new MorphTargetManager
  19426. * @param scene defines the current scene
  19427. */
  19428. constructor(scene?: Nullable<Scene>);
  19429. /**
  19430. * Gets the unique ID of this manager
  19431. */
  19432. readonly uniqueId: number;
  19433. /**
  19434. * Gets the number of vertices handled by this manager
  19435. */
  19436. readonly vertexCount: number;
  19437. /**
  19438. * Gets a boolean indicating if this manager supports morphing of normals
  19439. */
  19440. readonly supportsNormals: boolean;
  19441. /**
  19442. * Gets a boolean indicating if this manager supports morphing of tangents
  19443. */
  19444. readonly supportsTangents: boolean;
  19445. /**
  19446. * Gets the number of targets stored in this manager
  19447. */
  19448. readonly numTargets: number;
  19449. /**
  19450. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19451. */
  19452. readonly numInfluencers: number;
  19453. /**
  19454. * Gets the list of influences (one per target)
  19455. */
  19456. readonly influences: Float32Array;
  19457. /**
  19458. * Gets the active target at specified index. An active target is a target with an influence > 0
  19459. * @param index defines the index to check
  19460. * @returns the requested target
  19461. */
  19462. getActiveTarget(index: number): MorphTarget;
  19463. /**
  19464. * Gets the target at specified index
  19465. * @param index defines the index to check
  19466. * @returns the requested target
  19467. */
  19468. getTarget(index: number): MorphTarget;
  19469. /**
  19470. * Add a new target to this manager
  19471. * @param target defines the target to add
  19472. */
  19473. addTarget(target: MorphTarget): void;
  19474. /**
  19475. * Removes a target from the manager
  19476. * @param target defines the target to remove
  19477. */
  19478. removeTarget(target: MorphTarget): void;
  19479. /**
  19480. * Serializes the current manager into a Serialization object
  19481. * @returns the serialized object
  19482. */
  19483. serialize(): any;
  19484. private _syncActiveTargets;
  19485. /**
  19486. * Syncrhonize the targets with all the meshes using this morph target manager
  19487. */
  19488. synchronize(): void;
  19489. /**
  19490. * Creates a new MorphTargetManager from serialized data
  19491. * @param serializationObject defines the serialized data
  19492. * @param scene defines the hosting scene
  19493. * @returns the new MorphTargetManager
  19494. */
  19495. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19496. }
  19497. }
  19498. declare module "babylonjs/Meshes/groundMesh" {
  19499. import { Scene } from "babylonjs/scene";
  19500. import { Vector3 } from "babylonjs/Maths/math";
  19501. import { Mesh } from "babylonjs/Meshes/mesh";
  19502. /**
  19503. * Mesh representing the gorund
  19504. */
  19505. export class GroundMesh extends Mesh {
  19506. /** If octree should be generated */
  19507. generateOctree: boolean;
  19508. private _heightQuads;
  19509. /** @hidden */
  19510. _subdivisionsX: number;
  19511. /** @hidden */
  19512. _subdivisionsY: number;
  19513. /** @hidden */
  19514. _width: number;
  19515. /** @hidden */
  19516. _height: number;
  19517. /** @hidden */
  19518. _minX: number;
  19519. /** @hidden */
  19520. _maxX: number;
  19521. /** @hidden */
  19522. _minZ: number;
  19523. /** @hidden */
  19524. _maxZ: number;
  19525. constructor(name: string, scene: Scene);
  19526. /**
  19527. * "GroundMesh"
  19528. * @returns "GroundMesh"
  19529. */
  19530. getClassName(): string;
  19531. /**
  19532. * The minimum of x and y subdivisions
  19533. */
  19534. readonly subdivisions: number;
  19535. /**
  19536. * X subdivisions
  19537. */
  19538. readonly subdivisionsX: number;
  19539. /**
  19540. * Y subdivisions
  19541. */
  19542. readonly subdivisionsY: number;
  19543. /**
  19544. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19545. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19546. * @param chunksCount the number of subdivisions for x and y
  19547. * @param octreeBlocksSize (Default: 32)
  19548. */
  19549. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19550. /**
  19551. * Returns a height (y) value in the Worl system :
  19552. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19553. * @param x x coordinate
  19554. * @param z z coordinate
  19555. * @returns the ground y position if (x, z) are outside the ground surface.
  19556. */
  19557. getHeightAtCoordinates(x: number, z: number): number;
  19558. /**
  19559. * Returns a normalized vector (Vector3) orthogonal to the ground
  19560. * at the ground coordinates (x, z) expressed in the World system.
  19561. * @param x x coordinate
  19562. * @param z z coordinate
  19563. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19564. */
  19565. getNormalAtCoordinates(x: number, z: number): Vector3;
  19566. /**
  19567. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19568. * at the ground coordinates (x, z) expressed in the World system.
  19569. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19570. * @param x x coordinate
  19571. * @param z z coordinate
  19572. * @param ref vector to store the result
  19573. * @returns the GroundMesh.
  19574. */
  19575. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19576. /**
  19577. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19578. * if the ground has been updated.
  19579. * This can be used in the render loop.
  19580. * @returns the GroundMesh.
  19581. */
  19582. updateCoordinateHeights(): GroundMesh;
  19583. private _getFacetAt;
  19584. private _initHeightQuads;
  19585. private _computeHeightQuads;
  19586. /**
  19587. * Serializes this ground mesh
  19588. * @param serializationObject object to write serialization to
  19589. */
  19590. serialize(serializationObject: any): void;
  19591. /**
  19592. * Parses a serialized ground mesh
  19593. * @param parsedMesh the serialized mesh
  19594. * @param scene the scene to create the ground mesh in
  19595. * @returns the created ground mesh
  19596. */
  19597. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19598. }
  19599. }
  19600. declare module "babylonjs/Physics/physicsJoint" {
  19601. import { Vector3 } from "babylonjs/Maths/math";
  19602. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  19603. /**
  19604. * Interface for Physics-Joint data
  19605. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19606. */
  19607. export interface PhysicsJointData {
  19608. /**
  19609. * The main pivot of the joint
  19610. */
  19611. mainPivot?: Vector3;
  19612. /**
  19613. * The connected pivot of the joint
  19614. */
  19615. connectedPivot?: Vector3;
  19616. /**
  19617. * The main axis of the joint
  19618. */
  19619. mainAxis?: Vector3;
  19620. /**
  19621. * The connected axis of the joint
  19622. */
  19623. connectedAxis?: Vector3;
  19624. /**
  19625. * The collision of the joint
  19626. */
  19627. collision?: boolean;
  19628. /**
  19629. * Native Oimo/Cannon/Energy data
  19630. */
  19631. nativeParams?: any;
  19632. }
  19633. /**
  19634. * This is a holder class for the physics joint created by the physics plugin
  19635. * It holds a set of functions to control the underlying joint
  19636. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19637. */
  19638. export class PhysicsJoint {
  19639. /**
  19640. * The type of the physics joint
  19641. */
  19642. type: number;
  19643. /**
  19644. * The data for the physics joint
  19645. */
  19646. jointData: PhysicsJointData;
  19647. private _physicsJoint;
  19648. protected _physicsPlugin: IPhysicsEnginePlugin;
  19649. /**
  19650. * Initializes the physics joint
  19651. * @param type The type of the physics joint
  19652. * @param jointData The data for the physics joint
  19653. */
  19654. constructor(
  19655. /**
  19656. * The type of the physics joint
  19657. */
  19658. type: number,
  19659. /**
  19660. * The data for the physics joint
  19661. */
  19662. jointData: PhysicsJointData);
  19663. /**
  19664. * Gets the physics joint
  19665. */
  19666. /**
  19667. * Sets the physics joint
  19668. */
  19669. physicsJoint: any;
  19670. /**
  19671. * Sets the physics plugin
  19672. */
  19673. physicsPlugin: IPhysicsEnginePlugin;
  19674. /**
  19675. * Execute a function that is physics-plugin specific.
  19676. * @param {Function} func the function that will be executed.
  19677. * It accepts two parameters: the physics world and the physics joint
  19678. */
  19679. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19680. /**
  19681. * Distance-Joint type
  19682. */
  19683. static DistanceJoint: number;
  19684. /**
  19685. * Hinge-Joint type
  19686. */
  19687. static HingeJoint: number;
  19688. /**
  19689. * Ball-and-Socket joint type
  19690. */
  19691. static BallAndSocketJoint: number;
  19692. /**
  19693. * Wheel-Joint type
  19694. */
  19695. static WheelJoint: number;
  19696. /**
  19697. * Slider-Joint type
  19698. */
  19699. static SliderJoint: number;
  19700. /**
  19701. * Prismatic-Joint type
  19702. */
  19703. static PrismaticJoint: number;
  19704. /**
  19705. * Universal-Joint type
  19706. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19707. */
  19708. static UniversalJoint: number;
  19709. /**
  19710. * Hinge-Joint 2 type
  19711. */
  19712. static Hinge2Joint: number;
  19713. /**
  19714. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19715. */
  19716. static PointToPointJoint: number;
  19717. /**
  19718. * Spring-Joint type
  19719. */
  19720. static SpringJoint: number;
  19721. /**
  19722. * Lock-Joint type
  19723. */
  19724. static LockJoint: number;
  19725. }
  19726. /**
  19727. * A class representing a physics distance joint
  19728. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19729. */
  19730. export class DistanceJoint extends PhysicsJoint {
  19731. /**
  19732. *
  19733. * @param jointData The data for the Distance-Joint
  19734. */
  19735. constructor(jointData: DistanceJointData);
  19736. /**
  19737. * Update the predefined distance.
  19738. * @param maxDistance The maximum preferred distance
  19739. * @param minDistance The minimum preferred distance
  19740. */
  19741. updateDistance(maxDistance: number, minDistance?: number): void;
  19742. }
  19743. /**
  19744. * Represents a Motor-Enabled Joint
  19745. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19746. */
  19747. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19748. /**
  19749. * Initializes the Motor-Enabled Joint
  19750. * @param type The type of the joint
  19751. * @param jointData The physica joint data for the joint
  19752. */
  19753. constructor(type: number, jointData: PhysicsJointData);
  19754. /**
  19755. * Set the motor values.
  19756. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19757. * @param force the force to apply
  19758. * @param maxForce max force for this motor.
  19759. */
  19760. setMotor(force?: number, maxForce?: number): void;
  19761. /**
  19762. * Set the motor's limits.
  19763. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19764. * @param upperLimit The upper limit of the motor
  19765. * @param lowerLimit The lower limit of the motor
  19766. */
  19767. setLimit(upperLimit: number, lowerLimit?: number): void;
  19768. }
  19769. /**
  19770. * This class represents a single physics Hinge-Joint
  19771. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19772. */
  19773. export class HingeJoint extends MotorEnabledJoint {
  19774. /**
  19775. * Initializes the Hinge-Joint
  19776. * @param jointData The joint data for the Hinge-Joint
  19777. */
  19778. constructor(jointData: PhysicsJointData);
  19779. /**
  19780. * Set the motor values.
  19781. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19782. * @param {number} force the force to apply
  19783. * @param {number} maxForce max force for this motor.
  19784. */
  19785. setMotor(force?: number, maxForce?: number): void;
  19786. /**
  19787. * Set the motor's limits.
  19788. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19789. * @param upperLimit The upper limit of the motor
  19790. * @param lowerLimit The lower limit of the motor
  19791. */
  19792. setLimit(upperLimit: number, lowerLimit?: number): void;
  19793. }
  19794. /**
  19795. * This class represents a dual hinge physics joint (same as wheel joint)
  19796. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19797. */
  19798. export class Hinge2Joint extends MotorEnabledJoint {
  19799. /**
  19800. * Initializes the Hinge2-Joint
  19801. * @param jointData The joint data for the Hinge2-Joint
  19802. */
  19803. constructor(jointData: PhysicsJointData);
  19804. /**
  19805. * Set the motor values.
  19806. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19807. * @param {number} targetSpeed the speed the motor is to reach
  19808. * @param {number} maxForce max force for this motor.
  19809. * @param {motorIndex} the motor's index, 0 or 1.
  19810. */
  19811. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19812. /**
  19813. * Set the motor limits.
  19814. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19815. * @param {number} upperLimit the upper limit
  19816. * @param {number} lowerLimit lower limit
  19817. * @param {motorIndex} the motor's index, 0 or 1.
  19818. */
  19819. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19820. }
  19821. /**
  19822. * Interface for a motor enabled joint
  19823. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19824. */
  19825. export interface IMotorEnabledJoint {
  19826. /**
  19827. * Physics joint
  19828. */
  19829. physicsJoint: any;
  19830. /**
  19831. * Sets the motor of the motor-enabled joint
  19832. * @param force The force of the motor
  19833. * @param maxForce The maximum force of the motor
  19834. * @param motorIndex The index of the motor
  19835. */
  19836. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19837. /**
  19838. * Sets the limit of the motor
  19839. * @param upperLimit The upper limit of the motor
  19840. * @param lowerLimit The lower limit of the motor
  19841. * @param motorIndex The index of the motor
  19842. */
  19843. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19844. }
  19845. /**
  19846. * Joint data for a Distance-Joint
  19847. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19848. */
  19849. export interface DistanceJointData extends PhysicsJointData {
  19850. /**
  19851. * Max distance the 2 joint objects can be apart
  19852. */
  19853. maxDistance: number;
  19854. }
  19855. /**
  19856. * Joint data from a spring joint
  19857. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19858. */
  19859. export interface SpringJointData extends PhysicsJointData {
  19860. /**
  19861. * Length of the spring
  19862. */
  19863. length: number;
  19864. /**
  19865. * Stiffness of the spring
  19866. */
  19867. stiffness: number;
  19868. /**
  19869. * Damping of the spring
  19870. */
  19871. damping: number;
  19872. /** this callback will be called when applying the force to the impostors. */
  19873. forceApplicationCallback: () => void;
  19874. }
  19875. }
  19876. declare module "babylonjs/Physics/physicsRaycastResult" {
  19877. import { Vector3 } from "babylonjs/Maths/math";
  19878. /**
  19879. * Holds the data for the raycast result
  19880. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19881. */
  19882. export class PhysicsRaycastResult {
  19883. private _hasHit;
  19884. private _hitDistance;
  19885. private _hitNormalWorld;
  19886. private _hitPointWorld;
  19887. private _rayFromWorld;
  19888. private _rayToWorld;
  19889. /**
  19890. * Gets if there was a hit
  19891. */
  19892. readonly hasHit: boolean;
  19893. /**
  19894. * Gets the distance from the hit
  19895. */
  19896. readonly hitDistance: number;
  19897. /**
  19898. * Gets the hit normal/direction in the world
  19899. */
  19900. readonly hitNormalWorld: Vector3;
  19901. /**
  19902. * Gets the hit point in the world
  19903. */
  19904. readonly hitPointWorld: Vector3;
  19905. /**
  19906. * Gets the ray "start point" of the ray in the world
  19907. */
  19908. readonly rayFromWorld: Vector3;
  19909. /**
  19910. * Gets the ray "end point" of the ray in the world
  19911. */
  19912. readonly rayToWorld: Vector3;
  19913. /**
  19914. * Sets the hit data (normal & point in world space)
  19915. * @param hitNormalWorld defines the normal in world space
  19916. * @param hitPointWorld defines the point in world space
  19917. */
  19918. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  19919. /**
  19920. * Sets the distance from the start point to the hit point
  19921. * @param distance
  19922. */
  19923. setHitDistance(distance: number): void;
  19924. /**
  19925. * Calculates the distance manually
  19926. */
  19927. calculateHitDistance(): void;
  19928. /**
  19929. * Resets all the values to default
  19930. * @param from The from point on world space
  19931. * @param to The to point on world space
  19932. */
  19933. reset(from?: Vector3, to?: Vector3): void;
  19934. }
  19935. /**
  19936. * Interface for the size containing width and height
  19937. */
  19938. interface IXYZ {
  19939. /**
  19940. * X
  19941. */
  19942. x: number;
  19943. /**
  19944. * Y
  19945. */
  19946. y: number;
  19947. /**
  19948. * Z
  19949. */
  19950. z: number;
  19951. }
  19952. }
  19953. declare module "babylonjs/Physics/IPhysicsEngine" {
  19954. import { Nullable } from "babylonjs/types";
  19955. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  19956. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19957. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  19958. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  19959. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  19960. /**
  19961. * Interface used to describe a physics joint
  19962. */
  19963. export interface PhysicsImpostorJoint {
  19964. /** Defines the main impostor to which the joint is linked */
  19965. mainImpostor: PhysicsImpostor;
  19966. /** Defines the impostor that is connected to the main impostor using this joint */
  19967. connectedImpostor: PhysicsImpostor;
  19968. /** Defines the joint itself */
  19969. joint: PhysicsJoint;
  19970. }
  19971. /** @hidden */
  19972. export interface IPhysicsEnginePlugin {
  19973. world: any;
  19974. name: string;
  19975. setGravity(gravity: Vector3): void;
  19976. setTimeStep(timeStep: number): void;
  19977. getTimeStep(): number;
  19978. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19979. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19980. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19981. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19982. removePhysicsBody(impostor: PhysicsImpostor): void;
  19983. generateJoint(joint: PhysicsImpostorJoint): void;
  19984. removeJoint(joint: PhysicsImpostorJoint): void;
  19985. isSupported(): boolean;
  19986. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19987. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19988. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19989. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19990. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19991. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19992. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19993. getBodyMass(impostor: PhysicsImpostor): number;
  19994. getBodyFriction(impostor: PhysicsImpostor): number;
  19995. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19996. getBodyRestitution(impostor: PhysicsImpostor): number;
  19997. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19998. getBodyPressure?(impostor: PhysicsImpostor): number;
  19999. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  20000. getBodyStiffness?(impostor: PhysicsImpostor): number;
  20001. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  20002. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  20003. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  20004. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  20005. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  20006. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20007. sleepBody(impostor: PhysicsImpostor): void;
  20008. wakeUpBody(impostor: PhysicsImpostor): void;
  20009. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20010. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  20011. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  20012. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20013. getRadius(impostor: PhysicsImpostor): number;
  20014. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  20015. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  20016. dispose(): void;
  20017. }
  20018. /**
  20019. * Interface used to define a physics engine
  20020. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  20021. */
  20022. export interface IPhysicsEngine {
  20023. /**
  20024. * Gets the gravity vector used by the simulation
  20025. */
  20026. gravity: Vector3;
  20027. /**
  20028. * Sets the gravity vector used by the simulation
  20029. * @param gravity defines the gravity vector to use
  20030. */
  20031. setGravity(gravity: Vector3): void;
  20032. /**
  20033. * Set the time step of the physics engine.
  20034. * Default is 1/60.
  20035. * To slow it down, enter 1/600 for example.
  20036. * To speed it up, 1/30
  20037. * @param newTimeStep the new timestep to apply to this world.
  20038. */
  20039. setTimeStep(newTimeStep: number): void;
  20040. /**
  20041. * Get the time step of the physics engine.
  20042. * @returns the current time step
  20043. */
  20044. getTimeStep(): number;
  20045. /**
  20046. * Release all resources
  20047. */
  20048. dispose(): void;
  20049. /**
  20050. * Gets the name of the current physics plugin
  20051. * @returns the name of the plugin
  20052. */
  20053. getPhysicsPluginName(): string;
  20054. /**
  20055. * Adding a new impostor for the impostor tracking.
  20056. * This will be done by the impostor itself.
  20057. * @param impostor the impostor to add
  20058. */
  20059. addImpostor(impostor: PhysicsImpostor): void;
  20060. /**
  20061. * Remove an impostor from the engine.
  20062. * This impostor and its mesh will not longer be updated by the physics engine.
  20063. * @param impostor the impostor to remove
  20064. */
  20065. removeImpostor(impostor: PhysicsImpostor): void;
  20066. /**
  20067. * Add a joint to the physics engine
  20068. * @param mainImpostor defines the main impostor to which the joint is added.
  20069. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  20070. * @param joint defines the joint that will connect both impostors.
  20071. */
  20072. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20073. /**
  20074. * Removes a joint from the simulation
  20075. * @param mainImpostor defines the impostor used with the joint
  20076. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  20077. * @param joint defines the joint to remove
  20078. */
  20079. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20080. /**
  20081. * Gets the current plugin used to run the simulation
  20082. * @returns current plugin
  20083. */
  20084. getPhysicsPlugin(): IPhysicsEnginePlugin;
  20085. /**
  20086. * Gets the list of physic impostors
  20087. * @returns an array of PhysicsImpostor
  20088. */
  20089. getImpostors(): Array<PhysicsImpostor>;
  20090. /**
  20091. * Gets the impostor for a physics enabled object
  20092. * @param object defines the object impersonated by the impostor
  20093. * @returns the PhysicsImpostor or null if not found
  20094. */
  20095. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20096. /**
  20097. * Gets the impostor for a physics body object
  20098. * @param body defines physics body used by the impostor
  20099. * @returns the PhysicsImpostor or null if not found
  20100. */
  20101. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  20102. /**
  20103. * Does a raycast in the physics world
  20104. * @param from when should the ray start?
  20105. * @param to when should the ray end?
  20106. * @returns PhysicsRaycastResult
  20107. */
  20108. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20109. /**
  20110. * Called by the scene. No need to call it.
  20111. * @param delta defines the timespam between frames
  20112. */
  20113. _step(delta: number): void;
  20114. }
  20115. }
  20116. declare module "babylonjs/Physics/physicsImpostor" {
  20117. import { Nullable, IndicesArray } from "babylonjs/types";
  20118. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  20119. import { TransformNode } from "babylonjs/Meshes/transformNode";
  20120. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20121. import { Scene } from "babylonjs/scene";
  20122. import { Bone } from "babylonjs/Bones/bone";
  20123. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  20124. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  20125. /**
  20126. * The interface for the physics imposter parameters
  20127. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20128. */
  20129. export interface PhysicsImpostorParameters {
  20130. /**
  20131. * The mass of the physics imposter
  20132. */
  20133. mass: number;
  20134. /**
  20135. * The friction of the physics imposter
  20136. */
  20137. friction?: number;
  20138. /**
  20139. * The coefficient of restitution of the physics imposter
  20140. */
  20141. restitution?: number;
  20142. /**
  20143. * The native options of the physics imposter
  20144. */
  20145. nativeOptions?: any;
  20146. /**
  20147. * Specifies if the parent should be ignored
  20148. */
  20149. ignoreParent?: boolean;
  20150. /**
  20151. * Specifies if bi-directional transformations should be disabled
  20152. */
  20153. disableBidirectionalTransformation?: boolean;
  20154. /**
  20155. * The pressure inside the physics imposter, soft object only
  20156. */
  20157. pressure?: number;
  20158. /**
  20159. * The stiffness the physics imposter, soft object only
  20160. */
  20161. stiffness?: number;
  20162. /**
  20163. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  20164. */
  20165. velocityIterations?: number;
  20166. /**
  20167. * The number of iterations used in maintaining consistent vertex positions, soft object only
  20168. */
  20169. positionIterations?: number;
  20170. /**
  20171. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  20172. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  20173. * Add to fix multiple points
  20174. */
  20175. fixedPoints?: number;
  20176. /**
  20177. * The collision margin around a soft object
  20178. */
  20179. margin?: number;
  20180. /**
  20181. * The collision margin around a soft object
  20182. */
  20183. damping?: number;
  20184. }
  20185. /**
  20186. * Interface for a physics-enabled object
  20187. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20188. */
  20189. export interface IPhysicsEnabledObject {
  20190. /**
  20191. * The position of the physics-enabled object
  20192. */
  20193. position: Vector3;
  20194. /**
  20195. * The rotation of the physics-enabled object
  20196. */
  20197. rotationQuaternion: Nullable<Quaternion>;
  20198. /**
  20199. * The scale of the physics-enabled object
  20200. */
  20201. scaling: Vector3;
  20202. /**
  20203. * The rotation of the physics-enabled object
  20204. */
  20205. rotation?: Vector3;
  20206. /**
  20207. * The parent of the physics-enabled object
  20208. */
  20209. parent?: any;
  20210. /**
  20211. * The bounding info of the physics-enabled object
  20212. * @returns The bounding info of the physics-enabled object
  20213. */
  20214. getBoundingInfo(): BoundingInfo;
  20215. /**
  20216. * Computes the world matrix
  20217. * @param force Specifies if the world matrix should be computed by force
  20218. * @returns A world matrix
  20219. */
  20220. computeWorldMatrix(force: boolean): Matrix;
  20221. /**
  20222. * Gets the world matrix
  20223. * @returns A world matrix
  20224. */
  20225. getWorldMatrix?(): Matrix;
  20226. /**
  20227. * Gets the child meshes
  20228. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20229. * @returns An array of abstract meshes
  20230. */
  20231. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20232. /**
  20233. * Gets the vertex data
  20234. * @param kind The type of vertex data
  20235. * @returns A nullable array of numbers, or a float32 array
  20236. */
  20237. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20238. /**
  20239. * Gets the indices from the mesh
  20240. * @returns A nullable array of index arrays
  20241. */
  20242. getIndices?(): Nullable<IndicesArray>;
  20243. /**
  20244. * Gets the scene from the mesh
  20245. * @returns the indices array or null
  20246. */
  20247. getScene?(): Scene;
  20248. /**
  20249. * Gets the absolute position from the mesh
  20250. * @returns the absolute position
  20251. */
  20252. getAbsolutePosition(): Vector3;
  20253. /**
  20254. * Gets the absolute pivot point from the mesh
  20255. * @returns the absolute pivot point
  20256. */
  20257. getAbsolutePivotPoint(): Vector3;
  20258. /**
  20259. * Rotates the mesh
  20260. * @param axis The axis of rotation
  20261. * @param amount The amount of rotation
  20262. * @param space The space of the rotation
  20263. * @returns The rotation transform node
  20264. */
  20265. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20266. /**
  20267. * Translates the mesh
  20268. * @param axis The axis of translation
  20269. * @param distance The distance of translation
  20270. * @param space The space of the translation
  20271. * @returns The transform node
  20272. */
  20273. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20274. /**
  20275. * Sets the absolute position of the mesh
  20276. * @param absolutePosition The absolute position of the mesh
  20277. * @returns The transform node
  20278. */
  20279. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20280. /**
  20281. * Gets the class name of the mesh
  20282. * @returns The class name
  20283. */
  20284. getClassName(): string;
  20285. }
  20286. /**
  20287. * Represents a physics imposter
  20288. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20289. */
  20290. export class PhysicsImpostor {
  20291. /**
  20292. * The physics-enabled object used as the physics imposter
  20293. */
  20294. object: IPhysicsEnabledObject;
  20295. /**
  20296. * The type of the physics imposter
  20297. */
  20298. type: number;
  20299. private _options;
  20300. private _scene?;
  20301. /**
  20302. * The default object size of the imposter
  20303. */
  20304. static DEFAULT_OBJECT_SIZE: Vector3;
  20305. /**
  20306. * The identity quaternion of the imposter
  20307. */
  20308. static IDENTITY_QUATERNION: Quaternion;
  20309. /** @hidden */
  20310. _pluginData: any;
  20311. private _physicsEngine;
  20312. private _physicsBody;
  20313. private _bodyUpdateRequired;
  20314. private _onBeforePhysicsStepCallbacks;
  20315. private _onAfterPhysicsStepCallbacks;
  20316. /** @hidden */
  20317. _onPhysicsCollideCallbacks: Array<{
  20318. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20319. otherImpostors: Array<PhysicsImpostor>;
  20320. }>;
  20321. private _deltaPosition;
  20322. private _deltaRotation;
  20323. private _deltaRotationConjugated;
  20324. private _parent;
  20325. private _isDisposed;
  20326. private static _tmpVecs;
  20327. private static _tmpQuat;
  20328. /**
  20329. * Specifies if the physics imposter is disposed
  20330. */
  20331. readonly isDisposed: boolean;
  20332. /**
  20333. * Gets the mass of the physics imposter
  20334. */
  20335. mass: number;
  20336. /**
  20337. * Gets the coefficient of friction
  20338. */
  20339. /**
  20340. * Sets the coefficient of friction
  20341. */
  20342. friction: number;
  20343. /**
  20344. * Gets the coefficient of restitution
  20345. */
  20346. /**
  20347. * Sets the coefficient of restitution
  20348. */
  20349. restitution: number;
  20350. /**
  20351. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  20352. */
  20353. /**
  20354. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  20355. */
  20356. pressure: number;
  20357. /**
  20358. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20359. */
  20360. /**
  20361. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20362. */
  20363. stiffness: number;
  20364. /**
  20365. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20366. */
  20367. /**
  20368. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20369. */
  20370. velocityIterations: number;
  20371. /**
  20372. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20373. */
  20374. /**
  20375. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20376. */
  20377. positionIterations: number;
  20378. /**
  20379. * The unique id of the physics imposter
  20380. * set by the physics engine when adding this impostor to the array
  20381. */
  20382. uniqueId: number;
  20383. /**
  20384. * @hidden
  20385. */
  20386. soft: boolean;
  20387. /**
  20388. * @hidden
  20389. */
  20390. segments: number;
  20391. private _joints;
  20392. /**
  20393. * Initializes the physics imposter
  20394. * @param object The physics-enabled object used as the physics imposter
  20395. * @param type The type of the physics imposter
  20396. * @param _options The options for the physics imposter
  20397. * @param _scene The Babylon scene
  20398. */
  20399. constructor(
  20400. /**
  20401. * The physics-enabled object used as the physics imposter
  20402. */
  20403. object: IPhysicsEnabledObject,
  20404. /**
  20405. * The type of the physics imposter
  20406. */
  20407. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20408. /**
  20409. * This function will completly initialize this impostor.
  20410. * It will create a new body - but only if this mesh has no parent.
  20411. * If it has, this impostor will not be used other than to define the impostor
  20412. * of the child mesh.
  20413. * @hidden
  20414. */
  20415. _init(): void;
  20416. private _getPhysicsParent;
  20417. /**
  20418. * Should a new body be generated.
  20419. * @returns boolean specifying if body initialization is required
  20420. */
  20421. isBodyInitRequired(): boolean;
  20422. /**
  20423. * Sets the updated scaling
  20424. * @param updated Specifies if the scaling is updated
  20425. */
  20426. setScalingUpdated(): void;
  20427. /**
  20428. * Force a regeneration of this or the parent's impostor's body.
  20429. * Use under cautious - This will remove all joints already implemented.
  20430. */
  20431. forceUpdate(): void;
  20432. /**
  20433. * Gets the body that holds this impostor. Either its own, or its parent.
  20434. */
  20435. /**
  20436. * Set the physics body. Used mainly by the physics engine/plugin
  20437. */
  20438. physicsBody: any;
  20439. /**
  20440. * Get the parent of the physics imposter
  20441. * @returns Physics imposter or null
  20442. */
  20443. /**
  20444. * Sets the parent of the physics imposter
  20445. */
  20446. parent: Nullable<PhysicsImpostor>;
  20447. /**
  20448. * Resets the update flags
  20449. */
  20450. resetUpdateFlags(): void;
  20451. /**
  20452. * Gets the object extend size
  20453. * @returns the object extend size
  20454. */
  20455. getObjectExtendSize(): Vector3;
  20456. /**
  20457. * Gets the object center
  20458. * @returns The object center
  20459. */
  20460. getObjectCenter(): Vector3;
  20461. /**
  20462. * Get a specific parametes from the options parameter
  20463. * @param paramName The object parameter name
  20464. * @returns The object parameter
  20465. */
  20466. getParam(paramName: string): any;
  20467. /**
  20468. * Sets a specific parameter in the options given to the physics plugin
  20469. * @param paramName The parameter name
  20470. * @param value The value of the parameter
  20471. */
  20472. setParam(paramName: string, value: number): void;
  20473. /**
  20474. * Specifically change the body's mass option. Won't recreate the physics body object
  20475. * @param mass The mass of the physics imposter
  20476. */
  20477. setMass(mass: number): void;
  20478. /**
  20479. * Gets the linear velocity
  20480. * @returns linear velocity or null
  20481. */
  20482. getLinearVelocity(): Nullable<Vector3>;
  20483. /**
  20484. * Sets the linear velocity
  20485. * @param velocity linear velocity or null
  20486. */
  20487. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20488. /**
  20489. * Gets the angular velocity
  20490. * @returns angular velocity or null
  20491. */
  20492. getAngularVelocity(): Nullable<Vector3>;
  20493. /**
  20494. * Sets the angular velocity
  20495. * @param velocity The velocity or null
  20496. */
  20497. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20498. /**
  20499. * Execute a function with the physics plugin native code
  20500. * Provide a function the will have two variables - the world object and the physics body object
  20501. * @param func The function to execute with the physics plugin native code
  20502. */
  20503. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20504. /**
  20505. * Register a function that will be executed before the physics world is stepping forward
  20506. * @param func The function to execute before the physics world is stepped forward
  20507. */
  20508. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20509. /**
  20510. * Unregister a function that will be executed before the physics world is stepping forward
  20511. * @param func The function to execute before the physics world is stepped forward
  20512. */
  20513. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20514. /**
  20515. * Register a function that will be executed after the physics step
  20516. * @param func The function to execute after physics step
  20517. */
  20518. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20519. /**
  20520. * Unregisters a function that will be executed after the physics step
  20521. * @param func The function to execute after physics step
  20522. */
  20523. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20524. /**
  20525. * register a function that will be executed when this impostor collides against a different body
  20526. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20527. * @param func Callback that is executed on collision
  20528. */
  20529. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20530. /**
  20531. * Unregisters the physics imposter on contact
  20532. * @param collideAgainst The physics object to collide against
  20533. * @param func Callback to execute on collision
  20534. */
  20535. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20536. private _tmpQuat;
  20537. private _tmpQuat2;
  20538. /**
  20539. * Get the parent rotation
  20540. * @returns The parent rotation
  20541. */
  20542. getParentsRotation(): Quaternion;
  20543. /**
  20544. * this function is executed by the physics engine.
  20545. */
  20546. beforeStep: () => void;
  20547. /**
  20548. * this function is executed by the physics engine
  20549. */
  20550. afterStep: () => void;
  20551. /**
  20552. * Legacy collision detection event support
  20553. */
  20554. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20555. /**
  20556. * event and body object due to cannon's event-based architecture.
  20557. */
  20558. onCollide: (e: {
  20559. body: any;
  20560. }) => void;
  20561. /**
  20562. * Apply a force
  20563. * @param force The force to apply
  20564. * @param contactPoint The contact point for the force
  20565. * @returns The physics imposter
  20566. */
  20567. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20568. /**
  20569. * Apply an impulse
  20570. * @param force The impulse force
  20571. * @param contactPoint The contact point for the impulse force
  20572. * @returns The physics imposter
  20573. */
  20574. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20575. /**
  20576. * A help function to create a joint
  20577. * @param otherImpostor A physics imposter used to create a joint
  20578. * @param jointType The type of joint
  20579. * @param jointData The data for the joint
  20580. * @returns The physics imposter
  20581. */
  20582. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20583. /**
  20584. * Add a joint to this impostor with a different impostor
  20585. * @param otherImpostor A physics imposter used to add a joint
  20586. * @param joint The joint to add
  20587. * @returns The physics imposter
  20588. */
  20589. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20590. /**
  20591. * Add an anchor to a soft impostor
  20592. * @param otherImpostor rigid impostor as the anchor
  20593. * @param width ratio across width from 0 to 1
  20594. * @param height ratio up height from 0 to 1
  20595. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, no strech
  20596. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  20597. * @returns impostor the soft imposter
  20598. */
  20599. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20600. /**
  20601. * Will keep this body still, in a sleep mode.
  20602. * @returns the physics imposter
  20603. */
  20604. sleep(): PhysicsImpostor;
  20605. /**
  20606. * Wake the body up.
  20607. * @returns The physics imposter
  20608. */
  20609. wakeUp(): PhysicsImpostor;
  20610. /**
  20611. * Clones the physics imposter
  20612. * @param newObject The physics imposter clones to this physics-enabled object
  20613. * @returns A nullable physics imposter
  20614. */
  20615. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20616. /**
  20617. * Disposes the physics imposter
  20618. */
  20619. dispose(): void;
  20620. /**
  20621. * Sets the delta position
  20622. * @param position The delta position amount
  20623. */
  20624. setDeltaPosition(position: Vector3): void;
  20625. /**
  20626. * Sets the delta rotation
  20627. * @param rotation The delta rotation amount
  20628. */
  20629. setDeltaRotation(rotation: Quaternion): void;
  20630. /**
  20631. * Gets the box size of the physics imposter and stores the result in the input parameter
  20632. * @param result Stores the box size
  20633. * @returns The physics imposter
  20634. */
  20635. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20636. /**
  20637. * Gets the radius of the physics imposter
  20638. * @returns Radius of the physics imposter
  20639. */
  20640. getRadius(): number;
  20641. /**
  20642. * Sync a bone with this impostor
  20643. * @param bone The bone to sync to the impostor.
  20644. * @param boneMesh The mesh that the bone is influencing.
  20645. * @param jointPivot The pivot of the joint / bone in local space.
  20646. * @param distToJoint Optional distance from the impostor to the joint.
  20647. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20648. */
  20649. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20650. /**
  20651. * Sync impostor to a bone
  20652. * @param bone The bone that the impostor will be synced to.
  20653. * @param boneMesh The mesh that the bone is influencing.
  20654. * @param jointPivot The pivot of the joint / bone in local space.
  20655. * @param distToJoint Optional distance from the impostor to the joint.
  20656. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20657. * @param boneAxis Optional vector3 axis the bone is aligned with
  20658. */
  20659. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20660. /**
  20661. * No-Imposter type
  20662. */
  20663. static NoImpostor: number;
  20664. /**
  20665. * Sphere-Imposter type
  20666. */
  20667. static SphereImpostor: number;
  20668. /**
  20669. * Box-Imposter type
  20670. */
  20671. static BoxImpostor: number;
  20672. /**
  20673. * Plane-Imposter type
  20674. */
  20675. static PlaneImpostor: number;
  20676. /**
  20677. * Mesh-imposter type
  20678. */
  20679. static MeshImpostor: number;
  20680. /**
  20681. * Cylinder-Imposter type
  20682. */
  20683. static CylinderImpostor: number;
  20684. /**
  20685. * Particle-Imposter type
  20686. */
  20687. static ParticleImpostor: number;
  20688. /**
  20689. * Heightmap-Imposter type
  20690. */
  20691. static HeightmapImpostor: number;
  20692. /**
  20693. * ConvexHull-Impostor type (Ammo.js plugin only)
  20694. */
  20695. static ConvexHullImpostor: number;
  20696. /**
  20697. * Rope-Imposter type
  20698. */
  20699. static RopeImpostor: number;
  20700. /**
  20701. * Cloth-Imposter type
  20702. */
  20703. static ClothImpostor: number;
  20704. /**
  20705. * Softbody-Imposter type
  20706. */
  20707. static SoftbodyImpostor: number;
  20708. }
  20709. }
  20710. declare module "babylonjs/Meshes/mesh" {
  20711. import { Observable } from "babylonjs/Misc/observable";
  20712. import { IAnimatable } from "babylonjs/Misc/tools";
  20713. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  20714. import { Camera } from "babylonjs/Cameras/camera";
  20715. import { Scene } from "babylonjs/scene";
  20716. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  20717. import { Engine } from "babylonjs/Engines/engine";
  20718. import { Node } from "babylonjs/node";
  20719. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20720. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  20721. import { Buffer } from "babylonjs/Meshes/buffer";
  20722. import { Geometry } from "babylonjs/Meshes/geometry";
  20723. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20724. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20725. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  20726. import { Effect } from "babylonjs/Materials/effect";
  20727. import { Material } from "babylonjs/Materials/material";
  20728. import { Skeleton } from "babylonjs/Bones/skeleton";
  20729. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  20730. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  20731. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20732. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  20733. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20734. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  20735. /**
  20736. * Class used to represent a specific level of detail of a mesh
  20737. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20738. */
  20739. export class MeshLODLevel {
  20740. /** Defines the distance where this level should star being displayed */
  20741. distance: number;
  20742. /** Defines the mesh to use to render this level */
  20743. mesh: Nullable<Mesh>;
  20744. /**
  20745. * Creates a new LOD level
  20746. * @param distance defines the distance where this level should star being displayed
  20747. * @param mesh defines the mesh to use to render this level
  20748. */
  20749. constructor(
  20750. /** Defines the distance where this level should star being displayed */
  20751. distance: number,
  20752. /** Defines the mesh to use to render this level */
  20753. mesh: Nullable<Mesh>);
  20754. }
  20755. /**
  20756. * @hidden
  20757. **/
  20758. export class _CreationDataStorage {
  20759. closePath?: boolean;
  20760. closeArray?: boolean;
  20761. idx: number[];
  20762. dashSize: number;
  20763. gapSize: number;
  20764. path3D: Path3D;
  20765. pathArray: Vector3[][];
  20766. arc: number;
  20767. radius: number;
  20768. cap: number;
  20769. tessellation: number;
  20770. }
  20771. /**
  20772. * @hidden
  20773. **/
  20774. class _InstanceDataStorage {
  20775. visibleInstances: any;
  20776. renderIdForInstances: number[];
  20777. batchCache: _InstancesBatch;
  20778. instancesBufferSize: number;
  20779. instancesBuffer: Nullable<Buffer>;
  20780. instancesData: Float32Array;
  20781. overridenInstanceCount: number;
  20782. }
  20783. /**
  20784. * @hidden
  20785. **/
  20786. export class _InstancesBatch {
  20787. mustReturn: boolean;
  20788. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  20789. renderSelf: boolean[];
  20790. }
  20791. /**
  20792. * Class used to represent renderable models
  20793. */
  20794. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20795. /**
  20796. * Mesh side orientation : usually the external or front surface
  20797. */
  20798. static readonly FRONTSIDE: number;
  20799. /**
  20800. * Mesh side orientation : usually the internal or back surface
  20801. */
  20802. static readonly BACKSIDE: number;
  20803. /**
  20804. * Mesh side orientation : both internal and external or front and back surfaces
  20805. */
  20806. static readonly DOUBLESIDE: number;
  20807. /**
  20808. * Mesh side orientation : by default, `FRONTSIDE`
  20809. */
  20810. static readonly DEFAULTSIDE: number;
  20811. /**
  20812. * Mesh cap setting : no cap
  20813. */
  20814. static readonly NO_CAP: number;
  20815. /**
  20816. * Mesh cap setting : one cap at the beginning of the mesh
  20817. */
  20818. static readonly CAP_START: number;
  20819. /**
  20820. * Mesh cap setting : one cap at the end of the mesh
  20821. */
  20822. static readonly CAP_END: number;
  20823. /**
  20824. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20825. */
  20826. static readonly CAP_ALL: number;
  20827. /**
  20828. * Gets the default side orientation.
  20829. * @param orientation the orientation to value to attempt to get
  20830. * @returns the default orientation
  20831. * @hidden
  20832. */
  20833. static _GetDefaultSideOrientation(orientation?: number): number;
  20834. private _onBeforeRenderObservable;
  20835. private _onBeforeBindObservable;
  20836. private _onAfterRenderObservable;
  20837. private _onBeforeDrawObservable;
  20838. /**
  20839. * An event triggered before rendering the mesh
  20840. */
  20841. readonly onBeforeRenderObservable: Observable<Mesh>;
  20842. /**
  20843. * An event triggered before binding the mesh
  20844. */
  20845. readonly onBeforeBindObservable: Observable<Mesh>;
  20846. /**
  20847. * An event triggered after rendering the mesh
  20848. */
  20849. readonly onAfterRenderObservable: Observable<Mesh>;
  20850. /**
  20851. * An event triggered before drawing the mesh
  20852. */
  20853. readonly onBeforeDrawObservable: Observable<Mesh>;
  20854. private _onBeforeDrawObserver;
  20855. /**
  20856. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20857. */
  20858. onBeforeDraw: () => void;
  20859. /**
  20860. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20861. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20862. */
  20863. delayLoadState: number;
  20864. /**
  20865. * Gets the list of instances created from this mesh
  20866. * it is not supposed to be modified manually.
  20867. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20868. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20869. */
  20870. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  20871. /**
  20872. * Gets the file containing delay loading data for this mesh
  20873. */
  20874. delayLoadingFile: string;
  20875. /** @hidden */
  20876. _binaryInfo: any;
  20877. private _LODLevels;
  20878. /**
  20879. * User defined function used to change how LOD level selection is done
  20880. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20881. */
  20882. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20883. private _morphTargetManager;
  20884. /**
  20885. * Gets or sets the morph target manager
  20886. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20887. */
  20888. morphTargetManager: Nullable<MorphTargetManager>;
  20889. /** @hidden */
  20890. _creationDataStorage: Nullable<_CreationDataStorage>;
  20891. /** @hidden */
  20892. _geometry: Nullable<Geometry>;
  20893. /** @hidden */
  20894. _delayInfo: Array<string>;
  20895. /** @hidden */
  20896. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20897. /** @hidden */
  20898. _instanceDataStorage: _InstanceDataStorage;
  20899. private _effectiveMaterial;
  20900. /** @hidden */
  20901. _shouldGenerateFlatShading: boolean;
  20902. private _preActivateId;
  20903. /** @hidden */
  20904. _originalBuilderSideOrientation: number;
  20905. /**
  20906. * Use this property to change the original side orientation defined at construction time
  20907. */
  20908. overrideMaterialSideOrientation: Nullable<number>;
  20909. private _areNormalsFrozen;
  20910. private _sourcePositions;
  20911. private _sourceNormals;
  20912. private _source;
  20913. private meshMap;
  20914. /**
  20915. * Gets the source mesh (the one used to clone this one from)
  20916. */
  20917. readonly source: Nullable<Mesh>;
  20918. /**
  20919. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20920. */
  20921. isUnIndexed: boolean;
  20922. /**
  20923. * @constructor
  20924. * @param name The value used by scene.getMeshByName() to do a lookup.
  20925. * @param scene The scene to add this mesh to.
  20926. * @param parent The parent of this mesh, if it has one
  20927. * @param source An optional Mesh from which geometry is shared, cloned.
  20928. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20929. * When false, achieved by calling a clone(), also passing False.
  20930. * This will make creation of children, recursive.
  20931. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20932. */
  20933. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20934. /**
  20935. * Gets the class name
  20936. * @returns the string "Mesh".
  20937. */
  20938. getClassName(): string;
  20939. /** @hidden */
  20940. readonly _isMesh: boolean;
  20941. /**
  20942. * Returns a description of this mesh
  20943. * @param fullDetails define if full details about this mesh must be used
  20944. * @returns a descriptive string representing this mesh
  20945. */
  20946. toString(fullDetails?: boolean): string;
  20947. /** @hidden */
  20948. _unBindEffect(): void;
  20949. /**
  20950. * Gets a boolean indicating if this mesh has LOD
  20951. */
  20952. readonly hasLODLevels: boolean;
  20953. /**
  20954. * Gets the list of MeshLODLevel associated with the current mesh
  20955. * @returns an array of MeshLODLevel
  20956. */
  20957. getLODLevels(): MeshLODLevel[];
  20958. private _sortLODLevels;
  20959. /**
  20960. * Add a mesh as LOD level triggered at the given distance.
  20961. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20962. * @param distance The distance from the center of the object to show this level
  20963. * @param mesh The mesh to be added as LOD level (can be null)
  20964. * @return This mesh (for chaining)
  20965. */
  20966. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20967. /**
  20968. * Returns the LOD level mesh at the passed distance or null if not found.
  20969. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20970. * @param distance The distance from the center of the object to show this level
  20971. * @returns a Mesh or `null`
  20972. */
  20973. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20974. /**
  20975. * Remove a mesh from the LOD array
  20976. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20977. * @param mesh defines the mesh to be removed
  20978. * @return This mesh (for chaining)
  20979. */
  20980. removeLODLevel(mesh: Mesh): Mesh;
  20981. /**
  20982. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20983. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20984. * @param camera defines the camera to use to compute distance
  20985. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  20986. * @return This mesh (for chaining)
  20987. */
  20988. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20989. /**
  20990. * Gets the mesh internal Geometry object
  20991. */
  20992. readonly geometry: Nullable<Geometry>;
  20993. /**
  20994. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20995. * @returns the total number of vertices
  20996. */
  20997. getTotalVertices(): number;
  20998. /**
  20999. * Returns the content of an associated vertex buffer
  21000. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21001. * - VertexBuffer.PositionKind
  21002. * - VertexBuffer.UVKind
  21003. * - VertexBuffer.UV2Kind
  21004. * - VertexBuffer.UV3Kind
  21005. * - VertexBuffer.UV4Kind
  21006. * - VertexBuffer.UV5Kind
  21007. * - VertexBuffer.UV6Kind
  21008. * - VertexBuffer.ColorKind
  21009. * - VertexBuffer.MatricesIndicesKind
  21010. * - VertexBuffer.MatricesIndicesExtraKind
  21011. * - VertexBuffer.MatricesWeightsKind
  21012. * - VertexBuffer.MatricesWeightsExtraKind
  21013. * @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
  21014. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  21015. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  21016. */
  21017. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21018. /**
  21019. * Returns the mesh VertexBuffer object from the requested `kind`
  21020. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21021. * - VertexBuffer.PositionKind
  21022. * - VertexBuffer.UVKind
  21023. * - VertexBuffer.UV2Kind
  21024. * - VertexBuffer.UV3Kind
  21025. * - VertexBuffer.UV4Kind
  21026. * - VertexBuffer.UV5Kind
  21027. * - VertexBuffer.UV6Kind
  21028. * - VertexBuffer.ColorKind
  21029. * - VertexBuffer.MatricesIndicesKind
  21030. * - VertexBuffer.MatricesIndicesExtraKind
  21031. * - VertexBuffer.MatricesWeightsKind
  21032. * - VertexBuffer.MatricesWeightsExtraKind
  21033. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  21034. */
  21035. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21036. /**
  21037. * Tests if a specific vertex buffer is associated with this mesh
  21038. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21039. * - VertexBuffer.PositionKind
  21040. * - VertexBuffer.UVKind
  21041. * - VertexBuffer.UV2Kind
  21042. * - VertexBuffer.UV3Kind
  21043. * - VertexBuffer.UV4Kind
  21044. * - VertexBuffer.UV5Kind
  21045. * - VertexBuffer.UV6Kind
  21046. * - VertexBuffer.ColorKind
  21047. * - VertexBuffer.MatricesIndicesKind
  21048. * - VertexBuffer.MatricesIndicesExtraKind
  21049. * - VertexBuffer.MatricesWeightsKind
  21050. * - VertexBuffer.MatricesWeightsExtraKind
  21051. * @returns a boolean
  21052. */
  21053. isVerticesDataPresent(kind: string): boolean;
  21054. /**
  21055. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21056. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21057. * - VertexBuffer.PositionKind
  21058. * - VertexBuffer.UVKind
  21059. * - VertexBuffer.UV2Kind
  21060. * - VertexBuffer.UV3Kind
  21061. * - VertexBuffer.UV4Kind
  21062. * - VertexBuffer.UV5Kind
  21063. * - VertexBuffer.UV6Kind
  21064. * - VertexBuffer.ColorKind
  21065. * - VertexBuffer.MatricesIndicesKind
  21066. * - VertexBuffer.MatricesIndicesExtraKind
  21067. * - VertexBuffer.MatricesWeightsKind
  21068. * - VertexBuffer.MatricesWeightsExtraKind
  21069. * @returns a boolean
  21070. */
  21071. isVertexBufferUpdatable(kind: string): boolean;
  21072. /**
  21073. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  21074. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21075. * - VertexBuffer.PositionKind
  21076. * - VertexBuffer.UVKind
  21077. * - VertexBuffer.UV2Kind
  21078. * - VertexBuffer.UV3Kind
  21079. * - VertexBuffer.UV4Kind
  21080. * - VertexBuffer.UV5Kind
  21081. * - VertexBuffer.UV6Kind
  21082. * - VertexBuffer.ColorKind
  21083. * - VertexBuffer.MatricesIndicesKind
  21084. * - VertexBuffer.MatricesIndicesExtraKind
  21085. * - VertexBuffer.MatricesWeightsKind
  21086. * - VertexBuffer.MatricesWeightsExtraKind
  21087. * @returns an array of strings
  21088. */
  21089. getVerticesDataKinds(): string[];
  21090. /**
  21091. * Returns a positive integer : the total number of indices in this mesh geometry.
  21092. * @returns the numner of indices or zero if the mesh has no geometry.
  21093. */
  21094. getTotalIndices(): number;
  21095. /**
  21096. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21097. * @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.
  21098. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21099. * @returns the indices array or an empty array if the mesh has no geometry
  21100. */
  21101. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21102. readonly isBlocked: boolean;
  21103. /**
  21104. * Determine if the current mesh is ready to be rendered
  21105. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21106. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21107. * @returns true if all associated assets are ready (material, textures, shaders)
  21108. */
  21109. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21110. /**
  21111. * 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.
  21112. */
  21113. readonly areNormalsFrozen: boolean;
  21114. /**
  21115. * 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.
  21116. * @returns the current mesh
  21117. */
  21118. freezeNormals(): Mesh;
  21119. /**
  21120. * 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
  21121. * @returns the current mesh
  21122. */
  21123. unfreezeNormals(): Mesh;
  21124. /**
  21125. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21126. */
  21127. overridenInstanceCount: number;
  21128. /** @hidden */
  21129. _preActivate(): Mesh;
  21130. /** @hidden */
  21131. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21132. /** @hidden */
  21133. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21134. /**
  21135. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21136. * This means the mesh underlying bounding box and sphere are recomputed.
  21137. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  21138. * @returns the current mesh
  21139. */
  21140. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  21141. /** @hidden */
  21142. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21143. /**
  21144. * This function will subdivide the mesh into multiple submeshes
  21145. * @param count defines the expected number of submeshes
  21146. */
  21147. subdivide(count: number): void;
  21148. /**
  21149. * Copy a FloatArray into a specific associated vertex buffer
  21150. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21151. * - VertexBuffer.PositionKind
  21152. * - VertexBuffer.UVKind
  21153. * - VertexBuffer.UV2Kind
  21154. * - VertexBuffer.UV3Kind
  21155. * - VertexBuffer.UV4Kind
  21156. * - VertexBuffer.UV5Kind
  21157. * - VertexBuffer.UV6Kind
  21158. * - VertexBuffer.ColorKind
  21159. * - VertexBuffer.MatricesIndicesKind
  21160. * - VertexBuffer.MatricesIndicesExtraKind
  21161. * - VertexBuffer.MatricesWeightsKind
  21162. * - VertexBuffer.MatricesWeightsExtraKind
  21163. * @param data defines the data source
  21164. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21165. * @param stride defines the data stride size (can be null)
  21166. * @returns the current mesh
  21167. */
  21168. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21169. /**
  21170. * Flags an associated vertex buffer as updatable
  21171. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  21172. * - VertexBuffer.PositionKind
  21173. * - VertexBuffer.UVKind
  21174. * - VertexBuffer.UV2Kind
  21175. * - VertexBuffer.UV3Kind
  21176. * - VertexBuffer.UV4Kind
  21177. * - VertexBuffer.UV5Kind
  21178. * - VertexBuffer.UV6Kind
  21179. * - VertexBuffer.ColorKind
  21180. * - VertexBuffer.MatricesIndicesKind
  21181. * - VertexBuffer.MatricesIndicesExtraKind
  21182. * - VertexBuffer.MatricesWeightsKind
  21183. * - VertexBuffer.MatricesWeightsExtraKind
  21184. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21185. */
  21186. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21187. /**
  21188. * Sets the mesh global Vertex Buffer
  21189. * @param buffer defines the buffer to use
  21190. * @returns the current mesh
  21191. */
  21192. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21193. /**
  21194. * Update a specific associated vertex buffer
  21195. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21196. * - VertexBuffer.PositionKind
  21197. * - VertexBuffer.UVKind
  21198. * - VertexBuffer.UV2Kind
  21199. * - VertexBuffer.UV3Kind
  21200. * - VertexBuffer.UV4Kind
  21201. * - VertexBuffer.UV5Kind
  21202. * - VertexBuffer.UV6Kind
  21203. * - VertexBuffer.ColorKind
  21204. * - VertexBuffer.MatricesIndicesKind
  21205. * - VertexBuffer.MatricesIndicesExtraKind
  21206. * - VertexBuffer.MatricesWeightsKind
  21207. * - VertexBuffer.MatricesWeightsExtraKind
  21208. * @param data defines the data source
  21209. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21210. * @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)
  21211. * @returns the current mesh
  21212. */
  21213. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21214. /**
  21215. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21216. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21217. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  21218. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  21219. * @returns the current mesh
  21220. */
  21221. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21222. /**
  21223. * Creates a un-shared specific occurence of the geometry for the mesh.
  21224. * @returns the current mesh
  21225. */
  21226. makeGeometryUnique(): Mesh;
  21227. /**
  21228. * Set the index buffer of this mesh
  21229. * @param indices defines the source data
  21230. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  21231. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  21232. * @returns the current mesh
  21233. */
  21234. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21235. /**
  21236. * Update the current index buffer
  21237. * @param indices defines the source data
  21238. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  21239. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  21240. * @returns the current mesh
  21241. */
  21242. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  21243. /**
  21244. * Invert the geometry to move from a right handed system to a left handed one.
  21245. * @returns the current mesh
  21246. */
  21247. toLeftHanded(): Mesh;
  21248. /** @hidden */
  21249. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21250. /** @hidden */
  21251. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  21252. /**
  21253. * Registers for this mesh a javascript function called just before the rendering process
  21254. * @param func defines the function to call before rendering this mesh
  21255. * @returns the current mesh
  21256. */
  21257. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21258. /**
  21259. * Disposes a previously registered javascript function called before the rendering
  21260. * @param func defines the function to remove
  21261. * @returns the current mesh
  21262. */
  21263. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21264. /**
  21265. * Registers for this mesh a javascript function called just after the rendering is complete
  21266. * @param func defines the function to call after rendering this mesh
  21267. * @returns the current mesh
  21268. */
  21269. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21270. /**
  21271. * Disposes a previously registered javascript function called after the rendering.
  21272. * @param func defines the function to remove
  21273. * @returns the current mesh
  21274. */
  21275. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21276. /** @hidden */
  21277. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21278. /** @hidden */
  21279. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21280. /** @hidden */
  21281. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21282. /**
  21283. * 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
  21284. * @param subMesh defines the subMesh to render
  21285. * @param enableAlphaMode defines if alpha mode can be changed
  21286. * @returns the current mesh
  21287. */
  21288. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21289. private _onBeforeDraw;
  21290. /**
  21291. * Renormalize the mesh and patch it up if there are no weights
  21292. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21293. * However in the case of zero weights then we set just a single influence to 1.
  21294. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21295. */
  21296. cleanMatrixWeights(): void;
  21297. private normalizeSkinFourWeights;
  21298. private normalizeSkinWeightsAndExtra;
  21299. /**
  21300. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21301. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21302. * the user know there was an issue with importing the mesh
  21303. * @returns a validation object with skinned, valid and report string
  21304. */
  21305. validateSkinning(): {
  21306. skinned: boolean;
  21307. valid: boolean;
  21308. report: string;
  21309. };
  21310. /** @hidden */
  21311. _checkDelayState(): Mesh;
  21312. private _queueLoad;
  21313. /**
  21314. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21315. * A mesh is in the frustum if its bounding box intersects the frustum
  21316. * @param frustumPlanes defines the frustum to test
  21317. * @returns true if the mesh is in the frustum planes
  21318. */
  21319. isInFrustum(frustumPlanes: Plane[]): boolean;
  21320. /**
  21321. * Sets the mesh material by the material or multiMaterial `id` property
  21322. * @param id is a string identifying the material or the multiMaterial
  21323. * @returns the current mesh
  21324. */
  21325. setMaterialByID(id: string): Mesh;
  21326. /**
  21327. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21328. * @returns an array of IAnimatable
  21329. */
  21330. getAnimatables(): IAnimatable[];
  21331. /**
  21332. * Modifies the mesh geometry according to the passed transformation matrix.
  21333. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21334. * The mesh normals are modified using the same transformation.
  21335. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21336. * @param transform defines the transform matrix to use
  21337. * @see http://doc.babylonjs.com/resources/baking_transformations
  21338. * @returns the current mesh
  21339. */
  21340. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21341. /**
  21342. * Modifies the mesh geometry according to its own current World Matrix.
  21343. * The mesh World Matrix is then reset.
  21344. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21345. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21346. * @see http://doc.babylonjs.com/resources/baking_transformations
  21347. * @returns the current mesh
  21348. */
  21349. bakeCurrentTransformIntoVertices(): Mesh;
  21350. /** @hidden */
  21351. readonly _positions: Nullable<Vector3[]>;
  21352. /** @hidden */
  21353. _resetPointsArrayCache(): Mesh;
  21354. /** @hidden */
  21355. _generatePointsArray(): boolean;
  21356. /**
  21357. * Returns a new Mesh object generated from the current mesh properties.
  21358. * This method must not get confused with createInstance()
  21359. * @param name is a string, the name given to the new mesh
  21360. * @param newParent can be any Node object (default `null`)
  21361. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  21362. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21363. * @returns a new mesh
  21364. */
  21365. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21366. /**
  21367. * Releases resources associated with this mesh.
  21368. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21369. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21370. */
  21371. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21372. /**
  21373. * Modifies the mesh geometry according to a displacement map.
  21374. * 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.
  21375. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21376. * @param url is a string, the URL from the image file is to be downloaded.
  21377. * @param minHeight is the lower limit of the displacement.
  21378. * @param maxHeight is the upper limit of the displacement.
  21379. * @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.
  21380. * @param uvOffset is an optional vector2 used to offset UV.
  21381. * @param uvScale is an optional vector2 used to scale UV.
  21382. * @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.
  21383. * @returns the Mesh.
  21384. */
  21385. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21386. /**
  21387. * Modifies the mesh geometry according to a displacementMap buffer.
  21388. * 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.
  21389. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21390. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21391. * @param heightMapWidth is the width of the buffer image.
  21392. * @param heightMapHeight is the height of the buffer image.
  21393. * @param minHeight is the lower limit of the displacement.
  21394. * @param maxHeight is the upper limit of the displacement.
  21395. * @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.
  21396. * @param uvOffset is an optional vector2 used to offset UV.
  21397. * @param uvScale is an optional vector2 used to scale UV.
  21398. * @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.
  21399. * @returns the Mesh.
  21400. */
  21401. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21402. /**
  21403. * Modify the mesh to get a flat shading rendering.
  21404. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21405. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21406. * @returns current mesh
  21407. */
  21408. convertToFlatShadedMesh(): Mesh;
  21409. /**
  21410. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21411. * In other words, more vertices, no more indices and a single bigger VBO.
  21412. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21413. * @returns current mesh
  21414. */
  21415. convertToUnIndexedMesh(): Mesh;
  21416. /**
  21417. * Inverses facet orientations.
  21418. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21419. * @param flipNormals will also inverts the normals
  21420. * @returns current mesh
  21421. */
  21422. flipFaces(flipNormals?: boolean): Mesh;
  21423. /**
  21424. * Increase the number of facets and hence vertices in a mesh
  21425. * Vertex normals are interpolated from existing vertex normals
  21426. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21427. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  21428. */
  21429. increaseVertices(numberPerEdge: number): void;
  21430. /**
  21431. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  21432. * This will undo any application of covertToFlatShadedMesh
  21433. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21434. */
  21435. forceSharedVertices(): void;
  21436. /** @hidden */
  21437. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21438. /** @hidden */
  21439. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21440. /**
  21441. * Creates a new InstancedMesh object from the mesh model.
  21442. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21443. * @param name defines the name of the new instance
  21444. * @returns a new InstancedMesh
  21445. */
  21446. createInstance(name: string): InstancedMesh;
  21447. /**
  21448. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21449. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21450. * @returns the current mesh
  21451. */
  21452. synchronizeInstances(): Mesh;
  21453. /**
  21454. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21455. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21456. * This should be used together with the simplification to avoid disappearing triangles.
  21457. * @param successCallback an optional success callback to be called after the optimization finished.
  21458. * @returns the current mesh
  21459. */
  21460. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21461. /**
  21462. * Serialize current mesh
  21463. * @param serializationObject defines the object which will receive the serialization data
  21464. */
  21465. serialize(serializationObject: any): void;
  21466. /** @hidden */
  21467. _syncGeometryWithMorphTargetManager(): void;
  21468. /** @hidden */
  21469. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21470. /**
  21471. * Returns a new Mesh object parsed from the source provided.
  21472. * @param parsedMesh is the source
  21473. * @param scene defines the hosting scene
  21474. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21475. * @returns a new Mesh
  21476. */
  21477. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21478. /**
  21479. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21480. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21481. * @param name defines the name of the mesh to create
  21482. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21483. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21484. * @param closePath creates a seam between the first and the last points of each path of the path array
  21485. * @param offset is taken in account only if the `pathArray` is containing a single path
  21486. * @param scene defines the hosting scene
  21487. * @param updatable defines if the mesh must be flagged as updatable
  21488. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21489. * @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)
  21490. * @returns a new Mesh
  21491. */
  21492. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21493. /**
  21494. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21495. * @param name defines the name of the mesh to create
  21496. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21497. * @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
  21498. * @param scene defines the hosting scene
  21499. * @param updatable defines if the mesh must be flagged as updatable
  21500. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21501. * @returns a new Mesh
  21502. */
  21503. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21504. /**
  21505. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21506. * @param name defines the name of the mesh to create
  21507. * @param size sets the size (float) of each box side (default 1)
  21508. * @param scene defines the hosting scene
  21509. * @param updatable defines if the mesh must be flagged as updatable
  21510. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21511. * @returns a new Mesh
  21512. */
  21513. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21514. /**
  21515. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21516. * @param name defines the name of the mesh to create
  21517. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21518. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21519. * @param scene defines the hosting scene
  21520. * @param updatable defines if the mesh must be flagged as updatable
  21521. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21522. * @returns a new Mesh
  21523. */
  21524. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21525. /**
  21526. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21527. * @param name defines the name of the mesh to create
  21528. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21529. * @param diameterTop set the top cap diameter (floats, default 1)
  21530. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21531. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21532. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21533. * @param scene defines the hosting scene
  21534. * @param updatable defines if the mesh must be flagged as updatable
  21535. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21536. * @returns a new Mesh
  21537. */
  21538. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21539. /**
  21540. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21541. * @param name defines the name of the mesh to create
  21542. * @param diameter sets the diameter size (float) of the torus (default 1)
  21543. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21544. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21545. * @param scene defines the hosting scene
  21546. * @param updatable defines if the mesh must be flagged as updatable
  21547. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21548. * @returns a new Mesh
  21549. */
  21550. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21551. /**
  21552. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21553. * @param name defines the name of the mesh to create
  21554. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21555. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21556. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21557. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21558. * @param p the number of windings on X axis (positive integers, default 2)
  21559. * @param q the number of windings on Y axis (positive integers, default 3)
  21560. * @param scene defines the hosting scene
  21561. * @param updatable defines if the mesh must be flagged as updatable
  21562. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21563. * @returns a new Mesh
  21564. */
  21565. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21566. /**
  21567. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21568. * @param name defines the name of the mesh to create
  21569. * @param points is an array successive Vector3
  21570. * @param scene defines the hosting scene
  21571. * @param updatable defines if the mesh must be flagged as updatable
  21572. * @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).
  21573. * @returns a new Mesh
  21574. */
  21575. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21576. /**
  21577. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21578. * @param name defines the name of the mesh to create
  21579. * @param points is an array successive Vector3
  21580. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21581. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21582. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21583. * @param scene defines the hosting scene
  21584. * @param updatable defines if the mesh must be flagged as updatable
  21585. * @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)
  21586. * @returns a new Mesh
  21587. */
  21588. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21589. /**
  21590. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21591. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21592. * 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.
  21593. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21594. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21595. * Remember you can only change the shape positions, not their number when updating a polygon.
  21596. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21597. * @param name defines the name of the mesh to create
  21598. * @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
  21599. * @param scene defines the hosting scene
  21600. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21601. * @param updatable defines if the mesh must be flagged as updatable
  21602. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21603. * @param earcutInjection can be used to inject your own earcut reference
  21604. * @returns a new Mesh
  21605. */
  21606. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21607. /**
  21608. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21609. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21610. * @param name defines the name of the mesh to create
  21611. * @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
  21612. * @param depth defines the height of extrusion
  21613. * @param scene defines the hosting scene
  21614. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21615. * @param updatable defines if the mesh must be flagged as updatable
  21616. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21617. * @param earcutInjection can be used to inject your own earcut reference
  21618. * @returns a new Mesh
  21619. */
  21620. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21621. /**
  21622. * Creates an extruded shape mesh.
  21623. * 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
  21624. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21625. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21626. * @param name defines the name of the mesh to create
  21627. * @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
  21628. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21629. * @param scale is the value to scale the shape
  21630. * @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
  21631. * @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
  21632. * @param scene defines the hosting scene
  21633. * @param updatable defines if the mesh must be flagged as updatable
  21634. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21635. * @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)
  21636. * @returns a new Mesh
  21637. */
  21638. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21639. /**
  21640. * Creates an custom extruded shape mesh.
  21641. * The custom extrusion is a parametric shape.
  21642. * It has no predefined shape. Its final shape will depend on the input parameters.
  21643. * Please consider using the same method from the MeshBuilder class instead
  21644. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21645. * @param name defines the name of the mesh to create
  21646. * @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
  21647. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21648. * @param scaleFunction is a custom Javascript function called on each path point
  21649. * @param rotationFunction is a custom Javascript function called on each path point
  21650. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21651. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21652. * @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
  21653. * @param scene defines the hosting scene
  21654. * @param updatable defines if the mesh must be flagged as updatable
  21655. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21656. * @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)
  21657. * @returns a new Mesh
  21658. */
  21659. 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;
  21660. /**
  21661. * Creates lathe mesh.
  21662. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21663. * Please consider using the same method from the MeshBuilder class instead
  21664. * @param name defines the name of the mesh to create
  21665. * @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
  21666. * @param radius is the radius value of the lathe
  21667. * @param tessellation is the side number of the lathe.
  21668. * @param scene defines the hosting scene
  21669. * @param updatable defines if the mesh must be flagged as updatable
  21670. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21671. * @returns a new Mesh
  21672. */
  21673. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21674. /**
  21675. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21676. * @param name defines the name of the mesh to create
  21677. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21678. * @param scene defines the hosting scene
  21679. * @param updatable defines if the mesh must be flagged as updatable
  21680. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21681. * @returns a new Mesh
  21682. */
  21683. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21684. /**
  21685. * Creates a ground mesh.
  21686. * Please consider using the same method from the MeshBuilder class instead
  21687. * @param name defines the name of the mesh to create
  21688. * @param width set the width of the ground
  21689. * @param height set the height of the ground
  21690. * @param subdivisions sets the number of subdivisions per side
  21691. * @param scene defines the hosting scene
  21692. * @param updatable defines if the mesh must be flagged as updatable
  21693. * @returns a new Mesh
  21694. */
  21695. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21696. /**
  21697. * Creates a tiled ground mesh.
  21698. * Please consider using the same method from the MeshBuilder class instead
  21699. * @param name defines the name of the mesh to create
  21700. * @param xmin set the ground minimum X coordinate
  21701. * @param zmin set the ground minimum Y coordinate
  21702. * @param xmax set the ground maximum X coordinate
  21703. * @param zmax set the ground maximum Z coordinate
  21704. * @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
  21705. * @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
  21706. * @param scene defines the hosting scene
  21707. * @param updatable defines if the mesh must be flagged as updatable
  21708. * @returns a new Mesh
  21709. */
  21710. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21711. w: number;
  21712. h: number;
  21713. }, precision: {
  21714. w: number;
  21715. h: number;
  21716. }, scene: Scene, updatable?: boolean): Mesh;
  21717. /**
  21718. * Creates a ground mesh from a height map.
  21719. * Please consider using the same method from the MeshBuilder class instead
  21720. * @see http://doc.babylonjs.com/babylon101/height_map
  21721. * @param name defines the name of the mesh to create
  21722. * @param url sets the URL of the height map image resource
  21723. * @param width set the ground width size
  21724. * @param height set the ground height size
  21725. * @param subdivisions sets the number of subdivision per side
  21726. * @param minHeight is the minimum altitude on the ground
  21727. * @param maxHeight is the maximum altitude on the ground
  21728. * @param scene defines the hosting scene
  21729. * @param updatable defines if the mesh must be flagged as updatable
  21730. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21731. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21732. * @returns a new Mesh
  21733. */
  21734. 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;
  21735. /**
  21736. * Creates a tube mesh.
  21737. * The tube is a parametric shape.
  21738. * It has no predefined shape. Its final shape will depend on the input parameters.
  21739. * Please consider using the same method from the MeshBuilder class instead
  21740. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21741. * @param name defines the name of the mesh to create
  21742. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21743. * @param radius sets the tube radius size
  21744. * @param tessellation is the number of sides on the tubular surface
  21745. * @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
  21746. * @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
  21747. * @param scene defines the hosting scene
  21748. * @param updatable defines if the mesh must be flagged as updatable
  21749. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21750. * @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)
  21751. * @returns a new Mesh
  21752. */
  21753. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21754. (i: number, distance: number): number;
  21755. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21756. /**
  21757. * Creates a polyhedron mesh.
  21758. * Please consider using the same method from the MeshBuilder class instead.
  21759. * * 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
  21760. * * The parameter `size` (positive float, default 1) sets the polygon size
  21761. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21762. * * 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`
  21763. * * 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
  21764. * * 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)`)
  21765. * * 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
  21766. * * 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
  21767. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21768. * * If you create a double-sided mesh, you can choose what parts of 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
  21769. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21770. * @param name defines the name of the mesh to create
  21771. * @param options defines the options used to create the mesh
  21772. * @param scene defines the hosting scene
  21773. * @returns a new Mesh
  21774. */
  21775. static CreatePolyhedron(name: string, options: {
  21776. type?: number;
  21777. size?: number;
  21778. sizeX?: number;
  21779. sizeY?: number;
  21780. sizeZ?: number;
  21781. custom?: any;
  21782. faceUV?: Vector4[];
  21783. faceColors?: Color4[];
  21784. updatable?: boolean;
  21785. sideOrientation?: number;
  21786. }, scene: Scene): Mesh;
  21787. /**
  21788. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21789. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21790. * * 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`)
  21791. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21792. * * 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
  21793. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21794. * * If you create a double-sided mesh, you can choose what parts of 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
  21795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21796. * @param name defines the name of the mesh
  21797. * @param options defines the options used to create the mesh
  21798. * @param scene defines the hosting scene
  21799. * @returns a new Mesh
  21800. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21801. */
  21802. static CreateIcoSphere(name: string, options: {
  21803. radius?: number;
  21804. flat?: boolean;
  21805. subdivisions?: number;
  21806. sideOrientation?: number;
  21807. updatable?: boolean;
  21808. }, scene: Scene): Mesh;
  21809. /**
  21810. * Creates a decal mesh.
  21811. * Please consider using the same method from the MeshBuilder class instead.
  21812. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21813. * @param name defines the name of the mesh
  21814. * @param sourceMesh defines the mesh receiving the decal
  21815. * @param position sets the position of the decal in world coordinates
  21816. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21817. * @param size sets the decal scaling
  21818. * @param angle sets the angle to rotate the decal
  21819. * @returns a new Mesh
  21820. */
  21821. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21822. /**
  21823. * Prepare internal position array for software CPU skinning
  21824. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21825. */
  21826. setPositionsForCPUSkinning(): Float32Array;
  21827. /**
  21828. * Prepare internal normal array for software CPU skinning
  21829. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21830. */
  21831. setNormalsForCPUSkinning(): Float32Array;
  21832. /**
  21833. * Updates the vertex buffer by applying transformation from the bones
  21834. * @param skeleton defines the skeleton to apply to current mesh
  21835. * @returns the current mesh
  21836. */
  21837. applySkeleton(skeleton: Skeleton): Mesh;
  21838. /**
  21839. * 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
  21840. * @param meshes defines the list of meshes to scan
  21841. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21842. */
  21843. static MinMax(meshes: AbstractMesh[]): {
  21844. min: Vector3;
  21845. max: Vector3;
  21846. };
  21847. /**
  21848. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21849. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21850. * @returns a vector3
  21851. */
  21852. static Center(meshesOrMinMaxVector: {
  21853. min: Vector3;
  21854. max: Vector3;
  21855. } | AbstractMesh[]): Vector3;
  21856. /**
  21857. * Merge the array of meshes into a single mesh for performance reasons.
  21858. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21859. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21860. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21861. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21862. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21863. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21864. * @returns a new mesh
  21865. */
  21866. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21867. /** @hidden */
  21868. addInstance(instance: InstancedMesh): void;
  21869. /** @hidden */
  21870. removeInstance(instance: InstancedMesh): void;
  21871. }
  21872. }
  21873. declare module "babylonjs/Materials/material" {
  21874. import { IAnimatable } from "babylonjs/Misc/tools";
  21875. import { SmartArray } from "babylonjs/Misc/smartArray";
  21876. import { Observable } from "babylonjs/Misc/observable";
  21877. import { Nullable } from "babylonjs/types";
  21878. import { Scene } from "babylonjs/scene";
  21879. import { Matrix } from "babylonjs/Maths/math";
  21880. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21881. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21882. import { Mesh } from "babylonjs/Meshes/mesh";
  21883. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21884. import { Effect } from "babylonjs/Materials/effect";
  21885. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21886. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21887. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21888. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21889. import { Animation } from "babylonjs/Animations/animation";
  21890. /**
  21891. * Base class for the main features of a material in Babylon.js
  21892. */
  21893. export class Material implements IAnimatable {
  21894. /**
  21895. * Returns the triangle fill mode
  21896. */
  21897. static readonly TriangleFillMode: number;
  21898. /**
  21899. * Returns the wireframe mode
  21900. */
  21901. static readonly WireFrameFillMode: number;
  21902. /**
  21903. * Returns the point fill mode
  21904. */
  21905. static readonly PointFillMode: number;
  21906. /**
  21907. * Returns the point list draw mode
  21908. */
  21909. static readonly PointListDrawMode: number;
  21910. /**
  21911. * Returns the line list draw mode
  21912. */
  21913. static readonly LineListDrawMode: number;
  21914. /**
  21915. * Returns the line loop draw mode
  21916. */
  21917. static readonly LineLoopDrawMode: number;
  21918. /**
  21919. * Returns the line strip draw mode
  21920. */
  21921. static readonly LineStripDrawMode: number;
  21922. /**
  21923. * Returns the triangle strip draw mode
  21924. */
  21925. static readonly TriangleStripDrawMode: number;
  21926. /**
  21927. * Returns the triangle fan draw mode
  21928. */
  21929. static readonly TriangleFanDrawMode: number;
  21930. /**
  21931. * Stores the clock-wise side orientation
  21932. */
  21933. static readonly ClockWiseSideOrientation: number;
  21934. /**
  21935. * Stores the counter clock-wise side orientation
  21936. */
  21937. static readonly CounterClockWiseSideOrientation: number;
  21938. /**
  21939. * The dirty texture flag value
  21940. */
  21941. static readonly TextureDirtyFlag: number;
  21942. /**
  21943. * The dirty light flag value
  21944. */
  21945. static readonly LightDirtyFlag: number;
  21946. /**
  21947. * The dirty fresnel flag value
  21948. */
  21949. static readonly FresnelDirtyFlag: number;
  21950. /**
  21951. * The dirty attribute flag value
  21952. */
  21953. static readonly AttributesDirtyFlag: number;
  21954. /**
  21955. * The dirty misc flag value
  21956. */
  21957. static readonly MiscDirtyFlag: number;
  21958. /**
  21959. * The all dirty flag value
  21960. */
  21961. static readonly AllDirtyFlag: number;
  21962. /**
  21963. * The ID of the material
  21964. */
  21965. id: string;
  21966. /**
  21967. * Gets or sets the unique id of the material
  21968. */
  21969. uniqueId: number;
  21970. /**
  21971. * The name of the material
  21972. */
  21973. name: string;
  21974. /**
  21975. * Gets or sets user defined metadata
  21976. */
  21977. metadata: any;
  21978. /**
  21979. * For internal use only. Please do not use.
  21980. */
  21981. reservedDataStore: any;
  21982. /**
  21983. * Specifies if the ready state should be checked on each call
  21984. */
  21985. checkReadyOnEveryCall: boolean;
  21986. /**
  21987. * Specifies if the ready state should be checked once
  21988. */
  21989. checkReadyOnlyOnce: boolean;
  21990. /**
  21991. * The state of the material
  21992. */
  21993. state: string;
  21994. /**
  21995. * The alpha value of the material
  21996. */
  21997. protected _alpha: number;
  21998. /**
  21999. * List of inspectable custom properties (used by the Inspector)
  22000. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22001. */
  22002. inspectableCustomProperties: IInspectable[];
  22003. /**
  22004. * Sets the alpha value of the material
  22005. */
  22006. /**
  22007. * Gets the alpha value of the material
  22008. */
  22009. alpha: number;
  22010. /**
  22011. * Specifies if back face culling is enabled
  22012. */
  22013. protected _backFaceCulling: boolean;
  22014. /**
  22015. * Sets the back-face culling state
  22016. */
  22017. /**
  22018. * Gets the back-face culling state
  22019. */
  22020. backFaceCulling: boolean;
  22021. /**
  22022. * Stores the value for side orientation
  22023. */
  22024. sideOrientation: number;
  22025. /**
  22026. * Callback triggered when the material is compiled
  22027. */
  22028. onCompiled: (effect: Effect) => void;
  22029. /**
  22030. * Callback triggered when an error occurs
  22031. */
  22032. onError: (effect: Effect, errors: string) => void;
  22033. /**
  22034. * Callback triggered to get the render target textures
  22035. */
  22036. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  22037. /**
  22038. * Gets a boolean indicating that current material needs to register RTT
  22039. */
  22040. readonly hasRenderTargetTextures: boolean;
  22041. /**
  22042. * Specifies if the material should be serialized
  22043. */
  22044. doNotSerialize: boolean;
  22045. /**
  22046. * @hidden
  22047. */
  22048. _storeEffectOnSubMeshes: boolean;
  22049. /**
  22050. * Stores the animations for the material
  22051. */
  22052. animations: Array<Animation>;
  22053. /**
  22054. * An event triggered when the material is disposed
  22055. */
  22056. onDisposeObservable: Observable<Material>;
  22057. /**
  22058. * An observer which watches for dispose events
  22059. */
  22060. private _onDisposeObserver;
  22061. private _onUnBindObservable;
  22062. /**
  22063. * Called during a dispose event
  22064. */
  22065. onDispose: () => void;
  22066. private _onBindObservable;
  22067. /**
  22068. * An event triggered when the material is bound
  22069. */
  22070. readonly onBindObservable: Observable<AbstractMesh>;
  22071. /**
  22072. * An observer which watches for bind events
  22073. */
  22074. private _onBindObserver;
  22075. /**
  22076. * Called during a bind event
  22077. */
  22078. onBind: (Mesh: AbstractMesh) => void;
  22079. /**
  22080. * An event triggered when the material is unbound
  22081. */
  22082. readonly onUnBindObservable: Observable<Material>;
  22083. /**
  22084. * Stores the value of the alpha mode
  22085. */
  22086. private _alphaMode;
  22087. /**
  22088. * Sets the value of the alpha mode.
  22089. *
  22090. * | Value | Type | Description |
  22091. * | --- | --- | --- |
  22092. * | 0 | ALPHA_DISABLE | |
  22093. * | 1 | ALPHA_ADD | |
  22094. * | 2 | ALPHA_COMBINE | |
  22095. * | 3 | ALPHA_SUBTRACT | |
  22096. * | 4 | ALPHA_MULTIPLY | |
  22097. * | 5 | ALPHA_MAXIMIZED | |
  22098. * | 6 | ALPHA_ONEONE | |
  22099. * | 7 | ALPHA_PREMULTIPLIED | |
  22100. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22101. * | 9 | ALPHA_INTERPOLATE | |
  22102. * | 10 | ALPHA_SCREENMODE | |
  22103. *
  22104. */
  22105. /**
  22106. * Gets the value of the alpha mode
  22107. */
  22108. alphaMode: number;
  22109. /**
  22110. * Stores the state of the need depth pre-pass value
  22111. */
  22112. private _needDepthPrePass;
  22113. /**
  22114. * Sets the need depth pre-pass value
  22115. */
  22116. /**
  22117. * Gets the depth pre-pass value
  22118. */
  22119. needDepthPrePass: boolean;
  22120. /**
  22121. * Specifies if depth writing should be disabled
  22122. */
  22123. disableDepthWrite: boolean;
  22124. /**
  22125. * Specifies if depth writing should be forced
  22126. */
  22127. forceDepthWrite: boolean;
  22128. /**
  22129. * Specifies if there should be a separate pass for culling
  22130. */
  22131. separateCullingPass: boolean;
  22132. /**
  22133. * Stores the state specifing if fog should be enabled
  22134. */
  22135. private _fogEnabled;
  22136. /**
  22137. * Sets the state for enabling fog
  22138. */
  22139. /**
  22140. * Gets the value of the fog enabled state
  22141. */
  22142. fogEnabled: boolean;
  22143. /**
  22144. * Stores the size of points
  22145. */
  22146. pointSize: number;
  22147. /**
  22148. * Stores the z offset value
  22149. */
  22150. zOffset: number;
  22151. /**
  22152. * Gets a value specifying if wireframe mode is enabled
  22153. */
  22154. /**
  22155. * Sets the state of wireframe mode
  22156. */
  22157. wireframe: boolean;
  22158. /**
  22159. * Gets the value specifying if point clouds are enabled
  22160. */
  22161. /**
  22162. * Sets the state of point cloud mode
  22163. */
  22164. pointsCloud: boolean;
  22165. /**
  22166. * Gets the material fill mode
  22167. */
  22168. /**
  22169. * Sets the material fill mode
  22170. */
  22171. fillMode: number;
  22172. /**
  22173. * @hidden
  22174. * Stores the effects for the material
  22175. */
  22176. _effect: Nullable<Effect>;
  22177. /**
  22178. * @hidden
  22179. * Specifies if the material was previously ready
  22180. */
  22181. _wasPreviouslyReady: boolean;
  22182. /**
  22183. * Specifies if uniform buffers should be used
  22184. */
  22185. private _useUBO;
  22186. /**
  22187. * Stores a reference to the scene
  22188. */
  22189. private _scene;
  22190. /**
  22191. * Stores the fill mode state
  22192. */
  22193. private _fillMode;
  22194. /**
  22195. * Specifies if the depth write state should be cached
  22196. */
  22197. private _cachedDepthWriteState;
  22198. /**
  22199. * Stores the uniform buffer
  22200. */
  22201. protected _uniformBuffer: UniformBuffer;
  22202. /** @hidden */
  22203. _indexInSceneMaterialArray: number;
  22204. /** @hidden */
  22205. meshMap: Nullable<{
  22206. [id: string]: AbstractMesh | undefined;
  22207. }>;
  22208. /**
  22209. * Creates a material instance
  22210. * @param name defines the name of the material
  22211. * @param scene defines the scene to reference
  22212. * @param doNotAdd specifies if the material should be added to the scene
  22213. */
  22214. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22215. /**
  22216. * Returns a string representation of the current material
  22217. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22218. * @returns a string with material information
  22219. */
  22220. toString(fullDetails?: boolean): string;
  22221. /**
  22222. * Gets the class name of the material
  22223. * @returns a string with the class name of the material
  22224. */
  22225. getClassName(): string;
  22226. /**
  22227. * Specifies if updates for the material been locked
  22228. */
  22229. readonly isFrozen: boolean;
  22230. /**
  22231. * Locks updates for the material
  22232. */
  22233. freeze(): void;
  22234. /**
  22235. * Unlocks updates for the material
  22236. */
  22237. unfreeze(): void;
  22238. /**
  22239. * Specifies if the material is ready to be used
  22240. * @param mesh defines the mesh to check
  22241. * @param useInstances specifies if instances should be used
  22242. * @returns a boolean indicating if the material is ready to be used
  22243. */
  22244. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22245. /**
  22246. * Specifies that the submesh is ready to be used
  22247. * @param mesh defines the mesh to check
  22248. * @param subMesh defines which submesh to check
  22249. * @param useInstances specifies that instances should be used
  22250. * @returns a boolean indicating that the submesh is ready or not
  22251. */
  22252. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22253. /**
  22254. * Returns the material effect
  22255. * @returns the effect associated with the material
  22256. */
  22257. getEffect(): Nullable<Effect>;
  22258. /**
  22259. * Returns the current scene
  22260. * @returns a Scene
  22261. */
  22262. getScene(): Scene;
  22263. /**
  22264. * Specifies if the material will require alpha blending
  22265. * @returns a boolean specifying if alpha blending is needed
  22266. */
  22267. needAlphaBlending(): boolean;
  22268. /**
  22269. * Specifies if the mesh will require alpha blending
  22270. * @param mesh defines the mesh to check
  22271. * @returns a boolean specifying if alpha blending is needed for the mesh
  22272. */
  22273. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22274. /**
  22275. * Specifies if this material should be rendered in alpha test mode
  22276. * @returns a boolean specifying if an alpha test is needed.
  22277. */
  22278. needAlphaTesting(): boolean;
  22279. /**
  22280. * Gets the texture used for the alpha test
  22281. * @returns the texture to use for alpha testing
  22282. */
  22283. getAlphaTestTexture(): Nullable<BaseTexture>;
  22284. /**
  22285. * Marks the material to indicate that it needs to be re-calculated
  22286. */
  22287. markDirty(): void;
  22288. /** @hidden */
  22289. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22290. /**
  22291. * Binds the material to the mesh
  22292. * @param world defines the world transformation matrix
  22293. * @param mesh defines the mesh to bind the material to
  22294. */
  22295. bind(world: Matrix, mesh?: Mesh): void;
  22296. /**
  22297. * Binds the submesh to the material
  22298. * @param world defines the world transformation matrix
  22299. * @param mesh defines the mesh containing the submesh
  22300. * @param subMesh defines the submesh to bind the material to
  22301. */
  22302. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22303. /**
  22304. * Binds the world matrix to the material
  22305. * @param world defines the world transformation matrix
  22306. */
  22307. bindOnlyWorldMatrix(world: Matrix): void;
  22308. /**
  22309. * Binds the scene's uniform buffer to the effect.
  22310. * @param effect defines the effect to bind to the scene uniform buffer
  22311. * @param sceneUbo defines the uniform buffer storing scene data
  22312. */
  22313. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22314. /**
  22315. * Binds the view matrix to the effect
  22316. * @param effect defines the effect to bind the view matrix to
  22317. */
  22318. bindView(effect: Effect): void;
  22319. /**
  22320. * Binds the view projection matrix to the effect
  22321. * @param effect defines the effect to bind the view projection matrix to
  22322. */
  22323. bindViewProjection(effect: Effect): void;
  22324. /**
  22325. * Specifies if material alpha testing should be turned on for the mesh
  22326. * @param mesh defines the mesh to check
  22327. */
  22328. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22329. /**
  22330. * Processes to execute after binding the material to a mesh
  22331. * @param mesh defines the rendered mesh
  22332. */
  22333. protected _afterBind(mesh?: Mesh): void;
  22334. /**
  22335. * Unbinds the material from the mesh
  22336. */
  22337. unbind(): void;
  22338. /**
  22339. * Gets the active textures from the material
  22340. * @returns an array of textures
  22341. */
  22342. getActiveTextures(): BaseTexture[];
  22343. /**
  22344. * Specifies if the material uses a texture
  22345. * @param texture defines the texture to check against the material
  22346. * @returns a boolean specifying if the material uses the texture
  22347. */
  22348. hasTexture(texture: BaseTexture): boolean;
  22349. /**
  22350. * Makes a duplicate of the material, and gives it a new name
  22351. * @param name defines the new name for the duplicated material
  22352. * @returns the cloned material
  22353. */
  22354. clone(name: string): Nullable<Material>;
  22355. /**
  22356. * Gets the meshes bound to the material
  22357. * @returns an array of meshes bound to the material
  22358. */
  22359. getBindedMeshes(): AbstractMesh[];
  22360. /**
  22361. * Force shader compilation
  22362. * @param mesh defines the mesh associated with this material
  22363. * @param onCompiled defines a function to execute once the material is compiled
  22364. * @param options defines the options to configure the compilation
  22365. */
  22366. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22367. clipPlane: boolean;
  22368. }>): void;
  22369. /**
  22370. * Force shader compilation
  22371. * @param mesh defines the mesh that will use this material
  22372. * @param options defines additional options for compiling the shaders
  22373. * @returns a promise that resolves when the compilation completes
  22374. */
  22375. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22376. clipPlane: boolean;
  22377. }>): Promise<void>;
  22378. private static readonly _ImageProcessingDirtyCallBack;
  22379. private static readonly _TextureDirtyCallBack;
  22380. private static readonly _FresnelDirtyCallBack;
  22381. private static readonly _MiscDirtyCallBack;
  22382. private static readonly _LightsDirtyCallBack;
  22383. private static readonly _AttributeDirtyCallBack;
  22384. private static _FresnelAndMiscDirtyCallBack;
  22385. private static _TextureAndMiscDirtyCallBack;
  22386. private static readonly _DirtyCallbackArray;
  22387. private static readonly _RunDirtyCallBacks;
  22388. /**
  22389. * Marks a define in the material to indicate that it needs to be re-computed
  22390. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22391. */
  22392. markAsDirty(flag: number): void;
  22393. /**
  22394. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22395. * @param func defines a function which checks material defines against the submeshes
  22396. */
  22397. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22398. /**
  22399. * Indicates that image processing needs to be re-calculated for all submeshes
  22400. */
  22401. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22402. /**
  22403. * Indicates that textures need to be re-calculated for all submeshes
  22404. */
  22405. protected _markAllSubMeshesAsTexturesDirty(): void;
  22406. /**
  22407. * Indicates that fresnel needs to be re-calculated for all submeshes
  22408. */
  22409. protected _markAllSubMeshesAsFresnelDirty(): void;
  22410. /**
  22411. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22412. */
  22413. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22414. /**
  22415. * Indicates that lights need to be re-calculated for all submeshes
  22416. */
  22417. protected _markAllSubMeshesAsLightsDirty(): void;
  22418. /**
  22419. * Indicates that attributes need to be re-calculated for all submeshes
  22420. */
  22421. protected _markAllSubMeshesAsAttributesDirty(): void;
  22422. /**
  22423. * Indicates that misc needs to be re-calculated for all submeshes
  22424. */
  22425. protected _markAllSubMeshesAsMiscDirty(): void;
  22426. /**
  22427. * Indicates that textures and misc need to be re-calculated for all submeshes
  22428. */
  22429. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22430. /**
  22431. * Disposes the material
  22432. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22433. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22434. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22435. */
  22436. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22437. /** @hidden */
  22438. private releaseVertexArrayObject;
  22439. /**
  22440. * Serializes this material
  22441. * @returns the serialized material object
  22442. */
  22443. serialize(): any;
  22444. /**
  22445. * Creates a material from parsed material data
  22446. * @param parsedMaterial defines parsed material data
  22447. * @param scene defines the hosting scene
  22448. * @param rootUrl defines the root URL to use to load textures
  22449. * @returns a new material
  22450. */
  22451. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  22452. }
  22453. }
  22454. declare module "babylonjs/Meshes/subMesh" {
  22455. import { Nullable, IndicesArray, DeepImmutable } from "babylonjs/types";
  22456. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  22457. import { Engine } from "babylonjs/Engines/engine";
  22458. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22459. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22460. import { Effect } from "babylonjs/Materials/effect";
  22461. import { Collider } from "babylonjs/Collisions/collider";
  22462. import { Material } from "babylonjs/Materials/material";
  22463. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22464. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22465. import { Mesh } from "babylonjs/Meshes/mesh";
  22466. import { Ray } from "babylonjs/Culling/ray";
  22467. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22468. /**
  22469. * Base class for submeshes
  22470. */
  22471. export class BaseSubMesh {
  22472. /** @hidden */
  22473. _materialDefines: Nullable<MaterialDefines>;
  22474. /** @hidden */
  22475. _materialEffect: Nullable<Effect>;
  22476. /**
  22477. * Gets associated effect
  22478. */
  22479. readonly effect: Nullable<Effect>;
  22480. /**
  22481. * Sets associated effect (effect used to render this submesh)
  22482. * @param effect defines the effect to associate with
  22483. * @param defines defines the set of defines used to compile this effect
  22484. */
  22485. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22486. }
  22487. /**
  22488. * Defines a subdivision inside a mesh
  22489. */
  22490. export class SubMesh extends BaseSubMesh implements ICullable {
  22491. /** the material index to use */
  22492. materialIndex: number;
  22493. /** vertex index start */
  22494. verticesStart: number;
  22495. /** vertices count */
  22496. verticesCount: number;
  22497. /** index start */
  22498. indexStart: number;
  22499. /** indices count */
  22500. indexCount: number;
  22501. /** @hidden */
  22502. _linesIndexCount: number;
  22503. private _mesh;
  22504. private _renderingMesh;
  22505. private _boundingInfo;
  22506. private _linesIndexBuffer;
  22507. /** @hidden */
  22508. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22509. /** @hidden */
  22510. _trianglePlanes: Plane[];
  22511. /** @hidden */
  22512. _lastColliderTransformMatrix: Matrix;
  22513. /** @hidden */
  22514. _renderId: number;
  22515. /** @hidden */
  22516. _alphaIndex: number;
  22517. /** @hidden */
  22518. _distanceToCamera: number;
  22519. /** @hidden */
  22520. _id: number;
  22521. private _currentMaterial;
  22522. /**
  22523. * Add a new submesh to a mesh
  22524. * @param materialIndex defines the material index to use
  22525. * @param verticesStart defines vertex index start
  22526. * @param verticesCount defines vertices count
  22527. * @param indexStart defines index start
  22528. * @param indexCount defines indices count
  22529. * @param mesh defines the parent mesh
  22530. * @param renderingMesh defines an optional rendering mesh
  22531. * @param createBoundingBox defines if bounding box should be created for this submesh
  22532. * @returns the new submesh
  22533. */
  22534. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22535. /**
  22536. * Creates a new submesh
  22537. * @param materialIndex defines the material index to use
  22538. * @param verticesStart defines vertex index start
  22539. * @param verticesCount defines vertices count
  22540. * @param indexStart defines index start
  22541. * @param indexCount defines indices count
  22542. * @param mesh defines the parent mesh
  22543. * @param renderingMesh defines an optional rendering mesh
  22544. * @param createBoundingBox defines if bounding box should be created for this submesh
  22545. */
  22546. constructor(
  22547. /** the material index to use */
  22548. materialIndex: number,
  22549. /** vertex index start */
  22550. verticesStart: number,
  22551. /** vertices count */
  22552. verticesCount: number,
  22553. /** index start */
  22554. indexStart: number,
  22555. /** indices count */
  22556. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22557. /**
  22558. * Returns true if this submesh covers the entire parent mesh
  22559. * @ignorenaming
  22560. */
  22561. readonly IsGlobal: boolean;
  22562. /**
  22563. * Returns the submesh BoudingInfo object
  22564. * @returns current bounding info (or mesh's one if the submesh is global)
  22565. */
  22566. getBoundingInfo(): BoundingInfo;
  22567. /**
  22568. * Sets the submesh BoundingInfo
  22569. * @param boundingInfo defines the new bounding info to use
  22570. * @returns the SubMesh
  22571. */
  22572. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22573. /**
  22574. * Returns the mesh of the current submesh
  22575. * @return the parent mesh
  22576. */
  22577. getMesh(): AbstractMesh;
  22578. /**
  22579. * Returns the rendering mesh of the submesh
  22580. * @returns the rendering mesh (could be different from parent mesh)
  22581. */
  22582. getRenderingMesh(): Mesh;
  22583. /**
  22584. * Returns the submesh material
  22585. * @returns null or the current material
  22586. */
  22587. getMaterial(): Nullable<Material>;
  22588. /**
  22589. * Sets a new updated BoundingInfo object to the submesh
  22590. * @returns the SubMesh
  22591. */
  22592. refreshBoundingInfo(): SubMesh;
  22593. /** @hidden */
  22594. _checkCollision(collider: Collider): boolean;
  22595. /**
  22596. * Updates the submesh BoundingInfo
  22597. * @param world defines the world matrix to use to update the bounding info
  22598. * @returns the submesh
  22599. */
  22600. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22601. /**
  22602. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22603. * @param frustumPlanes defines the frustum planes
  22604. * @returns true if the submesh is intersecting with the frustum
  22605. */
  22606. isInFrustum(frustumPlanes: Plane[]): boolean;
  22607. /**
  22608. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22609. * @param frustumPlanes defines the frustum planes
  22610. * @returns true if the submesh is inside the frustum
  22611. */
  22612. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22613. /**
  22614. * Renders the submesh
  22615. * @param enableAlphaMode defines if alpha needs to be used
  22616. * @returns the submesh
  22617. */
  22618. render(enableAlphaMode: boolean): SubMesh;
  22619. /**
  22620. * @hidden
  22621. */
  22622. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22623. /**
  22624. * Checks if the submesh intersects with a ray
  22625. * @param ray defines the ray to test
  22626. * @returns true is the passed ray intersects the submesh bounding box
  22627. */
  22628. canIntersects(ray: Ray): boolean;
  22629. /**
  22630. * Intersects current submesh with a ray
  22631. * @param ray defines the ray to test
  22632. * @param positions defines mesh's positions array
  22633. * @param indices defines mesh's indices array
  22634. * @param fastCheck defines if only bounding info should be used
  22635. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22636. * @returns intersection info or null if no intersection
  22637. */
  22638. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22639. /** @hidden */
  22640. private _intersectLines;
  22641. /** @hidden */
  22642. private _intersectTriangles;
  22643. /** @hidden */
  22644. _rebuild(): void;
  22645. /**
  22646. * Creates a new submesh from the passed mesh
  22647. * @param newMesh defines the new hosting mesh
  22648. * @param newRenderingMesh defines an optional rendering mesh
  22649. * @returns the new submesh
  22650. */
  22651. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22652. /**
  22653. * Release associated resources
  22654. */
  22655. dispose(): void;
  22656. /**
  22657. * Gets the class name
  22658. * @returns the string "SubMesh".
  22659. */
  22660. getClassName(): string;
  22661. /**
  22662. * Creates a new submesh from indices data
  22663. * @param materialIndex the index of the main mesh material
  22664. * @param startIndex the index where to start the copy in the mesh indices array
  22665. * @param indexCount the number of indices to copy then from the startIndex
  22666. * @param mesh the main mesh to create the submesh from
  22667. * @param renderingMesh the optional rendering mesh
  22668. * @returns a new submesh
  22669. */
  22670. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22671. }
  22672. }
  22673. declare module "babylonjs/Meshes/geometry" {
  22674. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22675. import { Scene } from "babylonjs/scene";
  22676. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  22677. import { Engine } from "babylonjs/Engines/engine";
  22678. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22679. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22680. import { Effect } from "babylonjs/Materials/effect";
  22681. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22682. import { Mesh } from "babylonjs/Meshes/mesh";
  22683. /**
  22684. * Class used to store geometry data (vertex buffers + index buffer)
  22685. */
  22686. export class Geometry implements IGetSetVerticesData {
  22687. /**
  22688. * Gets or sets the ID of the geometry
  22689. */
  22690. id: string;
  22691. /**
  22692. * Gets or sets the unique ID of the geometry
  22693. */
  22694. uniqueId: number;
  22695. /**
  22696. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22697. */
  22698. delayLoadState: number;
  22699. /**
  22700. * Gets the file containing the data to load when running in delay load state
  22701. */
  22702. delayLoadingFile: Nullable<string>;
  22703. /**
  22704. * Callback called when the geometry is updated
  22705. */
  22706. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22707. private _scene;
  22708. private _engine;
  22709. private _meshes;
  22710. private _totalVertices;
  22711. /** @hidden */
  22712. _indices: IndicesArray;
  22713. /** @hidden */
  22714. _vertexBuffers: {
  22715. [key: string]: VertexBuffer;
  22716. };
  22717. private _isDisposed;
  22718. private _extend;
  22719. private _boundingBias;
  22720. /** @hidden */
  22721. _delayInfo: Array<string>;
  22722. private _indexBuffer;
  22723. private _indexBufferIsUpdatable;
  22724. /** @hidden */
  22725. _boundingInfo: Nullable<BoundingInfo>;
  22726. /** @hidden */
  22727. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22728. /** @hidden */
  22729. _softwareSkinningFrameId: number;
  22730. private _vertexArrayObjects;
  22731. private _updatable;
  22732. /** @hidden */
  22733. _positions: Nullable<Vector3[]>;
  22734. /**
  22735. * 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
  22736. */
  22737. /**
  22738. * 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
  22739. */
  22740. boundingBias: Vector2;
  22741. /**
  22742. * Static function used to attach a new empty geometry to a mesh
  22743. * @param mesh defines the mesh to attach the geometry to
  22744. * @returns the new Geometry
  22745. */
  22746. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22747. /**
  22748. * Creates a new geometry
  22749. * @param id defines the unique ID
  22750. * @param scene defines the hosting scene
  22751. * @param vertexData defines the VertexData used to get geometry data
  22752. * @param updatable defines if geometry must be updatable (false by default)
  22753. * @param mesh defines the mesh that will be associated with the geometry
  22754. */
  22755. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22756. /**
  22757. * Gets the current extend of the geometry
  22758. */
  22759. readonly extend: {
  22760. minimum: Vector3;
  22761. maximum: Vector3;
  22762. };
  22763. /**
  22764. * Gets the hosting scene
  22765. * @returns the hosting Scene
  22766. */
  22767. getScene(): Scene;
  22768. /**
  22769. * Gets the hosting engine
  22770. * @returns the hosting Engine
  22771. */
  22772. getEngine(): Engine;
  22773. /**
  22774. * Defines if the geometry is ready to use
  22775. * @returns true if the geometry is ready to be used
  22776. */
  22777. isReady(): boolean;
  22778. /**
  22779. * Gets a value indicating that the geometry should not be serialized
  22780. */
  22781. readonly doNotSerialize: boolean;
  22782. /** @hidden */
  22783. _rebuild(): void;
  22784. /**
  22785. * Affects all geometry data in one call
  22786. * @param vertexData defines the geometry data
  22787. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22788. */
  22789. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22790. /**
  22791. * Set specific vertex data
  22792. * @param kind defines the data kind (Position, normal, etc...)
  22793. * @param data defines the vertex data to use
  22794. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22795. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22796. */
  22797. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22798. /**
  22799. * Removes a specific vertex data
  22800. * @param kind defines the data kind (Position, normal, etc...)
  22801. */
  22802. removeVerticesData(kind: string): void;
  22803. /**
  22804. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22805. * @param buffer defines the vertex buffer to use
  22806. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22807. */
  22808. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22809. /**
  22810. * Update a specific vertex buffer
  22811. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  22812. * It will do nothing if the buffer is not updatable
  22813. * @param kind defines the data kind (Position, normal, etc...)
  22814. * @param data defines the data to use
  22815. * @param offset defines the offset in the target buffer where to store the data
  22816. * @param useBytes set to true if the offset is in bytes
  22817. */
  22818. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22819. /**
  22820. * Update a specific vertex buffer
  22821. * This function will create a new buffer if the current one is not updatable
  22822. * @param kind defines the data kind (Position, normal, etc...)
  22823. * @param data defines the data to use
  22824. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22825. */
  22826. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22827. private _updateBoundingInfo;
  22828. /** @hidden */
  22829. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  22830. /**
  22831. * Gets total number of vertices
  22832. * @returns the total number of vertices
  22833. */
  22834. getTotalVertices(): number;
  22835. /**
  22836. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22837. * @param kind defines the data kind (Position, normal, etc...)
  22838. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22839. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22840. * @returns a float array containing vertex data
  22841. */
  22842. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22843. /**
  22844. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22845. * @param kind defines the data kind (Position, normal, etc...)
  22846. * @returns true if the vertex buffer with the specified kind is updatable
  22847. */
  22848. isVertexBufferUpdatable(kind: string): boolean;
  22849. /**
  22850. * Gets a specific vertex buffer
  22851. * @param kind defines the data kind (Position, normal, etc...)
  22852. * @returns a VertexBuffer
  22853. */
  22854. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22855. /**
  22856. * Returns all vertex buffers
  22857. * @return an object holding all vertex buffers indexed by kind
  22858. */
  22859. getVertexBuffers(): Nullable<{
  22860. [key: string]: VertexBuffer;
  22861. }>;
  22862. /**
  22863. * Gets a boolean indicating if specific vertex buffer is present
  22864. * @param kind defines the data kind (Position, normal, etc...)
  22865. * @returns true if data is present
  22866. */
  22867. isVerticesDataPresent(kind: string): boolean;
  22868. /**
  22869. * Gets a list of all attached data kinds (Position, normal, etc...)
  22870. * @returns a list of string containing all kinds
  22871. */
  22872. getVerticesDataKinds(): string[];
  22873. /**
  22874. * Update index buffer
  22875. * @param indices defines the indices to store in the index buffer
  22876. * @param offset defines the offset in the target buffer where to store the data
  22877. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  22878. */
  22879. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22880. /**
  22881. * Creates a new index buffer
  22882. * @param indices defines the indices to store in the index buffer
  22883. * @param totalVertices defines the total number of vertices (could be null)
  22884. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22885. */
  22886. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22887. /**
  22888. * Return the total number of indices
  22889. * @returns the total number of indices
  22890. */
  22891. getTotalIndices(): number;
  22892. /**
  22893. * Gets the index buffer array
  22894. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22895. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22896. * @returns the index buffer array
  22897. */
  22898. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22899. /**
  22900. * Gets the index buffer
  22901. * @return the index buffer
  22902. */
  22903. getIndexBuffer(): Nullable<WebGLBuffer>;
  22904. /** @hidden */
  22905. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22906. /**
  22907. * Release the associated resources for a specific mesh
  22908. * @param mesh defines the source mesh
  22909. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22910. */
  22911. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22912. /**
  22913. * Apply current geometry to a given mesh
  22914. * @param mesh defines the mesh to apply geometry to
  22915. */
  22916. applyToMesh(mesh: Mesh): void;
  22917. private _updateExtend;
  22918. private _applyToMesh;
  22919. private notifyUpdate;
  22920. /**
  22921. * Load the geometry if it was flagged as delay loaded
  22922. * @param scene defines the hosting scene
  22923. * @param onLoaded defines a callback called when the geometry is loaded
  22924. */
  22925. load(scene: Scene, onLoaded?: () => void): void;
  22926. private _queueLoad;
  22927. /**
  22928. * Invert the geometry to move from a right handed system to a left handed one.
  22929. */
  22930. toLeftHanded(): void;
  22931. /** @hidden */
  22932. _resetPointsArrayCache(): void;
  22933. /** @hidden */
  22934. _generatePointsArray(): boolean;
  22935. /**
  22936. * Gets a value indicating if the geometry is disposed
  22937. * @returns true if the geometry was disposed
  22938. */
  22939. isDisposed(): boolean;
  22940. private _disposeVertexArrayObjects;
  22941. /**
  22942. * Free all associated resources
  22943. */
  22944. dispose(): void;
  22945. /**
  22946. * Clone the current geometry into a new geometry
  22947. * @param id defines the unique ID of the new geometry
  22948. * @returns a new geometry object
  22949. */
  22950. copy(id: string): Geometry;
  22951. /**
  22952. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22953. * @return a JSON representation of the current geometry data (without the vertices data)
  22954. */
  22955. serialize(): any;
  22956. private toNumberArray;
  22957. /**
  22958. * Serialize all vertices data into a JSON oject
  22959. * @returns a JSON representation of the current geometry data
  22960. */
  22961. serializeVerticeData(): any;
  22962. /**
  22963. * Extracts a clone of a mesh geometry
  22964. * @param mesh defines the source mesh
  22965. * @param id defines the unique ID of the new geometry object
  22966. * @returns the new geometry object
  22967. */
  22968. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22969. /**
  22970. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22971. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22972. * Be aware Math.random() could cause collisions, but:
  22973. * "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"
  22974. * @returns a string containing a new GUID
  22975. */
  22976. static RandomId(): string;
  22977. /** @hidden */
  22978. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22979. private static _CleanMatricesWeights;
  22980. /**
  22981. * Create a new geometry from persisted data (Using .babylon file format)
  22982. * @param parsedVertexData defines the persisted data
  22983. * @param scene defines the hosting scene
  22984. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22985. * @returns the new geometry object
  22986. */
  22987. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22988. }
  22989. }
  22990. declare module "babylonjs/Meshes/mesh.vertexData" {
  22991. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22992. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  22993. import { Geometry } from "babylonjs/Meshes/geometry";
  22994. import { Mesh } from "babylonjs/Meshes/mesh";
  22995. /**
  22996. * Define an interface for all classes that will get and set the data on vertices
  22997. */
  22998. export interface IGetSetVerticesData {
  22999. /**
  23000. * Gets a boolean indicating if specific vertex data is present
  23001. * @param kind defines the vertex data kind to use
  23002. * @returns true is data kind is present
  23003. */
  23004. isVerticesDataPresent(kind: string): boolean;
  23005. /**
  23006. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23007. * @param kind defines the data kind (Position, normal, etc...)
  23008. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23009. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23010. * @returns a float array containing vertex data
  23011. */
  23012. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23013. /**
  23014. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23015. * @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.
  23016. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23017. * @returns the indices array or an empty array if the mesh has no geometry
  23018. */
  23019. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23020. /**
  23021. * Set specific vertex data
  23022. * @param kind defines the data kind (Position, normal, etc...)
  23023. * @param data defines the vertex data to use
  23024. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23025. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23026. */
  23027. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23028. /**
  23029. * Update a specific associated vertex buffer
  23030. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23031. * - VertexBuffer.PositionKind
  23032. * - VertexBuffer.UVKind
  23033. * - VertexBuffer.UV2Kind
  23034. * - VertexBuffer.UV3Kind
  23035. * - VertexBuffer.UV4Kind
  23036. * - VertexBuffer.UV5Kind
  23037. * - VertexBuffer.UV6Kind
  23038. * - VertexBuffer.ColorKind
  23039. * - VertexBuffer.MatricesIndicesKind
  23040. * - VertexBuffer.MatricesIndicesExtraKind
  23041. * - VertexBuffer.MatricesWeightsKind
  23042. * - VertexBuffer.MatricesWeightsExtraKind
  23043. * @param data defines the data source
  23044. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23045. * @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)
  23046. */
  23047. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23048. /**
  23049. * Creates a new index buffer
  23050. * @param indices defines the indices to store in the index buffer
  23051. * @param totalVertices defines the total number of vertices (could be null)
  23052. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23053. */
  23054. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23055. }
  23056. /**
  23057. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23058. */
  23059. export class VertexData {
  23060. /**
  23061. * Mesh side orientation : usually the external or front surface
  23062. */
  23063. static readonly FRONTSIDE: number;
  23064. /**
  23065. * Mesh side orientation : usually the internal or back surface
  23066. */
  23067. static readonly BACKSIDE: number;
  23068. /**
  23069. * Mesh side orientation : both internal and external or front and back surfaces
  23070. */
  23071. static readonly DOUBLESIDE: number;
  23072. /**
  23073. * Mesh side orientation : by default, `FRONTSIDE`
  23074. */
  23075. static readonly DEFAULTSIDE: number;
  23076. /**
  23077. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23078. */
  23079. positions: Nullable<FloatArray>;
  23080. /**
  23081. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23082. */
  23083. normals: Nullable<FloatArray>;
  23084. /**
  23085. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23086. */
  23087. tangents: Nullable<FloatArray>;
  23088. /**
  23089. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23090. */
  23091. uvs: Nullable<FloatArray>;
  23092. /**
  23093. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23094. */
  23095. uvs2: Nullable<FloatArray>;
  23096. /**
  23097. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23098. */
  23099. uvs3: Nullable<FloatArray>;
  23100. /**
  23101. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23102. */
  23103. uvs4: Nullable<FloatArray>;
  23104. /**
  23105. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23106. */
  23107. uvs5: Nullable<FloatArray>;
  23108. /**
  23109. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23110. */
  23111. uvs6: Nullable<FloatArray>;
  23112. /**
  23113. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23114. */
  23115. colors: Nullable<FloatArray>;
  23116. /**
  23117. * 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).
  23118. */
  23119. matricesIndices: Nullable<FloatArray>;
  23120. /**
  23121. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23122. */
  23123. matricesWeights: Nullable<FloatArray>;
  23124. /**
  23125. * An array extending the number of possible indices
  23126. */
  23127. matricesIndicesExtra: Nullable<FloatArray>;
  23128. /**
  23129. * An array extending the number of possible weights when the number of indices is extended
  23130. */
  23131. matricesWeightsExtra: Nullable<FloatArray>;
  23132. /**
  23133. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23134. */
  23135. indices: Nullable<IndicesArray>;
  23136. /**
  23137. * Uses the passed data array to set the set the values for the specified kind of data
  23138. * @param data a linear array of floating numbers
  23139. * @param kind the type of data that is being set, eg positions, colors etc
  23140. */
  23141. set(data: FloatArray, kind: string): void;
  23142. /**
  23143. * Associates the vertexData to the passed Mesh.
  23144. * Sets it as updatable or not (default `false`)
  23145. * @param mesh the mesh the vertexData is applied to
  23146. * @param updatable when used and having the value true allows new data to update the vertexData
  23147. * @returns the VertexData
  23148. */
  23149. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23150. /**
  23151. * Associates the vertexData to the passed Geometry.
  23152. * Sets it as updatable or not (default `false`)
  23153. * @param geometry the geometry the vertexData is applied to
  23154. * @param updatable when used and having the value true allows new data to update the vertexData
  23155. * @returns VertexData
  23156. */
  23157. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23158. /**
  23159. * Updates the associated mesh
  23160. * @param mesh the mesh to be updated
  23161. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23162. * @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
  23163. * @returns VertexData
  23164. */
  23165. updateMesh(mesh: Mesh): VertexData;
  23166. /**
  23167. * Updates the associated geometry
  23168. * @param geometry the geometry to be updated
  23169. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23170. * @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
  23171. * @returns VertexData.
  23172. */
  23173. updateGeometry(geometry: Geometry): VertexData;
  23174. private _applyTo;
  23175. private _update;
  23176. /**
  23177. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23178. * @param matrix the transforming matrix
  23179. * @returns the VertexData
  23180. */
  23181. transform(matrix: Matrix): VertexData;
  23182. /**
  23183. * Merges the passed VertexData into the current one
  23184. * @param other the VertexData to be merged into the current one
  23185. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23186. * @returns the modified VertexData
  23187. */
  23188. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23189. private _mergeElement;
  23190. private _validate;
  23191. /**
  23192. * Serializes the VertexData
  23193. * @returns a serialized object
  23194. */
  23195. serialize(): any;
  23196. /**
  23197. * Extracts the vertexData from a mesh
  23198. * @param mesh the mesh from which to extract the VertexData
  23199. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23200. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23201. * @returns the object VertexData associated to the passed mesh
  23202. */
  23203. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23204. /**
  23205. * Extracts the vertexData from the geometry
  23206. * @param geometry the geometry from which to extract the VertexData
  23207. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23208. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23209. * @returns the object VertexData associated to the passed mesh
  23210. */
  23211. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23212. private static _ExtractFrom;
  23213. /**
  23214. * Creates the VertexData for a Ribbon
  23215. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23216. * * pathArray array of paths, each of which an array of successive Vector3
  23217. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23218. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23219. * * 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
  23220. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23221. * * 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)
  23222. * * 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)
  23223. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23224. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23225. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23226. * @returns the VertexData of the ribbon
  23227. */
  23228. static CreateRibbon(options: {
  23229. pathArray: Vector3[][];
  23230. closeArray?: boolean;
  23231. closePath?: boolean;
  23232. offset?: number;
  23233. sideOrientation?: number;
  23234. frontUVs?: Vector4;
  23235. backUVs?: Vector4;
  23236. invertUV?: boolean;
  23237. uvs?: Vector2[];
  23238. colors?: Color4[];
  23239. }): VertexData;
  23240. /**
  23241. * Creates the VertexData for a box
  23242. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23243. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23244. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23245. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23246. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23247. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23248. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23249. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23250. * * 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)
  23251. * * 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)
  23252. * @returns the VertexData of the box
  23253. */
  23254. static CreateBox(options: {
  23255. size?: number;
  23256. width?: number;
  23257. height?: number;
  23258. depth?: number;
  23259. faceUV?: Vector4[];
  23260. faceColors?: Color4[];
  23261. sideOrientation?: number;
  23262. frontUVs?: Vector4;
  23263. backUVs?: Vector4;
  23264. }): VertexData;
  23265. /**
  23266. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23267. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23268. * * segments sets the number of horizontal strips optional, default 32
  23269. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23270. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23271. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23272. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23273. * * 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
  23274. * * 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
  23275. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23276. * * 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)
  23277. * * 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)
  23278. * @returns the VertexData of the ellipsoid
  23279. */
  23280. static CreateSphere(options: {
  23281. segments?: number;
  23282. diameter?: number;
  23283. diameterX?: number;
  23284. diameterY?: number;
  23285. diameterZ?: number;
  23286. arc?: number;
  23287. slice?: number;
  23288. sideOrientation?: number;
  23289. frontUVs?: Vector4;
  23290. backUVs?: Vector4;
  23291. }): VertexData;
  23292. /**
  23293. * Creates the VertexData for a cylinder, cone or prism
  23294. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23295. * * height sets the height (y direction) of the cylinder, optional, default 2
  23296. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23297. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23298. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23299. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23300. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23301. * * 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
  23302. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23303. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23304. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23305. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23306. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23307. * * 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)
  23308. * * 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)
  23309. * @returns the VertexData of the cylinder, cone or prism
  23310. */
  23311. static CreateCylinder(options: {
  23312. height?: number;
  23313. diameterTop?: number;
  23314. diameterBottom?: number;
  23315. diameter?: number;
  23316. tessellation?: number;
  23317. subdivisions?: number;
  23318. arc?: number;
  23319. faceColors?: Color4[];
  23320. faceUV?: Vector4[];
  23321. hasRings?: boolean;
  23322. enclose?: boolean;
  23323. sideOrientation?: number;
  23324. frontUVs?: Vector4;
  23325. backUVs?: Vector4;
  23326. }): VertexData;
  23327. /**
  23328. * Creates the VertexData for a torus
  23329. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23330. * * diameter the diameter of the torus, optional default 1
  23331. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23332. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23333. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23334. * * 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)
  23335. * * 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)
  23336. * @returns the VertexData of the torus
  23337. */
  23338. static CreateTorus(options: {
  23339. diameter?: number;
  23340. thickness?: number;
  23341. tessellation?: number;
  23342. sideOrientation?: number;
  23343. frontUVs?: Vector4;
  23344. backUVs?: Vector4;
  23345. }): VertexData;
  23346. /**
  23347. * Creates the VertexData of the LineSystem
  23348. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23349. * - lines an array of lines, each line being an array of successive Vector3
  23350. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23351. * @returns the VertexData of the LineSystem
  23352. */
  23353. static CreateLineSystem(options: {
  23354. lines: Vector3[][];
  23355. colors?: Nullable<Color4[][]>;
  23356. }): VertexData;
  23357. /**
  23358. * Create the VertexData for a DashedLines
  23359. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23360. * - points an array successive Vector3
  23361. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23362. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23363. * - dashNb the intended total number of dashes, optional, default 200
  23364. * @returns the VertexData for the DashedLines
  23365. */
  23366. static CreateDashedLines(options: {
  23367. points: Vector3[];
  23368. dashSize?: number;
  23369. gapSize?: number;
  23370. dashNb?: number;
  23371. }): VertexData;
  23372. /**
  23373. * Creates the VertexData for a Ground
  23374. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23375. * - width the width (x direction) of the ground, optional, default 1
  23376. * - height the height (z direction) of the ground, optional, default 1
  23377. * - subdivisions the number of subdivisions per side, optional, default 1
  23378. * @returns the VertexData of the Ground
  23379. */
  23380. static CreateGround(options: {
  23381. width?: number;
  23382. height?: number;
  23383. subdivisions?: number;
  23384. subdivisionsX?: number;
  23385. subdivisionsY?: number;
  23386. }): VertexData;
  23387. /**
  23388. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23389. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23390. * * xmin the ground minimum X coordinate, optional, default -1
  23391. * * zmin the ground minimum Z coordinate, optional, default -1
  23392. * * xmax the ground maximum X coordinate, optional, default 1
  23393. * * zmax the ground maximum Z coordinate, optional, default 1
  23394. * * 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}
  23395. * * 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}
  23396. * @returns the VertexData of the TiledGround
  23397. */
  23398. static CreateTiledGround(options: {
  23399. xmin: number;
  23400. zmin: number;
  23401. xmax: number;
  23402. zmax: number;
  23403. subdivisions?: {
  23404. w: number;
  23405. h: number;
  23406. };
  23407. precision?: {
  23408. w: number;
  23409. h: number;
  23410. };
  23411. }): VertexData;
  23412. /**
  23413. * Creates the VertexData of the Ground designed from a heightmap
  23414. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23415. * * width the width (x direction) of the ground
  23416. * * height the height (z direction) of the ground
  23417. * * subdivisions the number of subdivisions per side
  23418. * * minHeight the minimum altitude on the ground, optional, default 0
  23419. * * maxHeight the maximum altitude on the ground, optional default 1
  23420. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23421. * * buffer the array holding the image color data
  23422. * * bufferWidth the width of image
  23423. * * bufferHeight the height of image
  23424. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23425. * @returns the VertexData of the Ground designed from a heightmap
  23426. */
  23427. static CreateGroundFromHeightMap(options: {
  23428. width: number;
  23429. height: number;
  23430. subdivisions: number;
  23431. minHeight: number;
  23432. maxHeight: number;
  23433. colorFilter: Color3;
  23434. buffer: Uint8Array;
  23435. bufferWidth: number;
  23436. bufferHeight: number;
  23437. alphaFilter: number;
  23438. }): VertexData;
  23439. /**
  23440. * Creates the VertexData for a Plane
  23441. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23442. * * size sets the width and height of the plane to the value of size, optional default 1
  23443. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23444. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23445. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23446. * * 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)
  23447. * * 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)
  23448. * @returns the VertexData of the box
  23449. */
  23450. static CreatePlane(options: {
  23451. size?: number;
  23452. width?: number;
  23453. height?: number;
  23454. sideOrientation?: number;
  23455. frontUVs?: Vector4;
  23456. backUVs?: Vector4;
  23457. }): VertexData;
  23458. /**
  23459. * Creates the VertexData of the Disc or regular Polygon
  23460. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23461. * * radius the radius of the disc, optional default 0.5
  23462. * * tessellation the number of polygon sides, optional, default 64
  23463. * * 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
  23464. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23465. * * 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)
  23466. * * 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)
  23467. * @returns the VertexData of the box
  23468. */
  23469. static CreateDisc(options: {
  23470. radius?: number;
  23471. tessellation?: number;
  23472. arc?: number;
  23473. sideOrientation?: number;
  23474. frontUVs?: Vector4;
  23475. backUVs?: Vector4;
  23476. }): VertexData;
  23477. /**
  23478. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23479. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23480. * @param polygon a mesh built from polygonTriangulation.build()
  23481. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23482. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23483. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23484. * @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)
  23485. * @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)
  23486. * @returns the VertexData of the Polygon
  23487. */
  23488. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23489. /**
  23490. * Creates the VertexData of the IcoSphere
  23491. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23492. * * radius the radius of the IcoSphere, optional default 1
  23493. * * radiusX allows stretching in the x direction, optional, default radius
  23494. * * radiusY allows stretching in the y direction, optional, default radius
  23495. * * radiusZ allows stretching in the z direction, optional, default radius
  23496. * * flat when true creates a flat shaded mesh, optional, default true
  23497. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23498. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23499. * * 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)
  23500. * * 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)
  23501. * @returns the VertexData of the IcoSphere
  23502. */
  23503. static CreateIcoSphere(options: {
  23504. radius?: number;
  23505. radiusX?: number;
  23506. radiusY?: number;
  23507. radiusZ?: number;
  23508. flat?: boolean;
  23509. subdivisions?: number;
  23510. sideOrientation?: number;
  23511. frontUVs?: Vector4;
  23512. backUVs?: Vector4;
  23513. }): VertexData;
  23514. /**
  23515. * Creates the VertexData for a Polyhedron
  23516. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23517. * * type provided types are:
  23518. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23519. * * 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)
  23520. * * size the size of the IcoSphere, optional default 1
  23521. * * sizeX allows stretching in the x direction, optional, default size
  23522. * * sizeY allows stretching in the y direction, optional, default size
  23523. * * sizeZ allows stretching in the z direction, optional, default size
  23524. * * 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
  23525. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23526. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23527. * * flat when true creates a flat shaded mesh, optional, default true
  23528. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23529. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23530. * * 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)
  23531. * * 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)
  23532. * @returns the VertexData of the Polyhedron
  23533. */
  23534. static CreatePolyhedron(options: {
  23535. type?: number;
  23536. size?: number;
  23537. sizeX?: number;
  23538. sizeY?: number;
  23539. sizeZ?: number;
  23540. custom?: any;
  23541. faceUV?: Vector4[];
  23542. faceColors?: Color4[];
  23543. flat?: boolean;
  23544. sideOrientation?: number;
  23545. frontUVs?: Vector4;
  23546. backUVs?: Vector4;
  23547. }): VertexData;
  23548. /**
  23549. * Creates the VertexData for a TorusKnot
  23550. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23551. * * radius the radius of the torus knot, optional, default 2
  23552. * * tube the thickness of the tube, optional, default 0.5
  23553. * * radialSegments the number of sides on each tube segments, optional, default 32
  23554. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23555. * * p the number of windings around the z axis, optional, default 2
  23556. * * q the number of windings around the x axis, optional, default 3
  23557. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23558. * * 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)
  23559. * * 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)
  23560. * @returns the VertexData of the Torus Knot
  23561. */
  23562. static CreateTorusKnot(options: {
  23563. radius?: number;
  23564. tube?: number;
  23565. radialSegments?: number;
  23566. tubularSegments?: number;
  23567. p?: number;
  23568. q?: number;
  23569. sideOrientation?: number;
  23570. frontUVs?: Vector4;
  23571. backUVs?: Vector4;
  23572. }): VertexData;
  23573. /**
  23574. * Compute normals for given positions and indices
  23575. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23576. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23577. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23578. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23579. * * facetNormals : optional array of facet normals (vector3)
  23580. * * facetPositions : optional array of facet positions (vector3)
  23581. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23582. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23583. * * bInfo : optional bounding info, required for facetPartitioning computation
  23584. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23585. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23586. * * useRightHandedSystem: optional boolean to for right handed system computation
  23587. * * depthSort : optional boolean to enable the facet depth sort computation
  23588. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23589. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23590. */
  23591. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23592. facetNormals?: any;
  23593. facetPositions?: any;
  23594. facetPartitioning?: any;
  23595. ratio?: number;
  23596. bInfo?: any;
  23597. bbSize?: Vector3;
  23598. subDiv?: any;
  23599. useRightHandedSystem?: boolean;
  23600. depthSort?: boolean;
  23601. distanceTo?: Vector3;
  23602. depthSortedFacets?: any;
  23603. }): void;
  23604. /** @hidden */
  23605. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23606. /**
  23607. * Applies VertexData created from the imported parameters to the geometry
  23608. * @param parsedVertexData the parsed data from an imported file
  23609. * @param geometry the geometry to apply the VertexData to
  23610. */
  23611. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23612. }
  23613. }
  23614. declare module "babylonjs/Meshes/Builders/discBuilder" {
  23615. import { Nullable } from "babylonjs/types";
  23616. import { Scene } from "babylonjs/scene";
  23617. import { Vector4 } from "babylonjs/Maths/math";
  23618. import { Mesh } from "babylonjs/Meshes/mesh";
  23619. /**
  23620. * Class containing static functions to help procedurally build meshes
  23621. */
  23622. export class DiscBuilder {
  23623. /**
  23624. * Creates a plane polygonal mesh. By default, this is a disc
  23625. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23626. * * 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
  23627. * * 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
  23628. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23629. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23630. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23631. * @param name defines the name of the mesh
  23632. * @param options defines the options used to create the mesh
  23633. * @param scene defines the hosting scene
  23634. * @returns the plane polygonal mesh
  23635. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23636. */
  23637. static CreateDisc(name: string, options: {
  23638. radius?: number;
  23639. tessellation?: number;
  23640. arc?: number;
  23641. updatable?: boolean;
  23642. sideOrientation?: number;
  23643. frontUVs?: Vector4;
  23644. backUVs?: Vector4;
  23645. }, scene?: Nullable<Scene>): Mesh;
  23646. }
  23647. }
  23648. declare module "babylonjs/Particles/solidParticleSystem" {
  23649. import { Vector3 } from "babylonjs/Maths/math";
  23650. import { Mesh } from "babylonjs/Meshes/mesh";
  23651. import { Scene, IDisposable } from "babylonjs/scene";
  23652. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  23653. /**
  23654. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23655. *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.
  23656. * The SPS is also a particle system. It provides some methods to manage the particles.
  23657. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23658. *
  23659. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23660. */
  23661. export class SolidParticleSystem implements IDisposable {
  23662. /**
  23663. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23664. * Example : var p = SPS.particles[i];
  23665. */
  23666. particles: SolidParticle[];
  23667. /**
  23668. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23669. */
  23670. nbParticles: number;
  23671. /**
  23672. * If the particles must ever face the camera (default false). Useful for planar particles.
  23673. */
  23674. billboard: boolean;
  23675. /**
  23676. * Recompute normals when adding a shape
  23677. */
  23678. recomputeNormals: boolean;
  23679. /**
  23680. * This a counter ofr your own usage. It's not set by any SPS functions.
  23681. */
  23682. counter: number;
  23683. /**
  23684. * The SPS name. This name is also given to the underlying mesh.
  23685. */
  23686. name: string;
  23687. /**
  23688. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23689. */
  23690. mesh: Mesh;
  23691. /**
  23692. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23693. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23694. */
  23695. vars: any;
  23696. /**
  23697. * This array is populated when the SPS is set as 'pickable'.
  23698. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23699. * Each element of this array is an object `{idx: int, faceId: int}`.
  23700. * `idx` is the picked particle index in the `SPS.particles` array
  23701. * `faceId` is the picked face index counted within this particle.
  23702. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23703. */
  23704. pickedParticles: {
  23705. idx: number;
  23706. faceId: number;
  23707. }[];
  23708. /**
  23709. * This array is populated when `enableDepthSort` is set to true.
  23710. * Each element of this array is an instance of the class DepthSortedParticle.
  23711. */
  23712. depthSortedParticles: DepthSortedParticle[];
  23713. /**
  23714. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23715. * @hidden
  23716. */
  23717. _bSphereOnly: boolean;
  23718. /**
  23719. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23720. * @hidden
  23721. */
  23722. _bSphereRadiusFactor: number;
  23723. private _scene;
  23724. private _positions;
  23725. private _indices;
  23726. private _normals;
  23727. private _colors;
  23728. private _uvs;
  23729. private _indices32;
  23730. private _positions32;
  23731. private _normals32;
  23732. private _fixedNormal32;
  23733. private _colors32;
  23734. private _uvs32;
  23735. private _index;
  23736. private _updatable;
  23737. private _pickable;
  23738. private _isVisibilityBoxLocked;
  23739. private _alwaysVisible;
  23740. private _depthSort;
  23741. private _shapeCounter;
  23742. private _copy;
  23743. private _color;
  23744. private _computeParticleColor;
  23745. private _computeParticleTexture;
  23746. private _computeParticleRotation;
  23747. private _computeParticleVertex;
  23748. private _computeBoundingBox;
  23749. private _depthSortParticles;
  23750. private _camera;
  23751. private _mustUnrotateFixedNormals;
  23752. private _particlesIntersect;
  23753. private _needs32Bits;
  23754. /**
  23755. * Creates a SPS (Solid Particle System) object.
  23756. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23757. * @param scene (Scene) is the scene in which the SPS is added.
  23758. * @param options defines the options of the sps e.g.
  23759. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23760. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23761. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23762. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23763. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23764. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23765. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23766. */
  23767. constructor(name: string, scene: Scene, options?: {
  23768. updatable?: boolean;
  23769. isPickable?: boolean;
  23770. enableDepthSort?: boolean;
  23771. particleIntersection?: boolean;
  23772. boundingSphereOnly?: boolean;
  23773. bSphereRadiusFactor?: number;
  23774. });
  23775. /**
  23776. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23777. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23778. * @returns the created mesh
  23779. */
  23780. buildMesh(): Mesh;
  23781. /**
  23782. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23783. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23784. * Thus the particles generated from `digest()` have their property `position` set yet.
  23785. * @param mesh ( Mesh ) is the mesh to be digested
  23786. * @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
  23787. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23788. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23789. * @returns the current SPS
  23790. */
  23791. digest(mesh: Mesh, options?: {
  23792. facetNb?: number;
  23793. number?: number;
  23794. delta?: number;
  23795. }): SolidParticleSystem;
  23796. private _unrotateFixedNormals;
  23797. private _resetCopy;
  23798. private _meshBuilder;
  23799. private _posToShape;
  23800. private _uvsToShapeUV;
  23801. private _addParticle;
  23802. /**
  23803. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23804. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23805. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23806. * @param nb (positive integer) the number of particles to be created from this model
  23807. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23808. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23809. * @returns the number of shapes in the system
  23810. */
  23811. addShape(mesh: Mesh, nb: number, options?: {
  23812. positionFunction?: any;
  23813. vertexFunction?: any;
  23814. }): number;
  23815. private _rebuildParticle;
  23816. /**
  23817. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23818. * @returns the SPS.
  23819. */
  23820. rebuildMesh(): SolidParticleSystem;
  23821. /**
  23822. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23823. * This method calls `updateParticle()` for each particle of the SPS.
  23824. * For an animated SPS, it is usually called within the render loop.
  23825. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23826. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23827. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23828. * @returns the SPS.
  23829. */
  23830. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23831. /**
  23832. * Disposes the SPS.
  23833. */
  23834. dispose(): void;
  23835. /**
  23836. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23837. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23838. * @returns the SPS.
  23839. */
  23840. refreshVisibleSize(): SolidParticleSystem;
  23841. /**
  23842. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23843. * @param size the size (float) of the visibility box
  23844. * note : this doesn't lock the SPS mesh bounding box.
  23845. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23846. */
  23847. setVisibilityBox(size: number): void;
  23848. /**
  23849. * Gets whether the SPS as always visible or not
  23850. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23851. */
  23852. /**
  23853. * Sets the SPS as always visible or not
  23854. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23855. */
  23856. isAlwaysVisible: boolean;
  23857. /**
  23858. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23859. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23860. */
  23861. /**
  23862. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23863. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23864. */
  23865. isVisibilityBoxLocked: boolean;
  23866. /**
  23867. * Tells to `setParticles()` to compute the particle rotations or not.
  23868. * Default value : true. The SPS is faster when it's set to false.
  23869. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23870. */
  23871. /**
  23872. * Gets if `setParticles()` computes the particle rotations or not.
  23873. * Default value : true. The SPS is faster when it's set to false.
  23874. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23875. */
  23876. computeParticleRotation: boolean;
  23877. /**
  23878. * Tells to `setParticles()` to compute the particle colors or not.
  23879. * Default value : true. The SPS is faster when it's set to false.
  23880. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23881. */
  23882. /**
  23883. * Gets if `setParticles()` computes the particle colors or not.
  23884. * Default value : true. The SPS is faster when it's set to false.
  23885. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23886. */
  23887. computeParticleColor: boolean;
  23888. /**
  23889. * Gets if `setParticles()` computes the particle textures or not.
  23890. * Default value : true. The SPS is faster when it's set to false.
  23891. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23892. */
  23893. computeParticleTexture: boolean;
  23894. /**
  23895. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23896. * Default value : false. The SPS is faster when it's set to false.
  23897. * Note : the particle custom vertex positions aren't stored values.
  23898. */
  23899. /**
  23900. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23901. * Default value : false. The SPS is faster when it's set to false.
  23902. * Note : the particle custom vertex positions aren't stored values.
  23903. */
  23904. computeParticleVertex: boolean;
  23905. /**
  23906. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23907. */
  23908. /**
  23909. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23910. */
  23911. computeBoundingBox: boolean;
  23912. /**
  23913. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23914. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23915. * Default : `true`
  23916. */
  23917. /**
  23918. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23919. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23920. * Default : `true`
  23921. */
  23922. depthSortParticles: boolean;
  23923. /**
  23924. * This function does nothing. It may be overwritten to set all the particle first values.
  23925. * The SPS doesn't call this function, you may have to call it by your own.
  23926. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23927. */
  23928. initParticles(): void;
  23929. /**
  23930. * This function does nothing. It may be overwritten to recycle a particle.
  23931. * The SPS doesn't call this function, you may have to call it by your own.
  23932. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23933. * @param particle The particle to recycle
  23934. * @returns the recycled particle
  23935. */
  23936. recycleParticle(particle: SolidParticle): SolidParticle;
  23937. /**
  23938. * Updates a particle : this function should be overwritten by the user.
  23939. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23940. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23941. * @example : just set a particle position or velocity and recycle conditions
  23942. * @param particle The particle to update
  23943. * @returns the updated particle
  23944. */
  23945. updateParticle(particle: SolidParticle): SolidParticle;
  23946. /**
  23947. * Updates a vertex of a particle : it can be overwritten by the user.
  23948. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23949. * @param particle the current particle
  23950. * @param vertex the current index of the current particle
  23951. * @param pt the index of the current vertex in the particle shape
  23952. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23953. * @example : just set a vertex particle position
  23954. * @returns the updated vertex
  23955. */
  23956. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23957. /**
  23958. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23959. * This does nothing and may be overwritten by the user.
  23960. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23961. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23962. * @param update the boolean update value actually passed to setParticles()
  23963. */
  23964. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23965. /**
  23966. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23967. * This will be passed three parameters.
  23968. * This does nothing and may be overwritten by the user.
  23969. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23970. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23971. * @param update the boolean update value actually passed to setParticles()
  23972. */
  23973. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23974. }
  23975. }
  23976. declare module "babylonjs/Particles/solidParticle" {
  23977. import { Nullable } from "babylonjs/types";
  23978. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  23979. import { Mesh } from "babylonjs/Meshes/mesh";
  23980. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23981. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  23982. /**
  23983. * Represents one particle of a solid particle system.
  23984. */
  23985. export class SolidParticle {
  23986. /**
  23987. * particle global index
  23988. */
  23989. idx: number;
  23990. /**
  23991. * The color of the particle
  23992. */
  23993. color: Nullable<Color4>;
  23994. /**
  23995. * The world space position of the particle.
  23996. */
  23997. position: Vector3;
  23998. /**
  23999. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24000. */
  24001. rotation: Vector3;
  24002. /**
  24003. * The world space rotation quaternion of the particle.
  24004. */
  24005. rotationQuaternion: Nullable<Quaternion>;
  24006. /**
  24007. * The scaling of the particle.
  24008. */
  24009. scaling: Vector3;
  24010. /**
  24011. * The uvs of the particle.
  24012. */
  24013. uvs: Vector4;
  24014. /**
  24015. * The current speed of the particle.
  24016. */
  24017. velocity: Vector3;
  24018. /**
  24019. * The pivot point in the particle local space.
  24020. */
  24021. pivot: Vector3;
  24022. /**
  24023. * Must the particle be translated from its pivot point in its local space ?
  24024. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24025. * Default : false
  24026. */
  24027. translateFromPivot: boolean;
  24028. /**
  24029. * Is the particle active or not ?
  24030. */
  24031. alive: boolean;
  24032. /**
  24033. * Is the particle visible or not ?
  24034. */
  24035. isVisible: boolean;
  24036. /**
  24037. * Index of this particle in the global "positions" array (Internal use)
  24038. * @hidden
  24039. */
  24040. _pos: number;
  24041. /**
  24042. * @hidden Index of this particle in the global "indices" array (Internal use)
  24043. */
  24044. _ind: number;
  24045. /**
  24046. * @hidden ModelShape of this particle (Internal use)
  24047. */
  24048. _model: ModelShape;
  24049. /**
  24050. * ModelShape id of this particle
  24051. */
  24052. shapeId: number;
  24053. /**
  24054. * Index of the particle in its shape id (Internal use)
  24055. */
  24056. idxInShape: number;
  24057. /**
  24058. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24059. */
  24060. _modelBoundingInfo: BoundingInfo;
  24061. /**
  24062. * @hidden Particle BoundingInfo object (Internal use)
  24063. */
  24064. _boundingInfo: BoundingInfo;
  24065. /**
  24066. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24067. */
  24068. _sps: SolidParticleSystem;
  24069. /**
  24070. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24071. */
  24072. _stillInvisible: boolean;
  24073. /**
  24074. * @hidden Last computed particle rotation matrix
  24075. */
  24076. _rotationMatrix: number[];
  24077. /**
  24078. * Parent particle Id, if any.
  24079. * Default null.
  24080. */
  24081. parentId: Nullable<number>;
  24082. /**
  24083. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24084. * The possible values are :
  24085. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24086. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24087. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24088. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24089. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24090. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24091. * */
  24092. cullingStrategy: number;
  24093. /**
  24094. * @hidden Internal global position in the SPS.
  24095. */
  24096. _globalPosition: Vector3;
  24097. /**
  24098. * Creates a Solid Particle object.
  24099. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24100. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24101. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24102. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24103. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24104. * @param shapeId (integer) is the model shape identifier in the SPS.
  24105. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24106. * @param sps defines the sps it is associated to
  24107. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24108. */
  24109. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24110. /**
  24111. * Legacy support, changed scale to scaling
  24112. */
  24113. /**
  24114. * Legacy support, changed scale to scaling
  24115. */
  24116. scale: Vector3;
  24117. /**
  24118. * Legacy support, changed quaternion to rotationQuaternion
  24119. */
  24120. /**
  24121. * Legacy support, changed quaternion to rotationQuaternion
  24122. */
  24123. quaternion: Nullable<Quaternion>;
  24124. /**
  24125. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24126. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24127. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24128. * @returns true if it intersects
  24129. */
  24130. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24131. /**
  24132. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24133. * A particle is in the frustum if its bounding box intersects the frustum
  24134. * @param frustumPlanes defines the frustum to test
  24135. * @returns true if the particle is in the frustum planes
  24136. */
  24137. isInFrustum(frustumPlanes: Plane[]): boolean;
  24138. /**
  24139. * get the rotation matrix of the particle
  24140. * @hidden
  24141. */
  24142. getRotationMatrix(m: Matrix): void;
  24143. }
  24144. /**
  24145. * Represents the shape of the model used by one particle of a solid particle system.
  24146. * SPS internal tool, don't use it manually.
  24147. */
  24148. export class ModelShape {
  24149. /**
  24150. * The shape id
  24151. * @hidden
  24152. */
  24153. shapeID: number;
  24154. /**
  24155. * flat array of model positions (internal use)
  24156. * @hidden
  24157. */
  24158. _shape: Vector3[];
  24159. /**
  24160. * flat array of model UVs (internal use)
  24161. * @hidden
  24162. */
  24163. _shapeUV: number[];
  24164. /**
  24165. * length of the shape in the model indices array (internal use)
  24166. * @hidden
  24167. */
  24168. _indicesLength: number;
  24169. /**
  24170. * Custom position function (internal use)
  24171. * @hidden
  24172. */
  24173. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24174. /**
  24175. * Custom vertex function (internal use)
  24176. * @hidden
  24177. */
  24178. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24179. /**
  24180. * 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.
  24181. * SPS internal tool, don't use it manually.
  24182. * @hidden
  24183. */
  24184. 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>);
  24185. }
  24186. /**
  24187. * Represents a Depth Sorted Particle in the solid particle system.
  24188. */
  24189. export class DepthSortedParticle {
  24190. /**
  24191. * Index of the particle in the "indices" array
  24192. */
  24193. ind: number;
  24194. /**
  24195. * Length of the particle shape in the "indices" array
  24196. */
  24197. indicesLength: number;
  24198. /**
  24199. * Squared distance from the particle to the camera
  24200. */
  24201. sqDistance: number;
  24202. }
  24203. }
  24204. declare module "babylonjs/Meshes/abstractMesh" {
  24205. import { Observable } from "babylonjs/Misc/observable";
  24206. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  24207. import { Camera } from "babylonjs/Cameras/camera";
  24208. import { Scene, IDisposable } from "babylonjs/scene";
  24209. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  24210. import { Node } from "babylonjs/node";
  24211. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24212. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24213. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24214. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  24215. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24216. import { Material } from "babylonjs/Materials/material";
  24217. import { Light } from "babylonjs/Lights/light";
  24218. import { Skeleton } from "babylonjs/Bones/skeleton";
  24219. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  24220. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  24221. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  24222. import { Ray } from "babylonjs/Culling/ray";
  24223. import { Collider } from "babylonjs/Collisions/collider";
  24224. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  24225. /**
  24226. * Class used to store all common mesh properties
  24227. */
  24228. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24229. /** No occlusion */
  24230. static OCCLUSION_TYPE_NONE: number;
  24231. /** Occlusion set to optimisitic */
  24232. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24233. /** Occlusion set to strict */
  24234. static OCCLUSION_TYPE_STRICT: number;
  24235. /** Use an accurante occlusion algorithm */
  24236. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24237. /** Use a conservative occlusion algorithm */
  24238. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24239. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24240. * Test order :
  24241. * Is the bounding sphere outside the frustum ?
  24242. * If not, are the bounding box vertices outside the frustum ?
  24243. * It not, then the cullable object is in the frustum.
  24244. */
  24245. static readonly CULLINGSTRATEGY_STANDARD: number;
  24246. /** Culling strategy : Bounding Sphere Only.
  24247. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24248. * It's also less accurate than the standard because some not visible objects can still be selected.
  24249. * Test : is the bounding sphere outside the frustum ?
  24250. * If not, then the cullable object is in the frustum.
  24251. */
  24252. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24253. /** Culling strategy : Optimistic Inclusion.
  24254. * This in an inclusion test first, then the standard exclusion test.
  24255. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24256. * 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.
  24257. * Anyway, it's as accurate as the standard strategy.
  24258. * Test :
  24259. * Is the cullable object bounding sphere center in the frustum ?
  24260. * If not, apply the default culling strategy.
  24261. */
  24262. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24263. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24264. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24265. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24266. * 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.
  24267. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24268. * Test :
  24269. * Is the cullable object bounding sphere center in the frustum ?
  24270. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24271. */
  24272. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24273. /**
  24274. * No billboard
  24275. */
  24276. static readonly BILLBOARDMODE_NONE: number;
  24277. /** Billboard on X axis */
  24278. static readonly BILLBOARDMODE_X: number;
  24279. /** Billboard on Y axis */
  24280. static readonly BILLBOARDMODE_Y: number;
  24281. /** Billboard on Z axis */
  24282. static readonly BILLBOARDMODE_Z: number;
  24283. /** Billboard on all axes */
  24284. static readonly BILLBOARDMODE_ALL: number;
  24285. private _facetData;
  24286. /**
  24287. * The culling strategy to use to check whether the mesh must be rendered or not.
  24288. * This value can be changed at any time and will be used on the next render mesh selection.
  24289. * The possible values are :
  24290. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24291. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24292. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24293. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24294. * Please read each static variable documentation to get details about the culling process.
  24295. * */
  24296. cullingStrategy: number;
  24297. /**
  24298. * Gets the number of facets in the mesh
  24299. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24300. */
  24301. readonly facetNb: number;
  24302. /**
  24303. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24304. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24305. */
  24306. partitioningSubdivisions: number;
  24307. /**
  24308. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24309. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24310. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24311. */
  24312. partitioningBBoxRatio: number;
  24313. /**
  24314. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24315. * Works only for updatable meshes.
  24316. * Doesn't work with multi-materials
  24317. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24318. */
  24319. mustDepthSortFacets: boolean;
  24320. /**
  24321. * The location (Vector3) where the facet depth sort must be computed from.
  24322. * By default, the active camera position.
  24323. * Used only when facet depth sort is enabled
  24324. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24325. */
  24326. facetDepthSortFrom: Vector3;
  24327. /**
  24328. * gets a boolean indicating if facetData is enabled
  24329. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24330. */
  24331. readonly isFacetDataEnabled: boolean;
  24332. /** @hidden */
  24333. _updateNonUniformScalingState(value: boolean): boolean;
  24334. /**
  24335. * An event triggered when this mesh collides with another one
  24336. */
  24337. onCollideObservable: Observable<AbstractMesh>;
  24338. private _onCollideObserver;
  24339. /** Set a function to call when this mesh collides with another one */
  24340. onCollide: () => void;
  24341. /**
  24342. * An event triggered when the collision's position changes
  24343. */
  24344. onCollisionPositionChangeObservable: Observable<Vector3>;
  24345. private _onCollisionPositionChangeObserver;
  24346. /** Set a function to call when the collision's position changes */
  24347. onCollisionPositionChange: () => void;
  24348. /**
  24349. * An event triggered when material is changed
  24350. */
  24351. onMaterialChangedObservable: Observable<AbstractMesh>;
  24352. /**
  24353. * Gets or sets the orientation for POV movement & rotation
  24354. */
  24355. definedFacingForward: boolean;
  24356. /** @hidden */
  24357. _occlusionQuery: Nullable<WebGLQuery>;
  24358. private _visibility;
  24359. /**
  24360. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24361. */
  24362. /**
  24363. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24364. */
  24365. visibility: number;
  24366. /** Gets or sets the alpha index used to sort transparent meshes
  24367. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24368. */
  24369. alphaIndex: number;
  24370. /**
  24371. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24372. */
  24373. isVisible: boolean;
  24374. /**
  24375. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24376. */
  24377. isPickable: boolean;
  24378. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24379. showSubMeshesBoundingBox: boolean;
  24380. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24381. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24382. */
  24383. isBlocker: boolean;
  24384. /**
  24385. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24386. */
  24387. enablePointerMoveEvents: boolean;
  24388. /**
  24389. * Specifies the rendering group id for this mesh (0 by default)
  24390. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24391. */
  24392. renderingGroupId: number;
  24393. private _material;
  24394. /** Gets or sets current material */
  24395. material: Nullable<Material>;
  24396. private _receiveShadows;
  24397. /**
  24398. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24399. * @see http://doc.babylonjs.com/babylon101/shadows
  24400. */
  24401. receiveShadows: boolean;
  24402. /** Defines color to use when rendering outline */
  24403. outlineColor: Color3;
  24404. /** Define width to use when rendering outline */
  24405. outlineWidth: number;
  24406. /** Defines color to use when rendering overlay */
  24407. overlayColor: Color3;
  24408. /** Defines alpha to use when rendering overlay */
  24409. overlayAlpha: number;
  24410. private _hasVertexAlpha;
  24411. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24412. hasVertexAlpha: boolean;
  24413. private _useVertexColors;
  24414. /** 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) */
  24415. useVertexColors: boolean;
  24416. private _computeBonesUsingShaders;
  24417. /**
  24418. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24419. */
  24420. computeBonesUsingShaders: boolean;
  24421. private _numBoneInfluencers;
  24422. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24423. numBoneInfluencers: number;
  24424. private _applyFog;
  24425. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24426. applyFog: boolean;
  24427. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24428. useOctreeForRenderingSelection: boolean;
  24429. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24430. useOctreeForPicking: boolean;
  24431. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24432. useOctreeForCollisions: boolean;
  24433. private _layerMask;
  24434. /**
  24435. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24436. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24437. */
  24438. layerMask: number;
  24439. /**
  24440. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24441. */
  24442. alwaysSelectAsActiveMesh: boolean;
  24443. /**
  24444. * Gets or sets the current action manager
  24445. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24446. */
  24447. actionManager: Nullable<AbstractActionManager>;
  24448. private _checkCollisions;
  24449. private _collisionMask;
  24450. private _collisionGroup;
  24451. /**
  24452. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24453. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24454. */
  24455. ellipsoid: Vector3;
  24456. /**
  24457. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24458. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24459. */
  24460. ellipsoidOffset: Vector3;
  24461. private _collider;
  24462. private _oldPositionForCollisions;
  24463. private _diffPositionForCollisions;
  24464. /**
  24465. * Gets or sets a collision mask used to mask collisions (default is -1).
  24466. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24467. */
  24468. collisionMask: number;
  24469. /**
  24470. * Gets or sets the current collision group mask (-1 by default).
  24471. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24472. */
  24473. collisionGroup: number;
  24474. /**
  24475. * Defines edge width used when edgesRenderer is enabled
  24476. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24477. */
  24478. edgesWidth: number;
  24479. /**
  24480. * Defines edge color used when edgesRenderer is enabled
  24481. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24482. */
  24483. edgesColor: Color4;
  24484. /** @hidden */
  24485. _edgesRenderer: Nullable<IEdgesRenderer>;
  24486. /** @hidden */
  24487. _masterMesh: Nullable<AbstractMesh>;
  24488. /** @hidden */
  24489. _boundingInfo: Nullable<BoundingInfo>;
  24490. /** @hidden */
  24491. _renderId: number;
  24492. /**
  24493. * Gets or sets the list of subMeshes
  24494. * @see http://doc.babylonjs.com/how_to/multi_materials
  24495. */
  24496. subMeshes: SubMesh[];
  24497. /** @hidden */
  24498. _intersectionsInProgress: AbstractMesh[];
  24499. /** @hidden */
  24500. _unIndexed: boolean;
  24501. /** @hidden */
  24502. _lightSources: Light[];
  24503. /** @hidden */
  24504. readonly _positions: Nullable<Vector3[]>;
  24505. /** @hidden */
  24506. _waitingActions: any;
  24507. /** @hidden */
  24508. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24509. private _skeleton;
  24510. /** @hidden */
  24511. _bonesTransformMatrices: Nullable<Float32Array>;
  24512. /**
  24513. * Gets or sets a skeleton to apply skining transformations
  24514. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24515. */
  24516. skeleton: Nullable<Skeleton>;
  24517. /**
  24518. * An event triggered when the mesh is rebuilt.
  24519. */
  24520. onRebuildObservable: Observable<AbstractMesh>;
  24521. /**
  24522. * Creates a new AbstractMesh
  24523. * @param name defines the name of the mesh
  24524. * @param scene defines the hosting scene
  24525. */
  24526. constructor(name: string, scene?: Nullable<Scene>);
  24527. /**
  24528. * Returns the string "AbstractMesh"
  24529. * @returns "AbstractMesh"
  24530. */
  24531. getClassName(): string;
  24532. /**
  24533. * Gets a string representation of the current mesh
  24534. * @param fullDetails defines a boolean indicating if full details must be included
  24535. * @returns a string representation of the current mesh
  24536. */
  24537. toString(fullDetails?: boolean): string;
  24538. /** @hidden */
  24539. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24540. /** @hidden */
  24541. _rebuild(): void;
  24542. /** @hidden */
  24543. _resyncLightSources(): void;
  24544. /** @hidden */
  24545. _resyncLighSource(light: Light): void;
  24546. /** @hidden */
  24547. _unBindEffect(): void;
  24548. /** @hidden */
  24549. _removeLightSource(light: Light): void;
  24550. private _markSubMeshesAsDirty;
  24551. /** @hidden */
  24552. _markSubMeshesAsLightDirty(): void;
  24553. /** @hidden */
  24554. _markSubMeshesAsAttributesDirty(): void;
  24555. /** @hidden */
  24556. _markSubMeshesAsMiscDirty(): void;
  24557. /**
  24558. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24559. */
  24560. scaling: Vector3;
  24561. /**
  24562. * Returns true if the mesh is blocked. Implemented by child classes
  24563. */
  24564. readonly isBlocked: boolean;
  24565. /**
  24566. * Returns the mesh itself by default. Implemented by child classes
  24567. * @param camera defines the camera to use to pick the right LOD level
  24568. * @returns the currentAbstractMesh
  24569. */
  24570. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24571. /**
  24572. * Returns 0 by default. Implemented by child classes
  24573. * @returns an integer
  24574. */
  24575. getTotalVertices(): number;
  24576. /**
  24577. * Returns a positive integer : the total number of indices in this mesh geometry.
  24578. * @returns the numner of indices or zero if the mesh has no geometry.
  24579. */
  24580. getTotalIndices(): number;
  24581. /**
  24582. * Returns null by default. Implemented by child classes
  24583. * @returns null
  24584. */
  24585. getIndices(): Nullable<IndicesArray>;
  24586. /**
  24587. * Returns the array of the requested vertex data kind. Implemented by child classes
  24588. * @param kind defines the vertex data kind to use
  24589. * @returns null
  24590. */
  24591. getVerticesData(kind: string): Nullable<FloatArray>;
  24592. /**
  24593. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24594. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24595. * Note that a new underlying VertexBuffer object is created each call.
  24596. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24597. * @param kind defines vertex data kind:
  24598. * * VertexBuffer.PositionKind
  24599. * * VertexBuffer.UVKind
  24600. * * VertexBuffer.UV2Kind
  24601. * * VertexBuffer.UV3Kind
  24602. * * VertexBuffer.UV4Kind
  24603. * * VertexBuffer.UV5Kind
  24604. * * VertexBuffer.UV6Kind
  24605. * * VertexBuffer.ColorKind
  24606. * * VertexBuffer.MatricesIndicesKind
  24607. * * VertexBuffer.MatricesIndicesExtraKind
  24608. * * VertexBuffer.MatricesWeightsKind
  24609. * * VertexBuffer.MatricesWeightsExtraKind
  24610. * @param data defines the data source
  24611. * @param updatable defines if the data must be flagged as updatable (or static)
  24612. * @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
  24613. * @returns the current mesh
  24614. */
  24615. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24616. /**
  24617. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24618. * If the mesh has no geometry, it is simply returned as it is.
  24619. * @param kind defines vertex data kind:
  24620. * * VertexBuffer.PositionKind
  24621. * * VertexBuffer.UVKind
  24622. * * VertexBuffer.UV2Kind
  24623. * * VertexBuffer.UV3Kind
  24624. * * VertexBuffer.UV4Kind
  24625. * * VertexBuffer.UV5Kind
  24626. * * VertexBuffer.UV6Kind
  24627. * * VertexBuffer.ColorKind
  24628. * * VertexBuffer.MatricesIndicesKind
  24629. * * VertexBuffer.MatricesIndicesExtraKind
  24630. * * VertexBuffer.MatricesWeightsKind
  24631. * * VertexBuffer.MatricesWeightsExtraKind
  24632. * @param data defines the data source
  24633. * @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
  24634. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24635. * @returns the current mesh
  24636. */
  24637. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24638. /**
  24639. * Sets the mesh indices,
  24640. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24641. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24642. * @param totalVertices Defines the total number of vertices
  24643. * @returns the current mesh
  24644. */
  24645. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24646. /**
  24647. * Gets a boolean indicating if specific vertex data is present
  24648. * @param kind defines the vertex data kind to use
  24649. * @returns true is data kind is present
  24650. */
  24651. isVerticesDataPresent(kind: string): boolean;
  24652. /**
  24653. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24654. * @returns a BoundingInfo
  24655. */
  24656. getBoundingInfo(): BoundingInfo;
  24657. /**
  24658. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24659. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24660. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24661. * @returns the current mesh
  24662. */
  24663. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  24664. /**
  24665. * Overwrite the current bounding info
  24666. * @param boundingInfo defines the new bounding info
  24667. * @returns the current mesh
  24668. */
  24669. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24670. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24671. readonly useBones: boolean;
  24672. /** @hidden */
  24673. _preActivate(): void;
  24674. /** @hidden */
  24675. _preActivateForIntermediateRendering(renderId: number): void;
  24676. /** @hidden */
  24677. _activate(renderId: number): void;
  24678. /**
  24679. * Gets the current world matrix
  24680. * @returns a Matrix
  24681. */
  24682. getWorldMatrix(): Matrix;
  24683. /** @hidden */
  24684. _getWorldMatrixDeterminant(): number;
  24685. /**
  24686. * Perform relative position change from the point of view of behind the front of the mesh.
  24687. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24688. * Supports definition of mesh facing forward or backward
  24689. * @param amountRight defines the distance on the right axis
  24690. * @param amountUp defines the distance on the up axis
  24691. * @param amountForward defines the distance on the forward axis
  24692. * @returns the current mesh
  24693. */
  24694. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24695. /**
  24696. * Calculate relative position change from the point of view of behind the front of the mesh.
  24697. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24698. * Supports definition of mesh facing forward or backward
  24699. * @param amountRight defines the distance on the right axis
  24700. * @param amountUp defines the distance on the up axis
  24701. * @param amountForward defines the distance on the forward axis
  24702. * @returns the new displacement vector
  24703. */
  24704. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24705. /**
  24706. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24707. * Supports definition of mesh facing forward or backward
  24708. * @param flipBack defines the flip
  24709. * @param twirlClockwise defines the twirl
  24710. * @param tiltRight defines the tilt
  24711. * @returns the current mesh
  24712. */
  24713. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24714. /**
  24715. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24716. * Supports definition of mesh facing forward or backward.
  24717. * @param flipBack defines the flip
  24718. * @param twirlClockwise defines the twirl
  24719. * @param tiltRight defines the tilt
  24720. * @returns the new rotation vector
  24721. */
  24722. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24723. /**
  24724. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24725. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24726. * @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
  24727. * @returns the new bounding vectors
  24728. */
  24729. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24730. min: Vector3;
  24731. max: Vector3;
  24732. };
  24733. /**
  24734. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24735. * This means the mesh underlying bounding box and sphere are recomputed.
  24736. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24737. * @returns the current mesh
  24738. */
  24739. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24740. /** @hidden */
  24741. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24742. /** @hidden */
  24743. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24744. /** @hidden */
  24745. _updateBoundingInfo(): AbstractMesh;
  24746. /** @hidden */
  24747. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24748. /** @hidden */
  24749. protected _afterComputeWorldMatrix(): void;
  24750. /**
  24751. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24752. * A mesh is in the frustum if its bounding box intersects the frustum
  24753. * @param frustumPlanes defines the frustum to test
  24754. * @returns true if the mesh is in the frustum planes
  24755. */
  24756. isInFrustum(frustumPlanes: Plane[]): boolean;
  24757. /**
  24758. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24759. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24760. * @param frustumPlanes defines the frustum to test
  24761. * @returns true if the mesh is completely in the frustum planes
  24762. */
  24763. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24764. /**
  24765. * True if the mesh intersects another mesh or a SolidParticle object
  24766. * @param mesh defines a target mesh or SolidParticle to test
  24767. * @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)
  24768. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24769. * @returns true if there is an intersection
  24770. */
  24771. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24772. /**
  24773. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24774. * @param point defines the point to test
  24775. * @returns true if there is an intersection
  24776. */
  24777. intersectsPoint(point: Vector3): boolean;
  24778. /**
  24779. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24780. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24781. */
  24782. checkCollisions: boolean;
  24783. /**
  24784. * Gets Collider object used to compute collisions (not physics)
  24785. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24786. */
  24787. readonly collider: Collider;
  24788. /**
  24789. * Move the mesh using collision engine
  24790. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24791. * @param displacement defines the requested displacement vector
  24792. * @returns the current mesh
  24793. */
  24794. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24795. private _onCollisionPositionChange;
  24796. /** @hidden */
  24797. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24798. /** @hidden */
  24799. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24800. /** @hidden */
  24801. _checkCollision(collider: Collider): AbstractMesh;
  24802. /** @hidden */
  24803. _generatePointsArray(): boolean;
  24804. /**
  24805. * Checks if the passed Ray intersects with the mesh
  24806. * @param ray defines the ray to use
  24807. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24808. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24809. * @returns the picking info
  24810. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24811. */
  24812. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  24813. /**
  24814. * Clones the current mesh
  24815. * @param name defines the mesh name
  24816. * @param newParent defines the new mesh parent
  24817. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24818. * @returns the new mesh
  24819. */
  24820. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24821. /**
  24822. * Disposes all the submeshes of the current meshnp
  24823. * @returns the current mesh
  24824. */
  24825. releaseSubMeshes(): AbstractMesh;
  24826. /**
  24827. * Releases resources associated with this abstract mesh.
  24828. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24829. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24830. */
  24831. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24832. /**
  24833. * Adds the passed mesh as a child to the current mesh
  24834. * @param mesh defines the child mesh
  24835. * @returns the current mesh
  24836. */
  24837. addChild(mesh: AbstractMesh): AbstractMesh;
  24838. /**
  24839. * Removes the passed mesh from the current mesh children list
  24840. * @param mesh defines the child mesh
  24841. * @returns the current mesh
  24842. */
  24843. removeChild(mesh: AbstractMesh): AbstractMesh;
  24844. /** @hidden */
  24845. private _initFacetData;
  24846. /**
  24847. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24848. * This method can be called within the render loop.
  24849. * 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
  24850. * @returns the current mesh
  24851. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24852. */
  24853. updateFacetData(): AbstractMesh;
  24854. /**
  24855. * Returns the facetLocalNormals array.
  24856. * The normals are expressed in the mesh local spac
  24857. * @returns an array of Vector3
  24858. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24859. */
  24860. getFacetLocalNormals(): Vector3[];
  24861. /**
  24862. * Returns the facetLocalPositions array.
  24863. * The facet positions are expressed in the mesh local space
  24864. * @returns an array of Vector3
  24865. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24866. */
  24867. getFacetLocalPositions(): Vector3[];
  24868. /**
  24869. * Returns the facetLocalPartioning array
  24870. * @returns an array of array of numbers
  24871. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24872. */
  24873. getFacetLocalPartitioning(): number[][];
  24874. /**
  24875. * Returns the i-th facet position in the world system.
  24876. * This method allocates a new Vector3 per call
  24877. * @param i defines the facet index
  24878. * @returns a new Vector3
  24879. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24880. */
  24881. getFacetPosition(i: number): Vector3;
  24882. /**
  24883. * Sets the reference Vector3 with the i-th facet position in the world system
  24884. * @param i defines the facet index
  24885. * @param ref defines the target vector
  24886. * @returns the current mesh
  24887. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24888. */
  24889. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24890. /**
  24891. * Returns the i-th facet normal in the world system.
  24892. * This method allocates a new Vector3 per call
  24893. * @param i defines the facet index
  24894. * @returns a new Vector3
  24895. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24896. */
  24897. getFacetNormal(i: number): Vector3;
  24898. /**
  24899. * Sets the reference Vector3 with the i-th facet normal in the world system
  24900. * @param i defines the facet index
  24901. * @param ref defines the target vector
  24902. * @returns the current mesh
  24903. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24904. */
  24905. getFacetNormalToRef(i: number, ref: Vector3): this;
  24906. /**
  24907. * 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)
  24908. * @param x defines x coordinate
  24909. * @param y defines y coordinate
  24910. * @param z defines z coordinate
  24911. * @returns the array of facet indexes
  24912. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24913. */
  24914. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24915. /**
  24916. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24917. * @param projected sets as the (x,y,z) world projection on the facet
  24918. * @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
  24919. * @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
  24920. * @param x defines x coordinate
  24921. * @param y defines y coordinate
  24922. * @param z defines z coordinate
  24923. * @returns the face index if found (or null instead)
  24924. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24925. */
  24926. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24927. /**
  24928. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24929. * @param projected sets as the (x,y,z) local projection on the facet
  24930. * @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
  24931. * @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
  24932. * @param x defines x coordinate
  24933. * @param y defines y coordinate
  24934. * @param z defines z coordinate
  24935. * @returns the face index if found (or null instead)
  24936. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24937. */
  24938. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24939. /**
  24940. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24941. * @returns the parameters
  24942. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24943. */
  24944. getFacetDataParameters(): any;
  24945. /**
  24946. * Disables the feature FacetData and frees the related memory
  24947. * @returns the current mesh
  24948. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24949. */
  24950. disableFacetData(): AbstractMesh;
  24951. /**
  24952. * Updates the AbstractMesh indices array
  24953. * @param indices defines the data source
  24954. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24955. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  24956. * @returns the current mesh
  24957. */
  24958. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24959. /**
  24960. * Creates new normals data for the mesh
  24961. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24962. * @returns the current mesh
  24963. */
  24964. createNormals(updatable: boolean): AbstractMesh;
  24965. /**
  24966. * Align the mesh with a normal
  24967. * @param normal defines the normal to use
  24968. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24969. * @returns the current mesh
  24970. */
  24971. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24972. /** @hidden */
  24973. _checkOcclusionQuery(): boolean;
  24974. }
  24975. }
  24976. declare module "babylonjs/Actions/actionEvent" {
  24977. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24978. import { Nullable } from "babylonjs/types";
  24979. import { Sprite } from "babylonjs/Sprites/sprite";
  24980. import { Scene } from "babylonjs/scene";
  24981. import { Vector2 } from "babylonjs/Maths/math";
  24982. /**
  24983. * Interface used to define ActionEvent
  24984. */
  24985. export interface IActionEvent {
  24986. /** The mesh or sprite that triggered the action */
  24987. source: any;
  24988. /** The X mouse cursor position at the time of the event */
  24989. pointerX: number;
  24990. /** The Y mouse cursor position at the time of the event */
  24991. pointerY: number;
  24992. /** The mesh that is currently pointed at (can be null) */
  24993. meshUnderPointer: Nullable<AbstractMesh>;
  24994. /** the original (browser) event that triggered the ActionEvent */
  24995. sourceEvent?: any;
  24996. /** additional data for the event */
  24997. additionalData?: any;
  24998. }
  24999. /**
  25000. * ActionEvent is the event being sent when an action is triggered.
  25001. */
  25002. export class ActionEvent implements IActionEvent {
  25003. /** The mesh or sprite that triggered the action */
  25004. source: any;
  25005. /** The X mouse cursor position at the time of the event */
  25006. pointerX: number;
  25007. /** The Y mouse cursor position at the time of the event */
  25008. pointerY: number;
  25009. /** The mesh that is currently pointed at (can be null) */
  25010. meshUnderPointer: Nullable<AbstractMesh>;
  25011. /** the original (browser) event that triggered the ActionEvent */
  25012. sourceEvent?: any;
  25013. /** additional data for the event */
  25014. additionalData?: any;
  25015. /**
  25016. * Creates a new ActionEvent
  25017. * @param source The mesh or sprite that triggered the action
  25018. * @param pointerX The X mouse cursor position at the time of the event
  25019. * @param pointerY The Y mouse cursor position at the time of the event
  25020. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25021. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25022. * @param additionalData additional data for the event
  25023. */
  25024. constructor(
  25025. /** The mesh or sprite that triggered the action */
  25026. source: any,
  25027. /** The X mouse cursor position at the time of the event */
  25028. pointerX: number,
  25029. /** The Y mouse cursor position at the time of the event */
  25030. pointerY: number,
  25031. /** The mesh that is currently pointed at (can be null) */
  25032. meshUnderPointer: Nullable<AbstractMesh>,
  25033. /** the original (browser) event that triggered the ActionEvent */
  25034. sourceEvent?: any,
  25035. /** additional data for the event */
  25036. additionalData?: any);
  25037. /**
  25038. * Helper function to auto-create an ActionEvent from a source mesh.
  25039. * @param source The source mesh that triggered the event
  25040. * @param evt The original (browser) event
  25041. * @param additionalData additional data for the event
  25042. * @returns the new ActionEvent
  25043. */
  25044. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25045. /**
  25046. * Helper function to auto-create an ActionEvent from a source sprite
  25047. * @param source The source sprite that triggered the event
  25048. * @param scene Scene associated with the sprite
  25049. * @param evt The original (browser) event
  25050. * @param additionalData additional data for the event
  25051. * @returns the new ActionEvent
  25052. */
  25053. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25054. /**
  25055. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25056. * @param scene the scene where the event occurred
  25057. * @param evt The original (browser) event
  25058. * @returns the new ActionEvent
  25059. */
  25060. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25061. /**
  25062. * Helper function to auto-create an ActionEvent from a primitive
  25063. * @param prim defines the target primitive
  25064. * @param pointerPos defines the pointer position
  25065. * @param evt The original (browser) event
  25066. * @param additionalData additional data for the event
  25067. * @returns the new ActionEvent
  25068. */
  25069. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25070. }
  25071. }
  25072. declare module "babylonjs/Actions/abstractActionManager" {
  25073. import { IDisposable } from "babylonjs/scene";
  25074. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  25075. import { IAction } from "babylonjs/Actions/action";
  25076. import { Nullable } from "babylonjs/types";
  25077. /**
  25078. * Abstract class used to decouple action Manager from scene and meshes.
  25079. * Do not instantiate.
  25080. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25081. */
  25082. export abstract class AbstractActionManager implements IDisposable {
  25083. /** Gets the list of active triggers */
  25084. static Triggers: {
  25085. [key: string]: number;
  25086. };
  25087. /** Gets the cursor to use when hovering items */
  25088. hoverCursor: string;
  25089. /** Gets the list of actions */
  25090. actions: IAction[];
  25091. /**
  25092. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25093. */
  25094. isRecursive: boolean;
  25095. /**
  25096. * Releases all associated resources
  25097. */
  25098. abstract dispose(): void;
  25099. /**
  25100. * Does this action manager has pointer triggers
  25101. */
  25102. abstract readonly hasPointerTriggers: boolean;
  25103. /**
  25104. * Does this action manager has pick triggers
  25105. */
  25106. abstract readonly hasPickTriggers: boolean;
  25107. /**
  25108. * Process a specific trigger
  25109. * @param trigger defines the trigger to process
  25110. * @param evt defines the event details to be processed
  25111. */
  25112. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25113. /**
  25114. * Does this action manager handles actions of any of the given triggers
  25115. * @param triggers defines the triggers to be tested
  25116. * @return a boolean indicating whether one (or more) of the triggers is handled
  25117. */
  25118. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25119. /**
  25120. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25121. * speed.
  25122. * @param triggerA defines the trigger to be tested
  25123. * @param triggerB defines the trigger to be tested
  25124. * @return a boolean indicating whether one (or more) of the triggers is handled
  25125. */
  25126. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25127. /**
  25128. * Does this action manager handles actions of a given trigger
  25129. * @param trigger defines the trigger to be tested
  25130. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25131. * @return whether the trigger is handled
  25132. */
  25133. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25134. /**
  25135. * Serialize this manager to a JSON object
  25136. * @param name defines the property name to store this manager
  25137. * @returns a JSON representation of this manager
  25138. */
  25139. abstract serialize(name: string): any;
  25140. /**
  25141. * Registers an action to this action manager
  25142. * @param action defines the action to be registered
  25143. * @return the action amended (prepared) after registration
  25144. */
  25145. abstract registerAction(action: IAction): Nullable<IAction>;
  25146. /**
  25147. * Unregisters an action to this action manager
  25148. * @param action defines the action to be unregistered
  25149. * @return a boolean indicating whether the action has been unregistered
  25150. */
  25151. abstract unregisterAction(action: IAction): Boolean;
  25152. /**
  25153. * Does exist one action manager with at least one trigger
  25154. **/
  25155. static readonly HasTriggers: boolean;
  25156. /**
  25157. * Does exist one action manager with at least one pick trigger
  25158. **/
  25159. static readonly HasPickTriggers: boolean;
  25160. /**
  25161. * Does exist one action manager that handles actions of a given trigger
  25162. * @param trigger defines the trigger to be tested
  25163. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25164. **/
  25165. static HasSpecificTrigger(trigger: number): boolean;
  25166. }
  25167. }
  25168. declare module "babylonjs/node" {
  25169. import { Scene } from "babylonjs/scene";
  25170. import { Nullable } from "babylonjs/types";
  25171. import { Matrix } from "babylonjs/Maths/math";
  25172. import { Engine } from "babylonjs/Engines/engine";
  25173. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  25174. import { Observable } from "babylonjs/Misc/observable";
  25175. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  25176. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25177. import { Animatable } from "babylonjs/Animations/animatable";
  25178. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  25179. import { Animation } from "babylonjs/Animations/animation";
  25180. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25181. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25182. /**
  25183. * Defines how a node can be built from a string name.
  25184. */
  25185. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25186. /**
  25187. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25188. */
  25189. export class Node implements IBehaviorAware<Node> {
  25190. /** @hidden */
  25191. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  25192. private static _NodeConstructors;
  25193. /**
  25194. * Add a new node constructor
  25195. * @param type defines the type name of the node to construct
  25196. * @param constructorFunc defines the constructor function
  25197. */
  25198. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25199. /**
  25200. * Returns a node constructor based on type name
  25201. * @param type defines the type name
  25202. * @param name defines the new node name
  25203. * @param scene defines the hosting scene
  25204. * @param options defines optional options to transmit to constructors
  25205. * @returns the new constructor or null
  25206. */
  25207. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25208. /**
  25209. * Gets or sets the name of the node
  25210. */
  25211. name: string;
  25212. /**
  25213. * Gets or sets the id of the node
  25214. */
  25215. id: string;
  25216. /**
  25217. * Gets or sets the unique id of the node
  25218. */
  25219. uniqueId: number;
  25220. /**
  25221. * Gets or sets a string used to store user defined state for the node
  25222. */
  25223. state: string;
  25224. /**
  25225. * Gets or sets an object used to store user defined information for the node
  25226. */
  25227. metadata: any;
  25228. /**
  25229. * For internal use only. Please do not use.
  25230. */
  25231. reservedDataStore: any;
  25232. /**
  25233. * List of inspectable custom properties (used by the Inspector)
  25234. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25235. */
  25236. inspectableCustomProperties: IInspectable[];
  25237. /**
  25238. * Gets or sets a boolean used to define if the node must be serialized
  25239. */
  25240. doNotSerialize: boolean;
  25241. /** @hidden */
  25242. _isDisposed: boolean;
  25243. /**
  25244. * Gets a list of Animations associated with the node
  25245. */
  25246. animations: import("babylonjs/Animations/animation").Animation[];
  25247. protected _ranges: {
  25248. [name: string]: Nullable<AnimationRange>;
  25249. };
  25250. /**
  25251. * Callback raised when the node is ready to be used
  25252. */
  25253. onReady: (node: Node) => void;
  25254. private _isEnabled;
  25255. private _isParentEnabled;
  25256. private _isReady;
  25257. /** @hidden */
  25258. _currentRenderId: number;
  25259. private _parentRenderId;
  25260. protected _childRenderId: number;
  25261. /** @hidden */
  25262. _waitingParentId: Nullable<string>;
  25263. /** @hidden */
  25264. _scene: Scene;
  25265. /** @hidden */
  25266. _cache: any;
  25267. private _parentNode;
  25268. private _children;
  25269. /** @hidden */
  25270. _worldMatrix: Matrix;
  25271. /** @hidden */
  25272. _worldMatrixDeterminant: number;
  25273. /** @hidden */
  25274. private _sceneRootNodesIndex;
  25275. /**
  25276. * Gets a boolean indicating if the node has been disposed
  25277. * @returns true if the node was disposed
  25278. */
  25279. isDisposed(): boolean;
  25280. /**
  25281. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25282. * @see https://doc.babylonjs.com/how_to/parenting
  25283. */
  25284. parent: Nullable<Node>;
  25285. private addToSceneRootNodes;
  25286. private removeFromSceneRootNodes;
  25287. private _animationPropertiesOverride;
  25288. /**
  25289. * Gets or sets the animation properties override
  25290. */
  25291. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25292. /**
  25293. * Gets a string idenfifying the name of the class
  25294. * @returns "Node" string
  25295. */
  25296. getClassName(): string;
  25297. /** @hidden */
  25298. readonly _isNode: boolean;
  25299. /**
  25300. * An event triggered when the mesh is disposed
  25301. */
  25302. onDisposeObservable: Observable<Node>;
  25303. private _onDisposeObserver;
  25304. /**
  25305. * Sets a callback that will be raised when the node will be disposed
  25306. */
  25307. onDispose: () => void;
  25308. /**
  25309. * Creates a new Node
  25310. * @param name the name and id to be given to this node
  25311. * @param scene the scene this node will be added to
  25312. * @param addToRootNodes the node will be added to scene.rootNodes
  25313. */
  25314. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25315. /**
  25316. * Gets the scene of the node
  25317. * @returns a scene
  25318. */
  25319. getScene(): Scene;
  25320. /**
  25321. * Gets the engine of the node
  25322. * @returns a Engine
  25323. */
  25324. getEngine(): Engine;
  25325. private _behaviors;
  25326. /**
  25327. * Attach a behavior to the node
  25328. * @see http://doc.babylonjs.com/features/behaviour
  25329. * @param behavior defines the behavior to attach
  25330. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25331. * @returns the current Node
  25332. */
  25333. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25334. /**
  25335. * Remove an attached behavior
  25336. * @see http://doc.babylonjs.com/features/behaviour
  25337. * @param behavior defines the behavior to attach
  25338. * @returns the current Node
  25339. */
  25340. removeBehavior(behavior: Behavior<Node>): Node;
  25341. /**
  25342. * Gets the list of attached behaviors
  25343. * @see http://doc.babylonjs.com/features/behaviour
  25344. */
  25345. readonly behaviors: Behavior<Node>[];
  25346. /**
  25347. * Gets an attached behavior by name
  25348. * @param name defines the name of the behavior to look for
  25349. * @see http://doc.babylonjs.com/features/behaviour
  25350. * @returns null if behavior was not found else the requested behavior
  25351. */
  25352. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25353. /**
  25354. * Returns the latest update of the World matrix
  25355. * @returns a Matrix
  25356. */
  25357. getWorldMatrix(): Matrix;
  25358. /** @hidden */
  25359. _getWorldMatrixDeterminant(): number;
  25360. /**
  25361. * Returns directly the latest state of the mesh World matrix.
  25362. * A Matrix is returned.
  25363. */
  25364. readonly worldMatrixFromCache: Matrix;
  25365. /** @hidden */
  25366. _initCache(): void;
  25367. /** @hidden */
  25368. updateCache(force?: boolean): void;
  25369. /** @hidden */
  25370. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25371. /** @hidden */
  25372. _updateCache(ignoreParentClass?: boolean): void;
  25373. /** @hidden */
  25374. _isSynchronized(): boolean;
  25375. /** @hidden */
  25376. _markSyncedWithParent(): void;
  25377. /** @hidden */
  25378. isSynchronizedWithParent(): boolean;
  25379. /** @hidden */
  25380. isSynchronized(): boolean;
  25381. /**
  25382. * Is this node ready to be used/rendered
  25383. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25384. * @return true if the node is ready
  25385. */
  25386. isReady(completeCheck?: boolean): boolean;
  25387. /**
  25388. * Is this node enabled?
  25389. * 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
  25390. * @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
  25391. * @return whether this node (and its parent) is enabled
  25392. */
  25393. isEnabled(checkAncestors?: boolean): boolean;
  25394. /** @hidden */
  25395. protected _syncParentEnabledState(): void;
  25396. /**
  25397. * Set the enabled state of this node
  25398. * @param value defines the new enabled state
  25399. */
  25400. setEnabled(value: boolean): void;
  25401. /**
  25402. * Is this node a descendant of the given node?
  25403. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25404. * @param ancestor defines the parent node to inspect
  25405. * @returns a boolean indicating if this node is a descendant of the given node
  25406. */
  25407. isDescendantOf(ancestor: Node): boolean;
  25408. /** @hidden */
  25409. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25410. /**
  25411. * Will return all nodes that have this node as ascendant
  25412. * @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
  25413. * @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
  25414. * @return all children nodes of all types
  25415. */
  25416. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25417. /**
  25418. * Get all child-meshes of this node
  25419. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: false)
  25420. * @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
  25421. * @returns an array of AbstractMesh
  25422. */
  25423. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25424. /**
  25425. * Get all direct children of this node
  25426. * @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
  25427. * @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)
  25428. * @returns an array of Node
  25429. */
  25430. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25431. /** @hidden */
  25432. _setReady(state: boolean): void;
  25433. /**
  25434. * Get an animation by name
  25435. * @param name defines the name of the animation to look for
  25436. * @returns null if not found else the requested animation
  25437. */
  25438. getAnimationByName(name: string): Nullable<Animation>;
  25439. /**
  25440. * Creates an animation range for this node
  25441. * @param name defines the name of the range
  25442. * @param from defines the starting key
  25443. * @param to defines the end key
  25444. */
  25445. createAnimationRange(name: string, from: number, to: number): void;
  25446. /**
  25447. * Delete a specific animation range
  25448. * @param name defines the name of the range to delete
  25449. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25450. */
  25451. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25452. /**
  25453. * Get an animation range by name
  25454. * @param name defines the name of the animation range to look for
  25455. * @returns null if not found else the requested animation range
  25456. */
  25457. getAnimationRange(name: string): Nullable<AnimationRange>;
  25458. /**
  25459. * Gets the list of all animation ranges defined on this node
  25460. * @returns an array
  25461. */
  25462. getAnimationRanges(): Nullable<AnimationRange>[];
  25463. /**
  25464. * Will start the animation sequence
  25465. * @param name defines the range frames for animation sequence
  25466. * @param loop defines if the animation should loop (false by default)
  25467. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25468. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25469. * @returns the object created for this animation. If range does not exist, it will return null
  25470. */
  25471. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25472. /**
  25473. * Serialize animation ranges into a JSON compatible object
  25474. * @returns serialization object
  25475. */
  25476. serializeAnimationRanges(): any;
  25477. /**
  25478. * Computes the world matrix of the node
  25479. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25480. * @returns the world matrix
  25481. */
  25482. computeWorldMatrix(force?: boolean): Matrix;
  25483. /**
  25484. * Releases resources associated with this node.
  25485. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25486. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25487. */
  25488. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25489. /**
  25490. * Parse animation range data from a serialization object and store them into a given node
  25491. * @param node defines where to store the animation ranges
  25492. * @param parsedNode defines the serialization object to read data from
  25493. * @param scene defines the hosting scene
  25494. */
  25495. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25496. }
  25497. }
  25498. declare module "babylonjs/Animations/animation" {
  25499. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  25500. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  25501. import { Nullable } from "babylonjs/types";
  25502. import { Scene } from "babylonjs/scene";
  25503. import { IAnimatable } from "babylonjs/Misc/tools";
  25504. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  25505. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25506. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  25507. import { Node } from "babylonjs/node";
  25508. import { Animatable } from "babylonjs/Animations/animatable";
  25509. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  25510. /**
  25511. * Class used to store any kind of animation
  25512. */
  25513. export class Animation {
  25514. /**Name of the animation */
  25515. name: string;
  25516. /**Property to animate */
  25517. targetProperty: string;
  25518. /**The frames per second of the animation */
  25519. framePerSecond: number;
  25520. /**The data type of the animation */
  25521. dataType: number;
  25522. /**The loop mode of the animation */
  25523. loopMode?: number | undefined;
  25524. /**Specifies if blending should be enabled */
  25525. enableBlending?: boolean | undefined;
  25526. /**
  25527. * Use matrix interpolation instead of using direct key value when animating matrices
  25528. */
  25529. static AllowMatricesInterpolation: boolean;
  25530. /**
  25531. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25532. */
  25533. static AllowMatrixDecomposeForInterpolation: boolean;
  25534. /**
  25535. * Stores the key frames of the animation
  25536. */
  25537. private _keys;
  25538. /**
  25539. * Stores the easing function of the animation
  25540. */
  25541. private _easingFunction;
  25542. /**
  25543. * @hidden Internal use only
  25544. */
  25545. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  25546. /**
  25547. * The set of event that will be linked to this animation
  25548. */
  25549. private _events;
  25550. /**
  25551. * Stores an array of target property paths
  25552. */
  25553. targetPropertyPath: string[];
  25554. /**
  25555. * Stores the blending speed of the animation
  25556. */
  25557. blendingSpeed: number;
  25558. /**
  25559. * Stores the animation ranges for the animation
  25560. */
  25561. private _ranges;
  25562. /**
  25563. * @hidden Internal use
  25564. */
  25565. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25566. /**
  25567. * Sets up an animation
  25568. * @param property The property to animate
  25569. * @param animationType The animation type to apply
  25570. * @param framePerSecond The frames per second of the animation
  25571. * @param easingFunction The easing function used in the animation
  25572. * @returns The created animation
  25573. */
  25574. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25575. /**
  25576. * Create and start an animation on a node
  25577. * @param name defines the name of the global animation that will be run on all nodes
  25578. * @param node defines the root node where the animation will take place
  25579. * @param targetProperty defines property to animate
  25580. * @param framePerSecond defines the number of frame per second yo use
  25581. * @param totalFrame defines the number of frames in total
  25582. * @param from defines the initial value
  25583. * @param to defines the final value
  25584. * @param loopMode defines which loop mode you want to use (off by default)
  25585. * @param easingFunction defines the easing function to use (linear by default)
  25586. * @param onAnimationEnd defines the callback to call when animation end
  25587. * @returns the animatable created for this animation
  25588. */
  25589. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25590. /**
  25591. * Create and start an animation on a node and its descendants
  25592. * @param name defines the name of the global animation that will be run on all nodes
  25593. * @param node defines the root node where the animation will take place
  25594. * @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
  25595. * @param targetProperty defines property to animate
  25596. * @param framePerSecond defines the number of frame per second to use
  25597. * @param totalFrame defines the number of frames in total
  25598. * @param from defines the initial value
  25599. * @param to defines the final value
  25600. * @param loopMode defines which loop mode you want to use (off by default)
  25601. * @param easingFunction defines the easing function to use (linear by default)
  25602. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25603. * @returns the list of animatables created for all nodes
  25604. * @example https://www.babylonjs-playground.com/#MH0VLI
  25605. */
  25606. 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[]>;
  25607. /**
  25608. * Creates a new animation, merges it with the existing animations and starts it
  25609. * @param name Name of the animation
  25610. * @param node Node which contains the scene that begins the animations
  25611. * @param targetProperty Specifies which property to animate
  25612. * @param framePerSecond The frames per second of the animation
  25613. * @param totalFrame The total number of frames
  25614. * @param from The frame at the beginning of the animation
  25615. * @param to The frame at the end of the animation
  25616. * @param loopMode Specifies the loop mode of the animation
  25617. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25618. * @param onAnimationEnd Callback to run once the animation is complete
  25619. * @returns Nullable animation
  25620. */
  25621. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25622. /**
  25623. * Transition property of an host to the target Value
  25624. * @param property The property to transition
  25625. * @param targetValue The target Value of the property
  25626. * @param host The object where the property to animate belongs
  25627. * @param scene Scene used to run the animation
  25628. * @param frameRate Framerate (in frame/s) to use
  25629. * @param transition The transition type we want to use
  25630. * @param duration The duration of the animation, in milliseconds
  25631. * @param onAnimationEnd Callback trigger at the end of the animation
  25632. * @returns Nullable animation
  25633. */
  25634. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25635. /**
  25636. * Return the array of runtime animations currently using this animation
  25637. */
  25638. readonly runtimeAnimations: RuntimeAnimation[];
  25639. /**
  25640. * Specifies if any of the runtime animations are currently running
  25641. */
  25642. readonly hasRunningRuntimeAnimations: boolean;
  25643. /**
  25644. * Initializes the animation
  25645. * @param name Name of the animation
  25646. * @param targetProperty Property to animate
  25647. * @param framePerSecond The frames per second of the animation
  25648. * @param dataType The data type of the animation
  25649. * @param loopMode The loop mode of the animation
  25650. * @param enableBlending Specifies if blending should be enabled
  25651. */
  25652. constructor(
  25653. /**Name of the animation */
  25654. name: string,
  25655. /**Property to animate */
  25656. targetProperty: string,
  25657. /**The frames per second of the animation */
  25658. framePerSecond: number,
  25659. /**The data type of the animation */
  25660. dataType: number,
  25661. /**The loop mode of the animation */
  25662. loopMode?: number | undefined,
  25663. /**Specifies if blending should be enabled */
  25664. enableBlending?: boolean | undefined);
  25665. /**
  25666. * Converts the animation to a string
  25667. * @param fullDetails support for multiple levels of logging within scene loading
  25668. * @returns String form of the animation
  25669. */
  25670. toString(fullDetails?: boolean): string;
  25671. /**
  25672. * Add an event to this animation
  25673. * @param event Event to add
  25674. */
  25675. addEvent(event: AnimationEvent): void;
  25676. /**
  25677. * Remove all events found at the given frame
  25678. * @param frame The frame to remove events from
  25679. */
  25680. removeEvents(frame: number): void;
  25681. /**
  25682. * Retrieves all the events from the animation
  25683. * @returns Events from the animation
  25684. */
  25685. getEvents(): AnimationEvent[];
  25686. /**
  25687. * Creates an animation range
  25688. * @param name Name of the animation range
  25689. * @param from Starting frame of the animation range
  25690. * @param to Ending frame of the animation
  25691. */
  25692. createRange(name: string, from: number, to: number): void;
  25693. /**
  25694. * Deletes an animation range by name
  25695. * @param name Name of the animation range to delete
  25696. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25697. */
  25698. deleteRange(name: string, deleteFrames?: boolean): void;
  25699. /**
  25700. * Gets the animation range by name, or null if not defined
  25701. * @param name Name of the animation range
  25702. * @returns Nullable animation range
  25703. */
  25704. getRange(name: string): Nullable<AnimationRange>;
  25705. /**
  25706. * Gets the key frames from the animation
  25707. * @returns The key frames of the animation
  25708. */
  25709. getKeys(): Array<IAnimationKey>;
  25710. /**
  25711. * Gets the highest frame rate of the animation
  25712. * @returns Highest frame rate of the animation
  25713. */
  25714. getHighestFrame(): number;
  25715. /**
  25716. * Gets the easing function of the animation
  25717. * @returns Easing function of the animation
  25718. */
  25719. getEasingFunction(): IEasingFunction;
  25720. /**
  25721. * Sets the easing function of the animation
  25722. * @param easingFunction A custom mathematical formula for animation
  25723. */
  25724. setEasingFunction(easingFunction: EasingFunction): void;
  25725. /**
  25726. * Interpolates a scalar linearly
  25727. * @param startValue Start value of the animation curve
  25728. * @param endValue End value of the animation curve
  25729. * @param gradient Scalar amount to interpolate
  25730. * @returns Interpolated scalar value
  25731. */
  25732. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25733. /**
  25734. * Interpolates a scalar cubically
  25735. * @param startValue Start value of the animation curve
  25736. * @param outTangent End tangent of the animation
  25737. * @param endValue End value of the animation curve
  25738. * @param inTangent Start tangent of the animation curve
  25739. * @param gradient Scalar amount to interpolate
  25740. * @returns Interpolated scalar value
  25741. */
  25742. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25743. /**
  25744. * Interpolates a quaternion using a spherical linear interpolation
  25745. * @param startValue Start value of the animation curve
  25746. * @param endValue End value of the animation curve
  25747. * @param gradient Scalar amount to interpolate
  25748. * @returns Interpolated quaternion value
  25749. */
  25750. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25751. /**
  25752. * Interpolates a quaternion cubically
  25753. * @param startValue Start value of the animation curve
  25754. * @param outTangent End tangent of the animation curve
  25755. * @param endValue End value of the animation curve
  25756. * @param inTangent Start tangent of the animation curve
  25757. * @param gradient Scalar amount to interpolate
  25758. * @returns Interpolated quaternion value
  25759. */
  25760. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25761. /**
  25762. * Interpolates a Vector3 linearl
  25763. * @param startValue Start value of the animation curve
  25764. * @param endValue End value of the animation curve
  25765. * @param gradient Scalar amount to interpolate
  25766. * @returns Interpolated scalar value
  25767. */
  25768. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25769. /**
  25770. * Interpolates a Vector3 cubically
  25771. * @param startValue Start value of the animation curve
  25772. * @param outTangent End tangent of the animation
  25773. * @param endValue End value of the animation curve
  25774. * @param inTangent Start tangent of the animation curve
  25775. * @param gradient Scalar amount to interpolate
  25776. * @returns InterpolatedVector3 value
  25777. */
  25778. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25779. /**
  25780. * Interpolates a Vector2 linearly
  25781. * @param startValue Start value of the animation curve
  25782. * @param endValue End value of the animation curve
  25783. * @param gradient Scalar amount to interpolate
  25784. * @returns Interpolated Vector2 value
  25785. */
  25786. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25787. /**
  25788. * Interpolates a Vector2 cubically
  25789. * @param startValue Start value of the animation curve
  25790. * @param outTangent End tangent of the animation
  25791. * @param endValue End value of the animation curve
  25792. * @param inTangent Start tangent of the animation curve
  25793. * @param gradient Scalar amount to interpolate
  25794. * @returns Interpolated Vector2 value
  25795. */
  25796. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25797. /**
  25798. * Interpolates a size linearly
  25799. * @param startValue Start value of the animation curve
  25800. * @param endValue End value of the animation curve
  25801. * @param gradient Scalar amount to interpolate
  25802. * @returns Interpolated Size value
  25803. */
  25804. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25805. /**
  25806. * Interpolates a Color3 linearly
  25807. * @param startValue Start value of the animation curve
  25808. * @param endValue End value of the animation curve
  25809. * @param gradient Scalar amount to interpolate
  25810. * @returns Interpolated Color3 value
  25811. */
  25812. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25813. /**
  25814. * @hidden Internal use only
  25815. */
  25816. _getKeyValue(value: any): any;
  25817. /**
  25818. * @hidden Internal use only
  25819. */
  25820. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  25821. /**
  25822. * Defines the function to use to interpolate matrices
  25823. * @param startValue defines the start matrix
  25824. * @param endValue defines the end matrix
  25825. * @param gradient defines the gradient between both matrices
  25826. * @param result defines an optional target matrix where to store the interpolation
  25827. * @returns the interpolated matrix
  25828. */
  25829. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25830. /**
  25831. * Makes a copy of the animation
  25832. * @returns Cloned animation
  25833. */
  25834. clone(): Animation;
  25835. /**
  25836. * Sets the key frames of the animation
  25837. * @param values The animation key frames to set
  25838. */
  25839. setKeys(values: Array<IAnimationKey>): void;
  25840. /**
  25841. * Serializes the animation to an object
  25842. * @returns Serialized object
  25843. */
  25844. serialize(): any;
  25845. /**
  25846. * Float animation type
  25847. */
  25848. private static _ANIMATIONTYPE_FLOAT;
  25849. /**
  25850. * Vector3 animation type
  25851. */
  25852. private static _ANIMATIONTYPE_VECTOR3;
  25853. /**
  25854. * Quaternion animation type
  25855. */
  25856. private static _ANIMATIONTYPE_QUATERNION;
  25857. /**
  25858. * Matrix animation type
  25859. */
  25860. private static _ANIMATIONTYPE_MATRIX;
  25861. /**
  25862. * Color3 animation type
  25863. */
  25864. private static _ANIMATIONTYPE_COLOR3;
  25865. /**
  25866. * Vector2 animation type
  25867. */
  25868. private static _ANIMATIONTYPE_VECTOR2;
  25869. /**
  25870. * Size animation type
  25871. */
  25872. private static _ANIMATIONTYPE_SIZE;
  25873. /**
  25874. * Relative Loop Mode
  25875. */
  25876. private static _ANIMATIONLOOPMODE_RELATIVE;
  25877. /**
  25878. * Cycle Loop Mode
  25879. */
  25880. private static _ANIMATIONLOOPMODE_CYCLE;
  25881. /**
  25882. * Constant Loop Mode
  25883. */
  25884. private static _ANIMATIONLOOPMODE_CONSTANT;
  25885. /**
  25886. * Get the float animation type
  25887. */
  25888. static readonly ANIMATIONTYPE_FLOAT: number;
  25889. /**
  25890. * Get the Vector3 animation type
  25891. */
  25892. static readonly ANIMATIONTYPE_VECTOR3: number;
  25893. /**
  25894. * Get the Vector2 animation type
  25895. */
  25896. static readonly ANIMATIONTYPE_VECTOR2: number;
  25897. /**
  25898. * Get the Size animation type
  25899. */
  25900. static readonly ANIMATIONTYPE_SIZE: number;
  25901. /**
  25902. * Get the Quaternion animation type
  25903. */
  25904. static readonly ANIMATIONTYPE_QUATERNION: number;
  25905. /**
  25906. * Get the Matrix animation type
  25907. */
  25908. static readonly ANIMATIONTYPE_MATRIX: number;
  25909. /**
  25910. * Get the Color3 animation type
  25911. */
  25912. static readonly ANIMATIONTYPE_COLOR3: number;
  25913. /**
  25914. * Get the Relative Loop Mode
  25915. */
  25916. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25917. /**
  25918. * Get the Cycle Loop Mode
  25919. */
  25920. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25921. /**
  25922. * Get the Constant Loop Mode
  25923. */
  25924. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25925. /** @hidden */
  25926. static _UniversalLerp(left: any, right: any, amount: number): any;
  25927. /**
  25928. * Parses an animation object and creates an animation
  25929. * @param parsedAnimation Parsed animation object
  25930. * @returns Animation object
  25931. */
  25932. static Parse(parsedAnimation: any): Animation;
  25933. /**
  25934. * Appends the serialized animations from the source animations
  25935. * @param source Source containing the animations
  25936. * @param destination Target to store the animations
  25937. */
  25938. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25939. }
  25940. }
  25941. declare module "babylonjs/Materials/Textures/baseTexture" {
  25942. import { Observable } from "babylonjs/Misc/observable";
  25943. import { IAnimatable } from "babylonjs/Misc/tools";
  25944. import { Nullable } from "babylonjs/types";
  25945. import { Scene } from "babylonjs/scene";
  25946. import { Matrix, ISize } from "babylonjs/Maths/math";
  25947. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  25948. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  25949. /**
  25950. * Base class of all the textures in babylon.
  25951. * It groups all the common properties the materials, post process, lights... might need
  25952. * in order to make a correct use of the texture.
  25953. */
  25954. export class BaseTexture implements IAnimatable {
  25955. /**
  25956. * Default anisotropic filtering level for the application.
  25957. * It is set to 4 as a good tradeoff between perf and quality.
  25958. */
  25959. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25960. /**
  25961. * Gets or sets the unique id of the texture
  25962. */
  25963. uniqueId: number;
  25964. /**
  25965. * Define the name of the texture.
  25966. */
  25967. name: string;
  25968. /**
  25969. * Gets or sets an object used to store user defined information.
  25970. */
  25971. metadata: any;
  25972. /**
  25973. * For internal use only. Please do not use.
  25974. */
  25975. reservedDataStore: any;
  25976. private _hasAlpha;
  25977. /**
  25978. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25979. */
  25980. hasAlpha: boolean;
  25981. /**
  25982. * Defines if the alpha value should be determined via the rgb values.
  25983. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25984. */
  25985. getAlphaFromRGB: boolean;
  25986. /**
  25987. * Intensity or strength of the texture.
  25988. * It is commonly used by materials to fine tune the intensity of the texture
  25989. */
  25990. level: number;
  25991. /**
  25992. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25993. * This is part of the texture as textures usually maps to one uv set.
  25994. */
  25995. coordinatesIndex: number;
  25996. private _coordinatesMode;
  25997. /**
  25998. * How a texture is mapped.
  25999. *
  26000. * | Value | Type | Description |
  26001. * | ----- | ----------------------------------- | ----------- |
  26002. * | 0 | EXPLICIT_MODE | |
  26003. * | 1 | SPHERICAL_MODE | |
  26004. * | 2 | PLANAR_MODE | |
  26005. * | 3 | CUBIC_MODE | |
  26006. * | 4 | PROJECTION_MODE | |
  26007. * | 5 | SKYBOX_MODE | |
  26008. * | 6 | INVCUBIC_MODE | |
  26009. * | 7 | EQUIRECTANGULAR_MODE | |
  26010. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26011. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26012. */
  26013. coordinatesMode: number;
  26014. /**
  26015. * | Value | Type | Description |
  26016. * | ----- | ------------------ | ----------- |
  26017. * | 0 | CLAMP_ADDRESSMODE | |
  26018. * | 1 | WRAP_ADDRESSMODE | |
  26019. * | 2 | MIRROR_ADDRESSMODE | |
  26020. */
  26021. wrapU: number;
  26022. /**
  26023. * | Value | Type | Description |
  26024. * | ----- | ------------------ | ----------- |
  26025. * | 0 | CLAMP_ADDRESSMODE | |
  26026. * | 1 | WRAP_ADDRESSMODE | |
  26027. * | 2 | MIRROR_ADDRESSMODE | |
  26028. */
  26029. wrapV: number;
  26030. /**
  26031. * | Value | Type | Description |
  26032. * | ----- | ------------------ | ----------- |
  26033. * | 0 | CLAMP_ADDRESSMODE | |
  26034. * | 1 | WRAP_ADDRESSMODE | |
  26035. * | 2 | MIRROR_ADDRESSMODE | |
  26036. */
  26037. wrapR: number;
  26038. /**
  26039. * With compliant hardware and browser (supporting anisotropic filtering)
  26040. * this defines the level of anisotropic filtering in the texture.
  26041. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26042. */
  26043. anisotropicFilteringLevel: number;
  26044. /**
  26045. * Define if the texture is a cube texture or if false a 2d texture.
  26046. */
  26047. isCube: boolean;
  26048. /**
  26049. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26050. */
  26051. is3D: boolean;
  26052. /**
  26053. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26054. * HDR texture are usually stored in linear space.
  26055. * This only impacts the PBR and Background materials
  26056. */
  26057. gammaSpace: boolean;
  26058. /**
  26059. * Gets whether or not the texture contains RGBD data.
  26060. */
  26061. readonly isRGBD: boolean;
  26062. /**
  26063. * Is Z inverted in the texture (useful in a cube texture).
  26064. */
  26065. invertZ: boolean;
  26066. /**
  26067. * Are mip maps generated for this texture or not.
  26068. */
  26069. readonly noMipmap: boolean;
  26070. /**
  26071. * @hidden
  26072. */
  26073. lodLevelInAlpha: boolean;
  26074. /**
  26075. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26076. */
  26077. lodGenerationOffset: number;
  26078. /**
  26079. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26080. */
  26081. lodGenerationScale: number;
  26082. /**
  26083. * Define if the texture is a render target.
  26084. */
  26085. isRenderTarget: boolean;
  26086. /**
  26087. * Define the unique id of the texture in the scene.
  26088. */
  26089. readonly uid: string;
  26090. /**
  26091. * Return a string representation of the texture.
  26092. * @returns the texture as a string
  26093. */
  26094. toString(): string;
  26095. /**
  26096. * Get the class name of the texture.
  26097. * @returns "BaseTexture"
  26098. */
  26099. getClassName(): string;
  26100. /**
  26101. * Define the list of animation attached to the texture.
  26102. */
  26103. animations: import("babylonjs/Animations/animation").Animation[];
  26104. /**
  26105. * An event triggered when the texture is disposed.
  26106. */
  26107. onDisposeObservable: Observable<BaseTexture>;
  26108. private _onDisposeObserver;
  26109. /**
  26110. * Callback triggered when the texture has been disposed.
  26111. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26112. */
  26113. onDispose: () => void;
  26114. /**
  26115. * Define the current state of the loading sequence when in delayed load mode.
  26116. */
  26117. delayLoadState: number;
  26118. private _scene;
  26119. /** @hidden */
  26120. _texture: Nullable<InternalTexture>;
  26121. private _uid;
  26122. /**
  26123. * Define if the texture is preventinga material to render or not.
  26124. * If not and the texture is not ready, the engine will use a default black texture instead.
  26125. */
  26126. readonly isBlocking: boolean;
  26127. /**
  26128. * Instantiates a new BaseTexture.
  26129. * Base class of all the textures in babylon.
  26130. * It groups all the common properties the materials, post process, lights... might need
  26131. * in order to make a correct use of the texture.
  26132. * @param scene Define the scene the texture blongs to
  26133. */
  26134. constructor(scene: Nullable<Scene>);
  26135. /**
  26136. * Get the scene the texture belongs to.
  26137. * @returns the scene or null if undefined
  26138. */
  26139. getScene(): Nullable<Scene>;
  26140. /**
  26141. * Get the texture transform matrix used to offset tile the texture for istance.
  26142. * @returns the transformation matrix
  26143. */
  26144. getTextureMatrix(): Matrix;
  26145. /**
  26146. * Get the texture reflection matrix used to rotate/transform the reflection.
  26147. * @returns the reflection matrix
  26148. */
  26149. getReflectionTextureMatrix(): Matrix;
  26150. /**
  26151. * Get the underlying lower level texture from Babylon.
  26152. * @returns the insternal texture
  26153. */
  26154. getInternalTexture(): Nullable<InternalTexture>;
  26155. /**
  26156. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26157. * @returns true if ready or not blocking
  26158. */
  26159. isReadyOrNotBlocking(): boolean;
  26160. /**
  26161. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26162. * @returns true if fully ready
  26163. */
  26164. isReady(): boolean;
  26165. private _cachedSize;
  26166. /**
  26167. * Get the size of the texture.
  26168. * @returns the texture size.
  26169. */
  26170. getSize(): ISize;
  26171. /**
  26172. * Get the base size of the texture.
  26173. * It can be different from the size if the texture has been resized for POT for instance
  26174. * @returns the base size
  26175. */
  26176. getBaseSize(): ISize;
  26177. /**
  26178. * Update the sampling mode of the texture.
  26179. * Default is Trilinear mode.
  26180. *
  26181. * | Value | Type | Description |
  26182. * | ----- | ------------------ | ----------- |
  26183. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26184. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26185. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26186. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26187. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26188. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26189. * | 7 | NEAREST_LINEAR | |
  26190. * | 8 | NEAREST_NEAREST | |
  26191. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26192. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26193. * | 11 | LINEAR_LINEAR | |
  26194. * | 12 | LINEAR_NEAREST | |
  26195. *
  26196. * > _mag_: magnification filter (close to the viewer)
  26197. * > _min_: minification filter (far from the viewer)
  26198. * > _mip_: filter used between mip map levels
  26199. *@param samplingMode Define the new sampling mode of the texture
  26200. */
  26201. updateSamplingMode(samplingMode: number): void;
  26202. /**
  26203. * Scales the texture if is `canRescale()`
  26204. * @param ratio the resize factor we want to use to rescale
  26205. */
  26206. scale(ratio: number): void;
  26207. /**
  26208. * Get if the texture can rescale.
  26209. */
  26210. readonly canRescale: boolean;
  26211. /** @hidden */
  26212. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26213. /** @hidden */
  26214. _rebuild(): void;
  26215. /**
  26216. * Triggers the load sequence in delayed load mode.
  26217. */
  26218. delayLoad(): void;
  26219. /**
  26220. * Clones the texture.
  26221. * @returns the cloned texture
  26222. */
  26223. clone(): Nullable<BaseTexture>;
  26224. /**
  26225. * Get the texture underlying type (INT, FLOAT...)
  26226. */
  26227. readonly textureType: number;
  26228. /**
  26229. * Get the texture underlying format (RGB, RGBA...)
  26230. */
  26231. readonly textureFormat: number;
  26232. /**
  26233. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26234. * This will returns an RGBA array buffer containing either in values (0-255) or
  26235. * float values (0-1) depending of the underlying buffer type.
  26236. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26237. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26238. * @param buffer defines a user defined buffer to fill with data (can be null)
  26239. * @returns The Array buffer containing the pixels data.
  26240. */
  26241. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26242. /**
  26243. * Release and destroy the underlying lower level texture aka internalTexture.
  26244. */
  26245. releaseInternalTexture(): void;
  26246. /**
  26247. * Get the polynomial representation of the texture data.
  26248. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26249. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26250. */
  26251. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26252. /** @hidden */
  26253. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26254. /** @hidden */
  26255. readonly _lodTextureMid: Nullable<BaseTexture>;
  26256. /** @hidden */
  26257. readonly _lodTextureLow: Nullable<BaseTexture>;
  26258. /**
  26259. * Dispose the texture and release its associated resources.
  26260. */
  26261. dispose(): void;
  26262. /**
  26263. * Serialize the texture into a JSON representation that can be parsed later on.
  26264. * @returns the JSON representation of the texture
  26265. */
  26266. serialize(): any;
  26267. /**
  26268. * Helper function to be called back once a list of texture contains only ready textures.
  26269. * @param textures Define the list of textures to wait for
  26270. * @param callback Define the callback triggered once the entire list will be ready
  26271. */
  26272. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26273. }
  26274. }
  26275. declare module "babylonjs/Materials/uniformBuffer" {
  26276. import { Nullable, FloatArray } from "babylonjs/types";
  26277. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  26278. import { Engine } from "babylonjs/Engines/engine";
  26279. import { Effect } from "babylonjs/Materials/effect";
  26280. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26281. /**
  26282. * Uniform buffer objects.
  26283. *
  26284. * Handles blocks of uniform on the GPU.
  26285. *
  26286. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26287. *
  26288. * For more information, please refer to :
  26289. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26290. */
  26291. export class UniformBuffer {
  26292. private _engine;
  26293. private _buffer;
  26294. private _data;
  26295. private _bufferData;
  26296. private _dynamic?;
  26297. private _uniformLocations;
  26298. private _uniformSizes;
  26299. private _uniformLocationPointer;
  26300. private _needSync;
  26301. private _noUBO;
  26302. private _currentEffect;
  26303. private static _MAX_UNIFORM_SIZE;
  26304. private static _tempBuffer;
  26305. /**
  26306. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  26307. * This is dynamic to allow compat with webgl 1 and 2.
  26308. * You will need to pass the name of the uniform as well as the value.
  26309. */
  26310. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26311. /**
  26312. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  26313. * This is dynamic to allow compat with webgl 1 and 2.
  26314. * You will need to pass the name of the uniform as well as the value.
  26315. */
  26316. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26317. /**
  26318. * Lambda to Update a single float in a uniform buffer.
  26319. * This is dynamic to allow compat with webgl 1 and 2.
  26320. * You will need to pass the name of the uniform as well as the value.
  26321. */
  26322. updateFloat: (name: string, x: number) => void;
  26323. /**
  26324. * Lambda to Update a vec2 of float in a uniform buffer.
  26325. * This is dynamic to allow compat with webgl 1 and 2.
  26326. * You will need to pass the name of the uniform as well as the value.
  26327. */
  26328. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26329. /**
  26330. * Lambda to Update a vec3 of float in a uniform buffer.
  26331. * This is dynamic to allow compat with webgl 1 and 2.
  26332. * You will need to pass the name of the uniform as well as the value.
  26333. */
  26334. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26335. /**
  26336. * Lambda to Update a vec4 of float in a uniform buffer.
  26337. * This is dynamic to allow compat with webgl 1 and 2.
  26338. * You will need to pass the name of the uniform as well as the value.
  26339. */
  26340. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26341. /**
  26342. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  26343. * This is dynamic to allow compat with webgl 1 and 2.
  26344. * You will need to pass the name of the uniform as well as the value.
  26345. */
  26346. updateMatrix: (name: string, mat: Matrix) => void;
  26347. /**
  26348. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  26349. * This is dynamic to allow compat with webgl 1 and 2.
  26350. * You will need to pass the name of the uniform as well as the value.
  26351. */
  26352. updateVector3: (name: string, vector: Vector3) => void;
  26353. /**
  26354. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26355. * This is dynamic to allow compat with webgl 1 and 2.
  26356. * You will need to pass the name of the uniform as well as the value.
  26357. */
  26358. updateVector4: (name: string, vector: Vector4) => void;
  26359. /**
  26360. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26361. * This is dynamic to allow compat with webgl 1 and 2.
  26362. * You will need to pass the name of the uniform as well as the value.
  26363. */
  26364. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26365. /**
  26366. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26367. * This is dynamic to allow compat with webgl 1 and 2.
  26368. * You will need to pass the name of the uniform as well as the value.
  26369. */
  26370. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26371. /**
  26372. * Instantiates a new Uniform buffer objects.
  26373. *
  26374. * Handles blocks of uniform on the GPU.
  26375. *
  26376. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26377. *
  26378. * For more information, please refer to :
  26379. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26380. * @param engine Define the engine the buffer is associated with
  26381. * @param data Define the data contained in the buffer
  26382. * @param dynamic Define if the buffer is updatable
  26383. */
  26384. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26385. /**
  26386. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26387. * or just falling back on setUniformXXX calls.
  26388. */
  26389. readonly useUbo: boolean;
  26390. /**
  26391. * Indicates if the WebGL underlying uniform buffer is in sync
  26392. * with the javascript cache data.
  26393. */
  26394. readonly isSync: boolean;
  26395. /**
  26396. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26397. * Also, a dynamic UniformBuffer will disable cache verification and always
  26398. * update the underlying WebGL uniform buffer to the GPU.
  26399. * @returns if Dynamic, otherwise false
  26400. */
  26401. isDynamic(): boolean;
  26402. /**
  26403. * The data cache on JS side.
  26404. * @returns the underlying data as a float array
  26405. */
  26406. getData(): Float32Array;
  26407. /**
  26408. * The underlying WebGL Uniform buffer.
  26409. * @returns the webgl buffer
  26410. */
  26411. getBuffer(): Nullable<WebGLBuffer>;
  26412. /**
  26413. * std140 layout specifies how to align data within an UBO structure.
  26414. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26415. * for specs.
  26416. */
  26417. private _fillAlignment;
  26418. /**
  26419. * Adds an uniform in the buffer.
  26420. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26421. * for the layout to be correct !
  26422. * @param name Name of the uniform, as used in the uniform block in the shader.
  26423. * @param size Data size, or data directly.
  26424. */
  26425. addUniform(name: string, size: number | number[]): void;
  26426. /**
  26427. * Adds a Matrix 4x4 to the uniform buffer.
  26428. * @param name Name of the uniform, as used in the uniform block in the shader.
  26429. * @param mat A 4x4 matrix.
  26430. */
  26431. addMatrix(name: string, mat: Matrix): void;
  26432. /**
  26433. * Adds a vec2 to the uniform buffer.
  26434. * @param name Name of the uniform, as used in the uniform block in the shader.
  26435. * @param x Define the x component value of the vec2
  26436. * @param y Define the y component value of the vec2
  26437. */
  26438. addFloat2(name: string, x: number, y: number): void;
  26439. /**
  26440. * Adds a vec3 to the uniform buffer.
  26441. * @param name Name of the uniform, as used in the uniform block in the shader.
  26442. * @param x Define the x component value of the vec3
  26443. * @param y Define the y component value of the vec3
  26444. * @param z Define the z component value of the vec3
  26445. */
  26446. addFloat3(name: string, x: number, y: number, z: number): void;
  26447. /**
  26448. * Adds a vec3 to the uniform buffer.
  26449. * @param name Name of the uniform, as used in the uniform block in the shader.
  26450. * @param color Define the vec3 from a Color
  26451. */
  26452. addColor3(name: string, color: Color3): void;
  26453. /**
  26454. * Adds a vec4 to the uniform buffer.
  26455. * @param name Name of the uniform, as used in the uniform block in the shader.
  26456. * @param color Define the rgb components from a Color
  26457. * @param alpha Define the a component of the vec4
  26458. */
  26459. addColor4(name: string, color: Color3, alpha: number): void;
  26460. /**
  26461. * Adds a vec3 to the uniform buffer.
  26462. * @param name Name of the uniform, as used in the uniform block in the shader.
  26463. * @param vector Define the vec3 components from a Vector
  26464. */
  26465. addVector3(name: string, vector: Vector3): void;
  26466. /**
  26467. * Adds a Matrix 3x3 to the uniform buffer.
  26468. * @param name Name of the uniform, as used in the uniform block in the shader.
  26469. */
  26470. addMatrix3x3(name: string): void;
  26471. /**
  26472. * Adds a Matrix 2x2 to the uniform buffer.
  26473. * @param name Name of the uniform, as used in the uniform block in the shader.
  26474. */
  26475. addMatrix2x2(name: string): void;
  26476. /**
  26477. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26478. */
  26479. create(): void;
  26480. /** @hidden */
  26481. _rebuild(): void;
  26482. /**
  26483. * Updates the WebGL Uniform Buffer on the GPU.
  26484. * If the `dynamic` flag is set to true, no cache comparison is done.
  26485. * Otherwise, the buffer will be updated only if the cache differs.
  26486. */
  26487. update(): void;
  26488. /**
  26489. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26490. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26491. * @param data Define the flattened data
  26492. * @param size Define the size of the data.
  26493. */
  26494. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26495. private _updateMatrix3x3ForUniform;
  26496. private _updateMatrix3x3ForEffect;
  26497. private _updateMatrix2x2ForEffect;
  26498. private _updateMatrix2x2ForUniform;
  26499. private _updateFloatForEffect;
  26500. private _updateFloatForUniform;
  26501. private _updateFloat2ForEffect;
  26502. private _updateFloat2ForUniform;
  26503. private _updateFloat3ForEffect;
  26504. private _updateFloat3ForUniform;
  26505. private _updateFloat4ForEffect;
  26506. private _updateFloat4ForUniform;
  26507. private _updateMatrixForEffect;
  26508. private _updateMatrixForUniform;
  26509. private _updateVector3ForEffect;
  26510. private _updateVector3ForUniform;
  26511. private _updateVector4ForEffect;
  26512. private _updateVector4ForUniform;
  26513. private _updateColor3ForEffect;
  26514. private _updateColor3ForUniform;
  26515. private _updateColor4ForEffect;
  26516. private _updateColor4ForUniform;
  26517. /**
  26518. * Sets a sampler uniform on the effect.
  26519. * @param name Define the name of the sampler.
  26520. * @param texture Define the texture to set in the sampler
  26521. */
  26522. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26523. /**
  26524. * Directly updates the value of the uniform in the cache AND on the GPU.
  26525. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26526. * @param data Define the flattened data
  26527. */
  26528. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26529. /**
  26530. * Binds this uniform buffer to an effect.
  26531. * @param effect Define the effect to bind the buffer to
  26532. * @param name Name of the uniform block in the shader.
  26533. */
  26534. bindToEffect(effect: Effect, name: string): void;
  26535. /**
  26536. * Disposes the uniform buffer.
  26537. */
  26538. dispose(): void;
  26539. }
  26540. }
  26541. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  26542. import { Nullable } from "babylonjs/types";
  26543. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26544. /**
  26545. * This represents the required contract to create a new type of texture loader.
  26546. */
  26547. export interface IInternalTextureLoader {
  26548. /**
  26549. * Defines wether the loader supports cascade loading the different faces.
  26550. */
  26551. supportCascades: boolean;
  26552. /**
  26553. * This returns if the loader support the current file information.
  26554. * @param extension defines the file extension of the file being loaded
  26555. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26556. * @param fallback defines the fallback internal texture if any
  26557. * @param isBase64 defines whether the texture is encoded as a base64
  26558. * @param isBuffer defines whether the texture data are stored as a buffer
  26559. * @returns true if the loader can load the specified file
  26560. */
  26561. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  26562. /**
  26563. * Transform the url before loading if required.
  26564. * @param rootUrl the url of the texture
  26565. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26566. * @returns the transformed texture
  26567. */
  26568. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  26569. /**
  26570. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  26571. * @param rootUrl the url of the texture
  26572. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26573. * @returns the fallback texture
  26574. */
  26575. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  26576. /**
  26577. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  26578. * @param data contains the texture data
  26579. * @param texture defines the BabylonJS internal texture
  26580. * @param createPolynomials will be true if polynomials have been requested
  26581. * @param onLoad defines the callback to trigger once the texture is ready
  26582. * @param onError defines the callback to trigger in case of error
  26583. */
  26584. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  26585. /**
  26586. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  26587. * @param data contains the texture data
  26588. * @param texture defines the BabylonJS internal texture
  26589. * @param callback defines the method to call once ready to upload
  26590. */
  26591. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  26592. }
  26593. }
  26594. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  26595. import { Scene } from "babylonjs/scene";
  26596. import { Engine } from "babylonjs/Engines/engine";
  26597. import { Texture } from "babylonjs/Materials/Textures/texture";
  26598. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26599. /**
  26600. * Creation options of the multi render target texture.
  26601. */
  26602. export interface IMultiRenderTargetOptions {
  26603. /**
  26604. * Define if the texture needs to create mip maps after render.
  26605. */
  26606. generateMipMaps?: boolean;
  26607. /**
  26608. * Define the types of all the draw buffers we want to create
  26609. */
  26610. types?: number[];
  26611. /**
  26612. * Define the sampling modes of all the draw buffers we want to create
  26613. */
  26614. samplingModes?: number[];
  26615. /**
  26616. * Define if a depth buffer is required
  26617. */
  26618. generateDepthBuffer?: boolean;
  26619. /**
  26620. * Define if a stencil buffer is required
  26621. */
  26622. generateStencilBuffer?: boolean;
  26623. /**
  26624. * Define if a depth texture is required instead of a depth buffer
  26625. */
  26626. generateDepthTexture?: boolean;
  26627. /**
  26628. * Define the number of desired draw buffers
  26629. */
  26630. textureCount?: number;
  26631. /**
  26632. * Define if aspect ratio should be adapted to the texture or stay the scene one
  26633. */
  26634. doNotChangeAspectRatio?: boolean;
  26635. /**
  26636. * Define the default type of the buffers we are creating
  26637. */
  26638. defaultType?: number;
  26639. }
  26640. /**
  26641. * A multi render target, like a render target provides the ability to render to a texture.
  26642. * Unlike the render target, it can render to several draw buffers in one draw.
  26643. * This is specially interesting in deferred rendering or for any effects requiring more than
  26644. * just one color from a single pass.
  26645. */
  26646. export class MultiRenderTarget extends RenderTargetTexture {
  26647. private _internalTextures;
  26648. private _textures;
  26649. private _multiRenderTargetOptions;
  26650. /**
  26651. * Get if draw buffers are currently supported by the used hardware and browser.
  26652. */
  26653. readonly isSupported: boolean;
  26654. /**
  26655. * Get the list of textures generated by the multi render target.
  26656. */
  26657. readonly textures: Texture[];
  26658. /**
  26659. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  26660. */
  26661. readonly depthTexture: Texture;
  26662. /**
  26663. * Set the wrapping mode on U of all the textures we are rendering to.
  26664. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26665. */
  26666. wrapU: number;
  26667. /**
  26668. * Set the wrapping mode on V of all the textures we are rendering to.
  26669. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26670. */
  26671. wrapV: number;
  26672. /**
  26673. * Instantiate a new multi render target texture.
  26674. * A multi render target, like a render target provides the ability to render to a texture.
  26675. * Unlike the render target, it can render to several draw buffers in one draw.
  26676. * This is specially interesting in deferred rendering or for any effects requiring more than
  26677. * just one color from a single pass.
  26678. * @param name Define the name of the texture
  26679. * @param size Define the size of the buffers to render to
  26680. * @param count Define the number of target we are rendering into
  26681. * @param scene Define the scene the texture belongs to
  26682. * @param options Define the options used to create the multi render target
  26683. */
  26684. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26685. /** @hidden */
  26686. _rebuild(): void;
  26687. private _createInternalTextures;
  26688. private _createTextures;
  26689. /**
  26690. * Define the number of samples used if MSAA is enabled.
  26691. */
  26692. samples: number;
  26693. /**
  26694. * Resize all the textures in the multi render target.
  26695. * Be carrefull as it will recreate all the data in the new texture.
  26696. * @param size Define the new size
  26697. */
  26698. resize(size: any): void;
  26699. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26700. /**
  26701. * Dispose the render targets and their associated resources
  26702. */
  26703. dispose(): void;
  26704. /**
  26705. * Release all the underlying texture used as draw buffers.
  26706. */
  26707. releaseInternalTextures(): void;
  26708. }
  26709. }
  26710. declare module "babylonjs/Audio/analyser" {
  26711. import { Scene } from "babylonjs/scene";
  26712. /**
  26713. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26714. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26715. */
  26716. export class Analyser {
  26717. /**
  26718. * Gets or sets the smoothing
  26719. * @ignorenaming
  26720. */
  26721. SMOOTHING: number;
  26722. /**
  26723. * Gets or sets the FFT table size
  26724. * @ignorenaming
  26725. */
  26726. FFT_SIZE: number;
  26727. /**
  26728. * Gets or sets the bar graph amplitude
  26729. * @ignorenaming
  26730. */
  26731. BARGRAPHAMPLITUDE: number;
  26732. /**
  26733. * Gets or sets the position of the debug canvas
  26734. * @ignorenaming
  26735. */
  26736. DEBUGCANVASPOS: {
  26737. x: number;
  26738. y: number;
  26739. };
  26740. /**
  26741. * Gets or sets the debug canvas size
  26742. * @ignorenaming
  26743. */
  26744. DEBUGCANVASSIZE: {
  26745. width: number;
  26746. height: number;
  26747. };
  26748. private _byteFreqs;
  26749. private _byteTime;
  26750. private _floatFreqs;
  26751. private _webAudioAnalyser;
  26752. private _debugCanvas;
  26753. private _debugCanvasContext;
  26754. private _scene;
  26755. private _registerFunc;
  26756. private _audioEngine;
  26757. /**
  26758. * Creates a new analyser
  26759. * @param scene defines hosting scene
  26760. */
  26761. constructor(scene: Scene);
  26762. /**
  26763. * Get the number of data values you will have to play with for the visualization
  26764. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26765. * @returns a number
  26766. */
  26767. getFrequencyBinCount(): number;
  26768. /**
  26769. * Gets the current frequency data as a byte array
  26770. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26771. * @returns a Uint8Array
  26772. */
  26773. getByteFrequencyData(): Uint8Array;
  26774. /**
  26775. * Gets the current waveform as a byte array
  26776. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26777. * @returns a Uint8Array
  26778. */
  26779. getByteTimeDomainData(): Uint8Array;
  26780. /**
  26781. * Gets the current frequency data as a float array
  26782. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26783. * @returns a Float32Array
  26784. */
  26785. getFloatFrequencyData(): Float32Array;
  26786. /**
  26787. * Renders the debug canvas
  26788. */
  26789. drawDebugCanvas(): void;
  26790. /**
  26791. * Stops rendering the debug canvas and removes it
  26792. */
  26793. stopDebugCanvas(): void;
  26794. /**
  26795. * Connects two audio nodes
  26796. * @param inputAudioNode defines first node to connect
  26797. * @param outputAudioNode defines second node to connect
  26798. */
  26799. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26800. /**
  26801. * Releases all associated resources
  26802. */
  26803. dispose(): void;
  26804. }
  26805. }
  26806. declare module "babylonjs/Audio/audioEngine" {
  26807. import { IDisposable } from "babylonjs/scene";
  26808. import { Analyser } from "babylonjs/Audio/analyser";
  26809. import { Nullable } from "babylonjs/types";
  26810. import { Observable } from "babylonjs/Misc/observable";
  26811. /**
  26812. * This represents an audio engine and it is responsible
  26813. * to play, synchronize and analyse sounds throughout the application.
  26814. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26815. */
  26816. export interface IAudioEngine extends IDisposable {
  26817. /**
  26818. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26819. */
  26820. readonly canUseWebAudio: boolean;
  26821. /**
  26822. * Gets the current AudioContext if available.
  26823. */
  26824. readonly audioContext: Nullable<AudioContext>;
  26825. /**
  26826. * The master gain node defines the global audio volume of your audio engine.
  26827. */
  26828. readonly masterGain: GainNode;
  26829. /**
  26830. * Gets whether or not mp3 are supported by your browser.
  26831. */
  26832. readonly isMP3supported: boolean;
  26833. /**
  26834. * Gets whether or not ogg are supported by your browser.
  26835. */
  26836. readonly isOGGsupported: boolean;
  26837. /**
  26838. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26839. * @ignoreNaming
  26840. */
  26841. WarnedWebAudioUnsupported: boolean;
  26842. /**
  26843. * Defines if the audio engine relies on a custom unlocked button.
  26844. * In this case, the embedded button will not be displayed.
  26845. */
  26846. useCustomUnlockedButton: boolean;
  26847. /**
  26848. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26849. */
  26850. readonly unlocked: boolean;
  26851. /**
  26852. * Event raised when audio has been unlocked on the browser.
  26853. */
  26854. onAudioUnlockedObservable: Observable<AudioEngine>;
  26855. /**
  26856. * Event raised when audio has been locked on the browser.
  26857. */
  26858. onAudioLockedObservable: Observable<AudioEngine>;
  26859. /**
  26860. * Flags the audio engine in Locked state.
  26861. * This happens due to new browser policies preventing audio to autoplay.
  26862. */
  26863. lock(): void;
  26864. /**
  26865. * Unlocks the audio engine once a user action has been done on the dom.
  26866. * This is helpful to resume play once browser policies have been satisfied.
  26867. */
  26868. unlock(): void;
  26869. }
  26870. /**
  26871. * This represents the default audio engine used in babylon.
  26872. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26873. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26874. */
  26875. export class AudioEngine implements IAudioEngine {
  26876. private _audioContext;
  26877. private _audioContextInitialized;
  26878. private _muteButton;
  26879. private _hostElement;
  26880. /**
  26881. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26882. */
  26883. canUseWebAudio: boolean;
  26884. /**
  26885. * The master gain node defines the global audio volume of your audio engine.
  26886. */
  26887. masterGain: GainNode;
  26888. /**
  26889. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26890. * @ignoreNaming
  26891. */
  26892. WarnedWebAudioUnsupported: boolean;
  26893. /**
  26894. * Gets whether or not mp3 are supported by your browser.
  26895. */
  26896. isMP3supported: boolean;
  26897. /**
  26898. * Gets whether or not ogg are supported by your browser.
  26899. */
  26900. isOGGsupported: boolean;
  26901. /**
  26902. * Gets whether audio has been unlocked on the device.
  26903. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26904. * a user interaction has happened.
  26905. */
  26906. unlocked: boolean;
  26907. /**
  26908. * Defines if the audio engine relies on a custom unlocked button.
  26909. * In this case, the embedded button will not be displayed.
  26910. */
  26911. useCustomUnlockedButton: boolean;
  26912. /**
  26913. * Event raised when audio has been unlocked on the browser.
  26914. */
  26915. onAudioUnlockedObservable: Observable<AudioEngine>;
  26916. /**
  26917. * Event raised when audio has been locked on the browser.
  26918. */
  26919. onAudioLockedObservable: Observable<AudioEngine>;
  26920. /**
  26921. * Gets the current AudioContext if available.
  26922. */
  26923. readonly audioContext: Nullable<AudioContext>;
  26924. private _connectedAnalyser;
  26925. /**
  26926. * Instantiates a new audio engine.
  26927. *
  26928. * There should be only one per page as some browsers restrict the number
  26929. * of audio contexts you can create.
  26930. * @param hostElement defines the host element where to display the mute icon if necessary
  26931. */
  26932. constructor(hostElement?: Nullable<HTMLElement>);
  26933. /**
  26934. * Flags the audio engine in Locked state.
  26935. * This happens due to new browser policies preventing audio to autoplay.
  26936. */
  26937. lock(): void;
  26938. /**
  26939. * Unlocks the audio engine once a user action has been done on the dom.
  26940. * This is helpful to resume play once browser policies have been satisfied.
  26941. */
  26942. unlock(): void;
  26943. private _resumeAudioContext;
  26944. private _initializeAudioContext;
  26945. private _tryToRun;
  26946. private _triggerRunningState;
  26947. private _triggerSuspendedState;
  26948. private _displayMuteButton;
  26949. private _moveButtonToTopLeft;
  26950. private _onResize;
  26951. private _hideMuteButton;
  26952. /**
  26953. * Destroy and release the resources associated with the audio ccontext.
  26954. */
  26955. dispose(): void;
  26956. /**
  26957. * Gets the global volume sets on the master gain.
  26958. * @returns the global volume if set or -1 otherwise
  26959. */
  26960. getGlobalVolume(): number;
  26961. /**
  26962. * Sets the global volume of your experience (sets on the master gain).
  26963. * @param newVolume Defines the new global volume of the application
  26964. */
  26965. setGlobalVolume(newVolume: number): void;
  26966. /**
  26967. * Connect the audio engine to an audio analyser allowing some amazing
  26968. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26969. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26970. * @param analyser The analyser to connect to the engine
  26971. */
  26972. connectToAnalyser(analyser: Analyser): void;
  26973. }
  26974. }
  26975. declare module "babylonjs/Loading/loadingScreen" {
  26976. /**
  26977. * Interface used to present a loading screen while loading a scene
  26978. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26979. */
  26980. export interface ILoadingScreen {
  26981. /**
  26982. * Function called to display the loading screen
  26983. */
  26984. displayLoadingUI: () => void;
  26985. /**
  26986. * Function called to hide the loading screen
  26987. */
  26988. hideLoadingUI: () => void;
  26989. /**
  26990. * Gets or sets the color to use for the background
  26991. */
  26992. loadingUIBackgroundColor: string;
  26993. /**
  26994. * Gets or sets the text to display while loading
  26995. */
  26996. loadingUIText: string;
  26997. }
  26998. /**
  26999. * Class used for the default loading screen
  27000. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27001. */
  27002. export class DefaultLoadingScreen implements ILoadingScreen {
  27003. private _renderingCanvas;
  27004. private _loadingText;
  27005. private _loadingDivBackgroundColor;
  27006. private _loadingDiv;
  27007. private _loadingTextDiv;
  27008. /**
  27009. * Creates a new default loading screen
  27010. * @param _renderingCanvas defines the canvas used to render the scene
  27011. * @param _loadingText defines the default text to display
  27012. * @param _loadingDivBackgroundColor defines the default background color
  27013. */
  27014. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27015. /**
  27016. * Function called to display the loading screen
  27017. */
  27018. displayLoadingUI(): void;
  27019. /**
  27020. * Function called to hide the loading screen
  27021. */
  27022. hideLoadingUI(): void;
  27023. /**
  27024. * Gets or sets the text to display while loading
  27025. */
  27026. loadingUIText: string;
  27027. /**
  27028. * Gets or sets the color to use for the background
  27029. */
  27030. loadingUIBackgroundColor: string;
  27031. private _resizeLoadingUI;
  27032. }
  27033. }
  27034. declare module "babylonjs/Materials/Textures/videoTexture" {
  27035. import { Observable } from "babylonjs/Misc/observable";
  27036. import { Nullable } from "babylonjs/types";
  27037. import { Scene } from "babylonjs/scene";
  27038. import { Texture } from "babylonjs/Materials/Textures/texture";
  27039. /**
  27040. * Settings for finer control over video usage
  27041. */
  27042. export interface VideoTextureSettings {
  27043. /**
  27044. * Applies `autoplay` to video, if specified
  27045. */
  27046. autoPlay?: boolean;
  27047. /**
  27048. * Applies `loop` to video, if specified
  27049. */
  27050. loop?: boolean;
  27051. /**
  27052. * Automatically updates internal texture from video at every frame in the render loop
  27053. */
  27054. autoUpdateTexture: boolean;
  27055. /**
  27056. * Image src displayed during the video loading or until the user interacts with the video.
  27057. */
  27058. poster?: string;
  27059. }
  27060. /**
  27061. * If you want to display a video in your scene, this is the special texture for that.
  27062. * This special texture works similar to other textures, with the exception of a few parameters.
  27063. * @see https://doc.babylonjs.com/how_to/video_texture
  27064. */
  27065. export class VideoTexture extends Texture {
  27066. /**
  27067. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27068. */
  27069. readonly autoUpdateTexture: boolean;
  27070. /**
  27071. * The video instance used by the texture internally
  27072. */
  27073. readonly video: HTMLVideoElement;
  27074. private _onUserActionRequestedObservable;
  27075. /**
  27076. * Event triggerd when a dom action is required by the user to play the video.
  27077. * This happens due to recent changes in browser policies preventing video to auto start.
  27078. */
  27079. readonly onUserActionRequestedObservable: Observable<Texture>;
  27080. private _generateMipMaps;
  27081. private _engine;
  27082. private _stillImageCaptured;
  27083. private _displayingPosterTexture;
  27084. private _settings;
  27085. private _createInternalTextureOnEvent;
  27086. /**
  27087. * Creates a video texture.
  27088. * If you want to display a video in your scene, this is the special texture for that.
  27089. * This special texture works similar to other textures, with the exception of a few parameters.
  27090. * @see https://doc.babylonjs.com/how_to/video_texture
  27091. * @param name optional name, will detect from video source, if not defined
  27092. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27093. * @param scene is obviously the current scene.
  27094. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27095. * @param invertY is false by default but can be used to invert video on Y axis
  27096. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27097. * @param settings allows finer control over video usage
  27098. */
  27099. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27100. private _getName;
  27101. private _getVideo;
  27102. private _createInternalTexture;
  27103. private reset;
  27104. /**
  27105. * @hidden Internal method to initiate `update`.
  27106. */
  27107. _rebuild(): void;
  27108. /**
  27109. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27110. */
  27111. update(): void;
  27112. /**
  27113. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27114. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27115. */
  27116. updateTexture(isVisible: boolean): void;
  27117. protected _updateInternalTexture: () => void;
  27118. /**
  27119. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27120. * @param url New url.
  27121. */
  27122. updateURL(url: string): void;
  27123. /**
  27124. * Dispose the texture and release its associated resources.
  27125. */
  27126. dispose(): void;
  27127. /**
  27128. * Creates a video texture straight from a stream.
  27129. * @param scene Define the scene the texture should be created in
  27130. * @param stream Define the stream the texture should be created from
  27131. * @returns The created video texture as a promise
  27132. */
  27133. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27134. /**
  27135. * Creates a video texture straight from your WebCam video feed.
  27136. * @param scene Define the scene the texture should be created in
  27137. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27138. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27139. * @returns The created video texture as a promise
  27140. */
  27141. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27142. minWidth: number;
  27143. maxWidth: number;
  27144. minHeight: number;
  27145. maxHeight: number;
  27146. deviceId: string;
  27147. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27148. /**
  27149. * Creates a video texture straight from your WebCam video feed.
  27150. * @param scene Define the scene the texture should be created in
  27151. * @param onReady Define a callback to triggered once the texture will be ready
  27152. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27153. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27154. */
  27155. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27156. minWidth: number;
  27157. maxWidth: number;
  27158. minHeight: number;
  27159. maxHeight: number;
  27160. deviceId: string;
  27161. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27162. }
  27163. }
  27164. declare module "babylonjs/Engines/engine" {
  27165. import { Observable } from "babylonjs/Misc/observable";
  27166. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  27167. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  27168. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  27169. import { Camera } from "babylonjs/Cameras/camera";
  27170. import { Scene } from "babylonjs/scene";
  27171. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  27172. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  27173. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  27174. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  27175. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  27176. import { Material } from "babylonjs/Materials/material";
  27177. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  27178. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27179. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27180. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  27181. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  27182. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  27183. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  27184. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  27185. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  27186. import { WebRequest } from "babylonjs/Misc/webRequest";
  27187. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27188. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27189. /**
  27190. * Interface for attribute information associated with buffer instanciation
  27191. */
  27192. export class InstancingAttributeInfo {
  27193. /**
  27194. * Index/offset of the attribute in the vertex shader
  27195. */
  27196. index: number;
  27197. /**
  27198. * size of the attribute, 1, 2, 3 or 4
  27199. */
  27200. attributeSize: number;
  27201. /**
  27202. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27203. * default is FLOAT
  27204. */
  27205. attribyteType: number;
  27206. /**
  27207. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27208. */
  27209. normalized: boolean;
  27210. /**
  27211. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27212. */
  27213. offset: number;
  27214. /**
  27215. * Name of the GLSL attribute, for debugging purpose only
  27216. */
  27217. attributeName: string;
  27218. }
  27219. /**
  27220. * Define options used to create a depth texture
  27221. */
  27222. export class DepthTextureCreationOptions {
  27223. /** Specifies whether or not a stencil should be allocated in the texture */
  27224. generateStencil?: boolean;
  27225. /** Specifies whether or not bilinear filtering is enable on the texture */
  27226. bilinearFiltering?: boolean;
  27227. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27228. comparisonFunction?: number;
  27229. /** Specifies if the created texture is a cube texture */
  27230. isCube?: boolean;
  27231. }
  27232. /**
  27233. * Class used to describe the capabilities of the engine relatively to the current browser
  27234. */
  27235. export class EngineCapabilities {
  27236. /** Maximum textures units per fragment shader */
  27237. maxTexturesImageUnits: number;
  27238. /** Maximum texture units per vertex shader */
  27239. maxVertexTextureImageUnits: number;
  27240. /** Maximum textures units in the entire pipeline */
  27241. maxCombinedTexturesImageUnits: number;
  27242. /** Maximum texture size */
  27243. maxTextureSize: number;
  27244. /** Maximum cube texture size */
  27245. maxCubemapTextureSize: number;
  27246. /** Maximum render texture size */
  27247. maxRenderTextureSize: number;
  27248. /** Maximum number of vertex attributes */
  27249. maxVertexAttribs: number;
  27250. /** Maximum number of varyings */
  27251. maxVaryingVectors: number;
  27252. /** Maximum number of uniforms per vertex shader */
  27253. maxVertexUniformVectors: number;
  27254. /** Maximum number of uniforms per fragment shader */
  27255. maxFragmentUniformVectors: number;
  27256. /** Defines if standard derivates (dx/dy) are supported */
  27257. standardDerivatives: boolean;
  27258. /** Defines if s3tc texture compression is supported */
  27259. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27260. /** Defines if pvrtc texture compression is supported */
  27261. pvrtc: any;
  27262. /** Defines if etc1 texture compression is supported */
  27263. etc1: any;
  27264. /** Defines if etc2 texture compression is supported */
  27265. etc2: any;
  27266. /** Defines if astc texture compression is supported */
  27267. astc: any;
  27268. /** Defines if float textures are supported */
  27269. textureFloat: boolean;
  27270. /** Defines if vertex array objects are supported */
  27271. vertexArrayObject: boolean;
  27272. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27273. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27274. /** Gets the maximum level of anisotropy supported */
  27275. maxAnisotropy: number;
  27276. /** Defines if instancing is supported */
  27277. instancedArrays: boolean;
  27278. /** Defines if 32 bits indices are supported */
  27279. uintIndices: boolean;
  27280. /** Defines if high precision shaders are supported */
  27281. highPrecisionShaderSupported: boolean;
  27282. /** Defines if depth reading in the fragment shader is supported */
  27283. fragmentDepthSupported: boolean;
  27284. /** Defines if float texture linear filtering is supported*/
  27285. textureFloatLinearFiltering: boolean;
  27286. /** Defines if rendering to float textures is supported */
  27287. textureFloatRender: boolean;
  27288. /** Defines if half float textures are supported*/
  27289. textureHalfFloat: boolean;
  27290. /** Defines if half float texture linear filtering is supported*/
  27291. textureHalfFloatLinearFiltering: boolean;
  27292. /** Defines if rendering to half float textures is supported */
  27293. textureHalfFloatRender: boolean;
  27294. /** Defines if textureLOD shader command is supported */
  27295. textureLOD: boolean;
  27296. /** Defines if draw buffers extension is supported */
  27297. drawBuffersExtension: boolean;
  27298. /** Defines if depth textures are supported */
  27299. depthTextureExtension: boolean;
  27300. /** Defines if float color buffer are supported */
  27301. colorBufferFloat: boolean;
  27302. /** Gets disjoint timer query extension (null if not supported) */
  27303. timerQuery: EXT_disjoint_timer_query;
  27304. /** Defines if timestamp can be used with timer query */
  27305. canUseTimestampForTimerQuery: boolean;
  27306. /** Function used to let the system compiles shaders in background */
  27307. parallelShaderCompile: {
  27308. COMPLETION_STATUS_KHR: number;
  27309. };
  27310. }
  27311. /** Interface defining initialization parameters for Engine class */
  27312. export interface EngineOptions extends WebGLContextAttributes {
  27313. /**
  27314. * Defines if the engine should no exceed a specified device ratio
  27315. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27316. */
  27317. limitDeviceRatio?: number;
  27318. /**
  27319. * Defines if webvr should be enabled automatically
  27320. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27321. */
  27322. autoEnableWebVR?: boolean;
  27323. /**
  27324. * Defines if webgl2 should be turned off even if supported
  27325. * @see http://doc.babylonjs.com/features/webgl2
  27326. */
  27327. disableWebGL2Support?: boolean;
  27328. /**
  27329. * Defines if webaudio should be initialized as well
  27330. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27331. */
  27332. audioEngine?: boolean;
  27333. /**
  27334. * Defines if animations should run using a deterministic lock step
  27335. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27336. */
  27337. deterministicLockstep?: boolean;
  27338. /** Defines the maximum steps to use with deterministic lock step mode */
  27339. lockstepMaxSteps?: number;
  27340. /**
  27341. * Defines that engine should ignore context lost events
  27342. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27343. */
  27344. doNotHandleContextLost?: boolean;
  27345. /**
  27346. * Defines that engine should ignore modifying touch action attribute and style
  27347. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27348. */
  27349. doNotHandleTouchAction?: boolean;
  27350. /**
  27351. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27352. */
  27353. useHighPrecisionFloats?: boolean;
  27354. }
  27355. /**
  27356. * Defines the interface used by display changed events
  27357. */
  27358. export interface IDisplayChangedEventArgs {
  27359. /** Gets the vrDisplay object (if any) */
  27360. vrDisplay: Nullable<any>;
  27361. /** Gets a boolean indicating if webVR is supported */
  27362. vrSupported: boolean;
  27363. }
  27364. /**
  27365. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27366. */
  27367. export class Engine {
  27368. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27369. static ExceptionList: ({
  27370. key: string;
  27371. capture: string;
  27372. captureConstraint: number;
  27373. targets: string[];
  27374. } | {
  27375. key: string;
  27376. capture: null;
  27377. captureConstraint: null;
  27378. targets: string[];
  27379. })[];
  27380. /** Gets the list of created engines */
  27381. static readonly Instances: Engine[];
  27382. /**
  27383. * Gets the latest created engine
  27384. */
  27385. static readonly LastCreatedEngine: Nullable<Engine>;
  27386. /**
  27387. * Gets the latest created scene
  27388. */
  27389. static readonly LastCreatedScene: Nullable<Scene>;
  27390. /**
  27391. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27392. * @param flag defines which part of the materials must be marked as dirty
  27393. * @param predicate defines a predicate used to filter which materials should be affected
  27394. */
  27395. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27396. /**
  27397. * Hidden
  27398. */
  27399. static _TextureLoaders: IInternalTextureLoader[];
  27400. /** Defines that alpha blending is disabled */
  27401. static readonly ALPHA_DISABLE: number;
  27402. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27403. static readonly ALPHA_ADD: number;
  27404. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27405. static readonly ALPHA_COMBINE: number;
  27406. /** Defines that alpha blending to DEST - SRC * DEST */
  27407. static readonly ALPHA_SUBTRACT: number;
  27408. /** Defines that alpha blending to SRC * DEST */
  27409. static readonly ALPHA_MULTIPLY: number;
  27410. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27411. static readonly ALPHA_MAXIMIZED: number;
  27412. /** Defines that alpha blending to SRC + DEST */
  27413. static readonly ALPHA_ONEONE: number;
  27414. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27415. static readonly ALPHA_PREMULTIPLIED: number;
  27416. /**
  27417. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27418. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27419. */
  27420. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27421. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27422. static readonly ALPHA_INTERPOLATE: number;
  27423. /**
  27424. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27425. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27426. */
  27427. static readonly ALPHA_SCREENMODE: number;
  27428. /** Defines that the ressource is not delayed*/
  27429. static readonly DELAYLOADSTATE_NONE: number;
  27430. /** Defines that the ressource was successfully delay loaded */
  27431. static readonly DELAYLOADSTATE_LOADED: number;
  27432. /** Defines that the ressource is currently delay loading */
  27433. static readonly DELAYLOADSTATE_LOADING: number;
  27434. /** Defines that the ressource is delayed and has not started loading */
  27435. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27436. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27437. static readonly NEVER: number;
  27438. /** 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 */
  27439. static readonly ALWAYS: number;
  27440. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27441. static readonly LESS: number;
  27442. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27443. static readonly EQUAL: number;
  27444. /** 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 */
  27445. static readonly LEQUAL: number;
  27446. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27447. static readonly GREATER: number;
  27448. /** 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 */
  27449. static readonly GEQUAL: number;
  27450. /** 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 */
  27451. static readonly NOTEQUAL: number;
  27452. /** Passed to stencilOperation to specify that stencil value must be kept */
  27453. static readonly KEEP: number;
  27454. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27455. static readonly REPLACE: number;
  27456. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27457. static readonly INCR: number;
  27458. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27459. static readonly DECR: number;
  27460. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27461. static readonly INVERT: number;
  27462. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27463. static readonly INCR_WRAP: number;
  27464. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27465. static readonly DECR_WRAP: number;
  27466. /** Texture is not repeating outside of 0..1 UVs */
  27467. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27468. /** Texture is repeating outside of 0..1 UVs */
  27469. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27470. /** Texture is repeating and mirrored */
  27471. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27472. /** ALPHA */
  27473. static readonly TEXTUREFORMAT_ALPHA: number;
  27474. /** LUMINANCE */
  27475. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27476. /** LUMINANCE_ALPHA */
  27477. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27478. /** RGB */
  27479. static readonly TEXTUREFORMAT_RGB: number;
  27480. /** RGBA */
  27481. static readonly TEXTUREFORMAT_RGBA: number;
  27482. /** RED */
  27483. static readonly TEXTUREFORMAT_RED: number;
  27484. /** RED (2nd reference) */
  27485. static readonly TEXTUREFORMAT_R: number;
  27486. /** RG */
  27487. static readonly TEXTUREFORMAT_RG: number;
  27488. /** RED_INTEGER */
  27489. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27490. /** RED_INTEGER (2nd reference) */
  27491. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27492. /** RG_INTEGER */
  27493. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27494. /** RGB_INTEGER */
  27495. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27496. /** RGBA_INTEGER */
  27497. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27498. /** UNSIGNED_BYTE */
  27499. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27500. /** UNSIGNED_BYTE (2nd reference) */
  27501. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27502. /** FLOAT */
  27503. static readonly TEXTURETYPE_FLOAT: number;
  27504. /** HALF_FLOAT */
  27505. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27506. /** BYTE */
  27507. static readonly TEXTURETYPE_BYTE: number;
  27508. /** SHORT */
  27509. static readonly TEXTURETYPE_SHORT: number;
  27510. /** UNSIGNED_SHORT */
  27511. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27512. /** INT */
  27513. static readonly TEXTURETYPE_INT: number;
  27514. /** UNSIGNED_INT */
  27515. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27516. /** UNSIGNED_SHORT_4_4_4_4 */
  27517. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27518. /** UNSIGNED_SHORT_5_5_5_1 */
  27519. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27520. /** UNSIGNED_SHORT_5_6_5 */
  27521. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27522. /** UNSIGNED_INT_2_10_10_10_REV */
  27523. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27524. /** UNSIGNED_INT_24_8 */
  27525. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27526. /** UNSIGNED_INT_10F_11F_11F_REV */
  27527. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27528. /** UNSIGNED_INT_5_9_9_9_REV */
  27529. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27530. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27531. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27532. /** nearest is mag = nearest and min = nearest and mip = linear */
  27533. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27534. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27535. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27536. /** Trilinear is mag = linear and min = linear and mip = linear */
  27537. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27538. /** nearest is mag = nearest and min = nearest and mip = linear */
  27539. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27540. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27541. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27542. /** Trilinear is mag = linear and min = linear and mip = linear */
  27543. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27544. /** mag = nearest and min = nearest and mip = nearest */
  27545. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27546. /** mag = nearest and min = linear and mip = nearest */
  27547. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27548. /** mag = nearest and min = linear and mip = linear */
  27549. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27550. /** mag = nearest and min = linear and mip = none */
  27551. static readonly TEXTURE_NEAREST_LINEAR: number;
  27552. /** mag = nearest and min = nearest and mip = none */
  27553. static readonly TEXTURE_NEAREST_NEAREST: number;
  27554. /** mag = linear and min = nearest and mip = nearest */
  27555. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27556. /** mag = linear and min = nearest and mip = linear */
  27557. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27558. /** mag = linear and min = linear and mip = none */
  27559. static readonly TEXTURE_LINEAR_LINEAR: number;
  27560. /** mag = linear and min = nearest and mip = none */
  27561. static readonly TEXTURE_LINEAR_NEAREST: number;
  27562. /** Explicit coordinates mode */
  27563. static readonly TEXTURE_EXPLICIT_MODE: number;
  27564. /** Spherical coordinates mode */
  27565. static readonly TEXTURE_SPHERICAL_MODE: number;
  27566. /** Planar coordinates mode */
  27567. static readonly TEXTURE_PLANAR_MODE: number;
  27568. /** Cubic coordinates mode */
  27569. static readonly TEXTURE_CUBIC_MODE: number;
  27570. /** Projection coordinates mode */
  27571. static readonly TEXTURE_PROJECTION_MODE: number;
  27572. /** Skybox coordinates mode */
  27573. static readonly TEXTURE_SKYBOX_MODE: number;
  27574. /** Inverse Cubic coordinates mode */
  27575. static readonly TEXTURE_INVCUBIC_MODE: number;
  27576. /** Equirectangular coordinates mode */
  27577. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27578. /** Equirectangular Fixed coordinates mode */
  27579. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27580. /** Equirectangular Fixed Mirrored coordinates mode */
  27581. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27582. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27583. static readonly SCALEMODE_FLOOR: number;
  27584. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27585. static readonly SCALEMODE_NEAREST: number;
  27586. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27587. static readonly SCALEMODE_CEILING: number;
  27588. /**
  27589. * Returns the current npm package of the sdk
  27590. */
  27591. static readonly NpmPackage: string;
  27592. /**
  27593. * Returns the current version of the framework
  27594. */
  27595. static readonly Version: string;
  27596. /**
  27597. * Returns a string describing the current engine
  27598. */
  27599. readonly description: string;
  27600. /**
  27601. * Gets or sets the epsilon value used by collision engine
  27602. */
  27603. static CollisionsEpsilon: number;
  27604. /**
  27605. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27606. */
  27607. static ShadersRepository: string;
  27608. /**
  27609. * Method called to create the default loading screen.
  27610. * This can be overriden in your own app.
  27611. * @param canvas The rendering canvas element
  27612. * @returns The loading screen
  27613. */
  27614. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27615. /**
  27616. * Method called to create the default rescale post process on each engine.
  27617. */
  27618. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27619. /**
  27620. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27621. */
  27622. forcePOTTextures: boolean;
  27623. /**
  27624. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27625. */
  27626. isFullscreen: boolean;
  27627. /**
  27628. * Gets a boolean indicating if the pointer is currently locked
  27629. */
  27630. isPointerLock: boolean;
  27631. /**
  27632. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27633. */
  27634. cullBackFaces: boolean;
  27635. /**
  27636. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27637. */
  27638. renderEvenInBackground: boolean;
  27639. /**
  27640. * Gets or sets a boolean indicating that cache can be kept between frames
  27641. */
  27642. preventCacheWipeBetweenFrames: boolean;
  27643. /**
  27644. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27645. **/
  27646. enableOfflineSupport: boolean;
  27647. /**
  27648. * 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)
  27649. **/
  27650. disableManifestCheck: boolean;
  27651. /**
  27652. * Gets the list of created scenes
  27653. */
  27654. scenes: Scene[];
  27655. /**
  27656. * Event raised when a new scene is created
  27657. */
  27658. onNewSceneAddedObservable: Observable<Scene>;
  27659. /**
  27660. * Gets the list of created postprocesses
  27661. */
  27662. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  27663. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27664. validateShaderPrograms: boolean;
  27665. /**
  27666. * Observable event triggered each time the rendering canvas is resized
  27667. */
  27668. onResizeObservable: Observable<Engine>;
  27669. /**
  27670. * Observable event triggered each time the canvas loses focus
  27671. */
  27672. onCanvasBlurObservable: Observable<Engine>;
  27673. /**
  27674. * Observable event triggered each time the canvas gains focus
  27675. */
  27676. onCanvasFocusObservable: Observable<Engine>;
  27677. /**
  27678. * Observable event triggered each time the canvas receives pointerout event
  27679. */
  27680. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27681. /**
  27682. * Observable event triggered before each texture is initialized
  27683. */
  27684. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  27685. private _vrDisplay;
  27686. private _vrSupported;
  27687. private _oldSize;
  27688. private _oldHardwareScaleFactor;
  27689. private _vrExclusivePointerMode;
  27690. private _webVRInitPromise;
  27691. /**
  27692. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27693. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27694. */
  27695. readonly isInVRExclusivePointerMode: boolean;
  27696. /**
  27697. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27698. */
  27699. disableUniformBuffers: boolean;
  27700. /** @hidden */
  27701. _uniformBuffers: UniformBuffer[];
  27702. /**
  27703. * Gets a boolean indicating that the engine supports uniform buffers
  27704. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27705. */
  27706. readonly supportsUniformBuffers: boolean;
  27707. /**
  27708. * Observable raised when the engine begins a new frame
  27709. */
  27710. onBeginFrameObservable: Observable<Engine>;
  27711. /**
  27712. * If set, will be used to request the next animation frame for the render loop
  27713. */
  27714. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27715. /**
  27716. * Observable raised when the engine ends the current frame
  27717. */
  27718. onEndFrameObservable: Observable<Engine>;
  27719. /**
  27720. * Observable raised when the engine is about to compile a shader
  27721. */
  27722. onBeforeShaderCompilationObservable: Observable<Engine>;
  27723. /**
  27724. * Observable raised when the engine has jsut compiled a shader
  27725. */
  27726. onAfterShaderCompilationObservable: Observable<Engine>;
  27727. /** @hidden */
  27728. _gl: WebGLRenderingContext;
  27729. private _renderingCanvas;
  27730. private _windowIsBackground;
  27731. private _webGLVersion;
  27732. protected _highPrecisionShadersAllowed: boolean;
  27733. /** @hidden */
  27734. readonly _shouldUseHighPrecisionShader: boolean;
  27735. /**
  27736. * Gets a boolean indicating that only power of 2 textures are supported
  27737. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27738. */
  27739. readonly needPOTTextures: boolean;
  27740. /** @hidden */
  27741. _badOS: boolean;
  27742. /** @hidden */
  27743. _badDesktopOS: boolean;
  27744. /**
  27745. * Gets or sets a value indicating if we want to disable texture binding optimization.
  27746. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  27747. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  27748. */
  27749. disableTextureBindingOptimization: boolean;
  27750. /**
  27751. * Gets the audio engine
  27752. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27753. * @ignorenaming
  27754. */
  27755. static audioEngine: IAudioEngine;
  27756. /**
  27757. * Default AudioEngine factory responsible of creating the Audio Engine.
  27758. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27759. */
  27760. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27761. /**
  27762. * Default offline support factory responsible of creating a tool used to store data locally.
  27763. * By default, this will create a Database object if the workload has been embedded.
  27764. */
  27765. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27766. private _onFocus;
  27767. private _onBlur;
  27768. private _onCanvasPointerOut;
  27769. private _onCanvasBlur;
  27770. private _onCanvasFocus;
  27771. private _onFullscreenChange;
  27772. private _onPointerLockChange;
  27773. private _onVRDisplayPointerRestricted;
  27774. private _onVRDisplayPointerUnrestricted;
  27775. private _onVrDisplayConnect;
  27776. private _onVrDisplayDisconnect;
  27777. private _onVrDisplayPresentChange;
  27778. /**
  27779. * Observable signaled when VR display mode changes
  27780. */
  27781. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27782. /**
  27783. * Observable signaled when VR request present is complete
  27784. */
  27785. onVRRequestPresentComplete: Observable<boolean>;
  27786. /**
  27787. * Observable signaled when VR request present starts
  27788. */
  27789. onVRRequestPresentStart: Observable<Engine>;
  27790. private _hardwareScalingLevel;
  27791. /** @hidden */
  27792. protected _caps: EngineCapabilities;
  27793. private _pointerLockRequested;
  27794. private _isStencilEnable;
  27795. private _colorWrite;
  27796. private _loadingScreen;
  27797. /** @hidden */
  27798. _drawCalls: PerfCounter;
  27799. /** @hidden */
  27800. _textureCollisions: PerfCounter;
  27801. private _glVersion;
  27802. private _glRenderer;
  27803. private _glVendor;
  27804. private _videoTextureSupported;
  27805. private _renderingQueueLaunched;
  27806. private _activeRenderLoops;
  27807. private _deterministicLockstep;
  27808. private _lockstepMaxSteps;
  27809. /**
  27810. * Observable signaled when a context lost event is raised
  27811. */
  27812. onContextLostObservable: Observable<Engine>;
  27813. /**
  27814. * Observable signaled when a context restored event is raised
  27815. */
  27816. onContextRestoredObservable: Observable<Engine>;
  27817. private _onContextLost;
  27818. private _onContextRestored;
  27819. private _contextWasLost;
  27820. private _doNotHandleContextLost;
  27821. /**
  27822. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27823. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27824. */
  27825. doNotHandleContextLost: boolean;
  27826. private _performanceMonitor;
  27827. private _fps;
  27828. private _deltaTime;
  27829. /**
  27830. * Turn this value on if you want to pause FPS computation when in background
  27831. */
  27832. disablePerformanceMonitorInBackground: boolean;
  27833. /**
  27834. * Gets the performance monitor attached to this engine
  27835. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27836. */
  27837. readonly performanceMonitor: PerformanceMonitor;
  27838. /** @hidden */
  27839. protected _depthCullingState: _DepthCullingState;
  27840. /** @hidden */
  27841. protected _stencilState: _StencilState;
  27842. /** @hidden */
  27843. protected _alphaState: _AlphaState;
  27844. /** @hidden */
  27845. protected _alphaMode: number;
  27846. protected _internalTexturesCache: InternalTexture[];
  27847. /** @hidden */
  27848. protected _activeChannel: number;
  27849. private _currentTextureChannel;
  27850. /** @hidden */
  27851. protected _boundTexturesCache: {
  27852. [key: string]: Nullable<InternalTexture>;
  27853. };
  27854. /** @hidden */
  27855. protected _currentEffect: Nullable<Effect>;
  27856. /** @hidden */
  27857. protected _currentProgram: Nullable<WebGLProgram>;
  27858. private _compiledEffects;
  27859. private _vertexAttribArraysEnabled;
  27860. /** @hidden */
  27861. protected _cachedViewport: Nullable<Viewport>;
  27862. private _cachedVertexArrayObject;
  27863. /** @hidden */
  27864. protected _cachedVertexBuffers: any;
  27865. /** @hidden */
  27866. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  27867. /** @hidden */
  27868. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27869. /** @hidden */
  27870. protected _currentRenderTarget: Nullable<InternalTexture>;
  27871. private _uintIndicesCurrentlySet;
  27872. private _currentBoundBuffer;
  27873. /** @hidden */
  27874. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27875. private _currentBufferPointers;
  27876. private _currentInstanceLocations;
  27877. private _currentInstanceBuffers;
  27878. private _textureUnits;
  27879. private _firstBoundInternalTextureTracker;
  27880. private _lastBoundInternalTextureTracker;
  27881. private _workingCanvas;
  27882. private _workingContext;
  27883. private _rescalePostProcess;
  27884. private _dummyFramebuffer;
  27885. private _externalData;
  27886. private _bindedRenderFunction;
  27887. private _vaoRecordInProgress;
  27888. private _mustWipeVertexAttributes;
  27889. private _emptyTexture;
  27890. private _emptyCubeTexture;
  27891. private _emptyTexture3D;
  27892. /** @hidden */
  27893. _frameHandler: number;
  27894. private _nextFreeTextureSlots;
  27895. private _maxSimultaneousTextures;
  27896. private _activeRequests;
  27897. private _texturesSupported;
  27898. private _textureFormatInUse;
  27899. /**
  27900. * Gets the list of texture formats supported
  27901. */
  27902. readonly texturesSupported: Array<string>;
  27903. /**
  27904. * Gets the list of texture formats in use
  27905. */
  27906. readonly textureFormatInUse: Nullable<string>;
  27907. /**
  27908. * Gets the current viewport
  27909. */
  27910. readonly currentViewport: Nullable<Viewport>;
  27911. /**
  27912. * Gets the default empty texture
  27913. */
  27914. readonly emptyTexture: InternalTexture;
  27915. /**
  27916. * Gets the default empty 3D texture
  27917. */
  27918. readonly emptyTexture3D: InternalTexture;
  27919. /**
  27920. * Gets the default empty cube texture
  27921. */
  27922. readonly emptyCubeTexture: InternalTexture;
  27923. /**
  27924. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27925. */
  27926. readonly premultipliedAlpha: boolean;
  27927. /**
  27928. * Creates a new engine
  27929. * @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
  27930. * @param antialias defines enable antialiasing (default: false)
  27931. * @param options defines further options to be sent to the getContext() function
  27932. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27933. */
  27934. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27935. private _disableTouchAction;
  27936. private _rebuildInternalTextures;
  27937. private _rebuildEffects;
  27938. /**
  27939. * Gets a boolean indicating if all created effects are ready
  27940. * @returns true if all effects are ready
  27941. */
  27942. areAllEffectsReady(): boolean;
  27943. private _rebuildBuffers;
  27944. private _initGLContext;
  27945. /**
  27946. * Gets version of the current webGL context
  27947. */
  27948. readonly webGLVersion: number;
  27949. /**
  27950. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27951. */
  27952. readonly isStencilEnable: boolean;
  27953. private _prepareWorkingCanvas;
  27954. /**
  27955. * Reset the texture cache to empty state
  27956. */
  27957. resetTextureCache(): void;
  27958. /**
  27959. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27960. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27961. * @returns true if engine is in deterministic lock step mode
  27962. */
  27963. isDeterministicLockStep(): boolean;
  27964. /**
  27965. * Gets the max steps when engine is running in deterministic lock step
  27966. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27967. * @returns the max steps
  27968. */
  27969. getLockstepMaxSteps(): number;
  27970. /**
  27971. * Gets an object containing information about the current webGL context
  27972. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27973. */
  27974. getGlInfo(): {
  27975. vendor: string;
  27976. renderer: string;
  27977. version: string;
  27978. };
  27979. /**
  27980. * Gets current aspect ratio
  27981. * @param camera defines the camera to use to get the aspect ratio
  27982. * @param useScreen defines if screen size must be used (or the current render target if any)
  27983. * @returns a number defining the aspect ratio
  27984. */
  27985. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27986. /**
  27987. * Gets current screen aspect ratio
  27988. * @returns a number defining the aspect ratio
  27989. */
  27990. getScreenAspectRatio(): number;
  27991. /**
  27992. * Gets the current render width
  27993. * @param useScreen defines if screen size must be used (or the current render target if any)
  27994. * @returns a number defining the current render width
  27995. */
  27996. getRenderWidth(useScreen?: boolean): number;
  27997. /**
  27998. * Gets the current render height
  27999. * @param useScreen defines if screen size must be used (or the current render target if any)
  28000. * @returns a number defining the current render height
  28001. */
  28002. getRenderHeight(useScreen?: boolean): number;
  28003. /**
  28004. * Gets the HTML canvas attached with the current webGL context
  28005. * @returns a HTML canvas
  28006. */
  28007. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28008. /**
  28009. * Gets the client rect of the HTML canvas attached with the current webGL context
  28010. * @returns a client rectanglee
  28011. */
  28012. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28013. /**
  28014. * Defines the hardware scaling level.
  28015. * By default the hardware scaling level is computed from the window device ratio.
  28016. * 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.
  28017. * @param level defines the level to use
  28018. */
  28019. setHardwareScalingLevel(level: number): void;
  28020. /**
  28021. * Gets the current hardware scaling level.
  28022. * By default the hardware scaling level is computed from the window device ratio.
  28023. * 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.
  28024. * @returns a number indicating the current hardware scaling level
  28025. */
  28026. getHardwareScalingLevel(): number;
  28027. /**
  28028. * Gets the list of loaded textures
  28029. * @returns an array containing all loaded textures
  28030. */
  28031. getLoadedTexturesCache(): InternalTexture[];
  28032. /**
  28033. * Gets the object containing all engine capabilities
  28034. * @returns the EngineCapabilities object
  28035. */
  28036. getCaps(): EngineCapabilities;
  28037. /**
  28038. * Gets the current depth function
  28039. * @returns a number defining the depth function
  28040. */
  28041. getDepthFunction(): Nullable<number>;
  28042. /**
  28043. * Sets the current depth function
  28044. * @param depthFunc defines the function to use
  28045. */
  28046. setDepthFunction(depthFunc: number): void;
  28047. /**
  28048. * Sets the current depth function to GREATER
  28049. */
  28050. setDepthFunctionToGreater(): void;
  28051. /**
  28052. * Sets the current depth function to GEQUAL
  28053. */
  28054. setDepthFunctionToGreaterOrEqual(): void;
  28055. /**
  28056. * Sets the current depth function to LESS
  28057. */
  28058. setDepthFunctionToLess(): void;
  28059. private _cachedStencilBuffer;
  28060. private _cachedStencilFunction;
  28061. private _cachedStencilMask;
  28062. private _cachedStencilOperationPass;
  28063. private _cachedStencilOperationFail;
  28064. private _cachedStencilOperationDepthFail;
  28065. private _cachedStencilReference;
  28066. /**
  28067. * Caches the the state of the stencil buffer
  28068. */
  28069. cacheStencilState(): void;
  28070. /**
  28071. * Restores the state of the stencil buffer
  28072. */
  28073. restoreStencilState(): void;
  28074. /**
  28075. * Sets the current depth function to LEQUAL
  28076. */
  28077. setDepthFunctionToLessOrEqual(): void;
  28078. /**
  28079. * Gets a boolean indicating if stencil buffer is enabled
  28080. * @returns the current stencil buffer state
  28081. */
  28082. getStencilBuffer(): boolean;
  28083. /**
  28084. * Enable or disable the stencil buffer
  28085. * @param enable defines if the stencil buffer must be enabled or disabled
  28086. */
  28087. setStencilBuffer(enable: boolean): void;
  28088. /**
  28089. * Gets the current stencil mask
  28090. * @returns a number defining the new stencil mask to use
  28091. */
  28092. getStencilMask(): number;
  28093. /**
  28094. * Sets the current stencil mask
  28095. * @param mask defines the new stencil mask to use
  28096. */
  28097. setStencilMask(mask: number): void;
  28098. /**
  28099. * Gets the current stencil function
  28100. * @returns a number defining the stencil function to use
  28101. */
  28102. getStencilFunction(): number;
  28103. /**
  28104. * Gets the current stencil reference value
  28105. * @returns a number defining the stencil reference value to use
  28106. */
  28107. getStencilFunctionReference(): number;
  28108. /**
  28109. * Gets the current stencil mask
  28110. * @returns a number defining the stencil mask to use
  28111. */
  28112. getStencilFunctionMask(): number;
  28113. /**
  28114. * Sets the current stencil function
  28115. * @param stencilFunc defines the new stencil function to use
  28116. */
  28117. setStencilFunction(stencilFunc: number): void;
  28118. /**
  28119. * Sets the current stencil reference
  28120. * @param reference defines the new stencil reference to use
  28121. */
  28122. setStencilFunctionReference(reference: number): void;
  28123. /**
  28124. * Sets the current stencil mask
  28125. * @param mask defines the new stencil mask to use
  28126. */
  28127. setStencilFunctionMask(mask: number): void;
  28128. /**
  28129. * Gets the current stencil operation when stencil fails
  28130. * @returns a number defining stencil operation to use when stencil fails
  28131. */
  28132. getStencilOperationFail(): number;
  28133. /**
  28134. * Gets the current stencil operation when depth fails
  28135. * @returns a number defining stencil operation to use when depth fails
  28136. */
  28137. getStencilOperationDepthFail(): number;
  28138. /**
  28139. * Gets the current stencil operation when stencil passes
  28140. * @returns a number defining stencil operation to use when stencil passes
  28141. */
  28142. getStencilOperationPass(): number;
  28143. /**
  28144. * Sets the stencil operation to use when stencil fails
  28145. * @param operation defines the stencil operation to use when stencil fails
  28146. */
  28147. setStencilOperationFail(operation: number): void;
  28148. /**
  28149. * Sets the stencil operation to use when depth fails
  28150. * @param operation defines the stencil operation to use when depth fails
  28151. */
  28152. setStencilOperationDepthFail(operation: number): void;
  28153. /**
  28154. * Sets the stencil operation to use when stencil passes
  28155. * @param operation defines the stencil operation to use when stencil passes
  28156. */
  28157. setStencilOperationPass(operation: number): void;
  28158. /**
  28159. * Sets a boolean indicating if the dithering state is enabled or disabled
  28160. * @param value defines the dithering state
  28161. */
  28162. setDitheringState(value: boolean): void;
  28163. /**
  28164. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28165. * @param value defines the rasterizer state
  28166. */
  28167. setRasterizerState(value: boolean): void;
  28168. /**
  28169. * stop executing a render loop function and remove it from the execution array
  28170. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28171. */
  28172. stopRenderLoop(renderFunction?: () => void): void;
  28173. /** @hidden */
  28174. _renderLoop(): void;
  28175. /**
  28176. * Register and execute a render loop. The engine can have more than one render function
  28177. * @param renderFunction defines the function to continuously execute
  28178. */
  28179. runRenderLoop(renderFunction: () => void): void;
  28180. /**
  28181. * Toggle full screen mode
  28182. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28183. */
  28184. switchFullscreen(requestPointerLock: boolean): void;
  28185. /**
  28186. * Enters full screen mode
  28187. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28188. */
  28189. enterFullscreen(requestPointerLock: boolean): void;
  28190. /**
  28191. * Exits full screen mode
  28192. */
  28193. exitFullscreen(): void;
  28194. /**
  28195. * Clear the current render buffer or the current render target (if any is set up)
  28196. * @param color defines the color to use
  28197. * @param backBuffer defines if the back buffer must be cleared
  28198. * @param depth defines if the depth buffer must be cleared
  28199. * @param stencil defines if the stencil buffer must be cleared
  28200. */
  28201. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28202. /**
  28203. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28204. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28205. * @param y defines the y-coordinate of the corner of the clear rectangle
  28206. * @param width defines the width of the clear rectangle
  28207. * @param height defines the height of the clear rectangle
  28208. * @param clearColor defines the clear color
  28209. */
  28210. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28211. /**
  28212. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28213. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28214. * @param y defines the y-coordinate of the corner of the clear rectangle
  28215. * @param width defines the width of the clear rectangle
  28216. * @param height defines the height of the clear rectangle
  28217. */
  28218. enableScissor(x: number, y: number, width: number, height: number): void;
  28219. /**
  28220. * Disable previously set scissor test rectangle
  28221. */
  28222. disableScissor(): void;
  28223. private _viewportCached;
  28224. /** @hidden */
  28225. _viewport(x: number, y: number, width: number, height: number): void;
  28226. /**
  28227. * Set the WebGL's viewport
  28228. * @param viewport defines the viewport element to be used
  28229. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28230. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28231. */
  28232. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28233. /**
  28234. * Directly set the WebGL Viewport
  28235. * @param x defines the x coordinate of the viewport (in screen space)
  28236. * @param y defines the y coordinate of the viewport (in screen space)
  28237. * @param width defines the width of the viewport (in screen space)
  28238. * @param height defines the height of the viewport (in screen space)
  28239. * @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
  28240. */
  28241. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28242. /**
  28243. * Begin a new frame
  28244. */
  28245. beginFrame(): void;
  28246. /**
  28247. * Enf the current frame
  28248. */
  28249. endFrame(): void;
  28250. /**
  28251. * Resize the view according to the canvas' size
  28252. */
  28253. resize(): void;
  28254. /**
  28255. * Force a specific size of the canvas
  28256. * @param width defines the new canvas' width
  28257. * @param height defines the new canvas' height
  28258. */
  28259. setSize(width: number, height: number): void;
  28260. /**
  28261. * Gets a boolean indicating if a webVR device was detected
  28262. * @returns true if a webVR device was detected
  28263. */
  28264. isVRDevicePresent(): boolean;
  28265. /**
  28266. * Gets the current webVR device
  28267. * @returns the current webVR device (or null)
  28268. */
  28269. getVRDevice(): any;
  28270. /**
  28271. * Initializes a webVR display and starts listening to display change events
  28272. * The onVRDisplayChangedObservable will be notified upon these changes
  28273. * @returns The onVRDisplayChangedObservable
  28274. */
  28275. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28276. /**
  28277. * Initializes a webVR display and starts listening to display change events
  28278. * The onVRDisplayChangedObservable will be notified upon these changes
  28279. * @returns A promise containing a VRDisplay and if vr is supported
  28280. */
  28281. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  28282. /**
  28283. * Call this function to switch to webVR mode
  28284. * Will do nothing if webVR is not supported or if there is no webVR device
  28285. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28286. */
  28287. enableVR(): void;
  28288. /**
  28289. * Call this function to leave webVR mode
  28290. * Will do nothing if webVR is not supported or if there is no webVR device
  28291. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28292. */
  28293. disableVR(): void;
  28294. private _onVRFullScreenTriggered;
  28295. private _getVRDisplaysAsync;
  28296. /**
  28297. * Binds the frame buffer to the specified texture.
  28298. * @param texture The texture to render to or null for the default canvas
  28299. * @param faceIndex The face of the texture to render to in case of cube texture
  28300. * @param requiredWidth The width of the target to render to
  28301. * @param requiredHeight The height of the target to render to
  28302. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28303. * @param depthStencilTexture The depth stencil texture to use to render
  28304. * @param lodLevel defines le lod level to bind to the frame buffer
  28305. */
  28306. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28307. private bindUnboundFramebuffer;
  28308. /**
  28309. * Unbind the current render target texture from the webGL context
  28310. * @param texture defines the render target texture to unbind
  28311. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28312. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28313. */
  28314. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28315. /**
  28316. * Unbind a list of render target textures from the webGL context
  28317. * This is used only when drawBuffer extension or webGL2 are active
  28318. * @param textures defines the render target textures to unbind
  28319. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28320. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28321. */
  28322. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28323. /**
  28324. * Force the mipmap generation for the given render target texture
  28325. * @param texture defines the render target texture to use
  28326. */
  28327. generateMipMapsForCubemap(texture: InternalTexture): void;
  28328. /**
  28329. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28330. */
  28331. flushFramebuffer(): void;
  28332. /**
  28333. * Unbind the current render target and bind the default framebuffer
  28334. */
  28335. restoreDefaultFramebuffer(): void;
  28336. /**
  28337. * Create an uniform buffer
  28338. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28339. * @param elements defines the content of the uniform buffer
  28340. * @returns the webGL uniform buffer
  28341. */
  28342. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  28343. /**
  28344. * Create a dynamic uniform buffer
  28345. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28346. * @param elements defines the content of the uniform buffer
  28347. * @returns the webGL uniform buffer
  28348. */
  28349. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  28350. /**
  28351. * Update an existing uniform buffer
  28352. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28353. * @param uniformBuffer defines the target uniform buffer
  28354. * @param elements defines the content to update
  28355. * @param offset defines the offset in the uniform buffer where update should start
  28356. * @param count defines the size of the data to update
  28357. */
  28358. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28359. private _resetVertexBufferBinding;
  28360. /**
  28361. * Creates a vertex buffer
  28362. * @param data the data for the vertex buffer
  28363. * @returns the new WebGL static buffer
  28364. */
  28365. createVertexBuffer(data: DataArray): WebGLBuffer;
  28366. /**
  28367. * Creates a dynamic vertex buffer
  28368. * @param data the data for the dynamic vertex buffer
  28369. * @returns the new WebGL dynamic buffer
  28370. */
  28371. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  28372. /**
  28373. * Update a dynamic index buffer
  28374. * @param indexBuffer defines the target index buffer
  28375. * @param indices defines the data to update
  28376. * @param offset defines the offset in the target index buffer where update should start
  28377. */
  28378. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  28379. /**
  28380. * Updates a dynamic vertex buffer.
  28381. * @param vertexBuffer the vertex buffer to update
  28382. * @param data the data used to update the vertex buffer
  28383. * @param byteOffset the byte offset of the data
  28384. * @param byteLength the byte length of the data
  28385. */
  28386. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28387. private _resetIndexBufferBinding;
  28388. /**
  28389. * Creates a new index buffer
  28390. * @param indices defines the content of the index buffer
  28391. * @param updatable defines if the index buffer must be updatable
  28392. * @returns a new webGL buffer
  28393. */
  28394. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  28395. /**
  28396. * Bind a webGL buffer to the webGL context
  28397. * @param buffer defines the buffer to bind
  28398. */
  28399. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  28400. /**
  28401. * Bind an uniform buffer to the current webGL context
  28402. * @param buffer defines the buffer to bind
  28403. */
  28404. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  28405. /**
  28406. * Bind a buffer to the current webGL context at a given location
  28407. * @param buffer defines the buffer to bind
  28408. * @param location defines the index where to bind the buffer
  28409. */
  28410. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  28411. /**
  28412. * Bind a specific block at a given index in a specific shader program
  28413. * @param shaderProgram defines the shader program
  28414. * @param blockName defines the block name
  28415. * @param index defines the index where to bind the block
  28416. */
  28417. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  28418. private bindIndexBuffer;
  28419. private bindBuffer;
  28420. /**
  28421. * update the bound buffer with the given data
  28422. * @param data defines the data to update
  28423. */
  28424. updateArrayBuffer(data: Float32Array): void;
  28425. private _vertexAttribPointer;
  28426. private _bindIndexBufferWithCache;
  28427. private _bindVertexBuffersAttributes;
  28428. /**
  28429. * Records a vertex array object
  28430. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28431. * @param vertexBuffers defines the list of vertex buffers to store
  28432. * @param indexBuffer defines the index buffer to store
  28433. * @param effect defines the effect to store
  28434. * @returns the new vertex array object
  28435. */
  28436. recordVertexArrayObject(vertexBuffers: {
  28437. [key: string]: VertexBuffer;
  28438. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  28439. /**
  28440. * Bind a specific vertex array object
  28441. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28442. * @param vertexArrayObject defines the vertex array object to bind
  28443. * @param indexBuffer defines the index buffer to bind
  28444. */
  28445. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  28446. /**
  28447. * Bind webGl buffers directly to the webGL context
  28448. * @param vertexBuffer defines the vertex buffer to bind
  28449. * @param indexBuffer defines the index buffer to bind
  28450. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28451. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28452. * @param effect defines the effect associated with the vertex buffer
  28453. */
  28454. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28455. private _unbindVertexArrayObject;
  28456. /**
  28457. * Bind a list of vertex buffers to the webGL context
  28458. * @param vertexBuffers defines the list of vertex buffers to bind
  28459. * @param indexBuffer defines the index buffer to bind
  28460. * @param effect defines the effect associated with the vertex buffers
  28461. */
  28462. bindBuffers(vertexBuffers: {
  28463. [key: string]: Nullable<VertexBuffer>;
  28464. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  28465. /**
  28466. * Unbind all instance attributes
  28467. */
  28468. unbindInstanceAttributes(): void;
  28469. /**
  28470. * Release and free the memory of a vertex array object
  28471. * @param vao defines the vertex array object to delete
  28472. */
  28473. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28474. /** @hidden */
  28475. _releaseBuffer(buffer: WebGLBuffer): boolean;
  28476. /**
  28477. * Creates a webGL buffer to use with instanciation
  28478. * @param capacity defines the size of the buffer
  28479. * @returns the webGL buffer
  28480. */
  28481. createInstancesBuffer(capacity: number): WebGLBuffer;
  28482. /**
  28483. * Delete a webGL buffer used with instanciation
  28484. * @param buffer defines the webGL buffer to delete
  28485. */
  28486. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28487. /**
  28488. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28489. * @param instancesBuffer defines the webGL buffer to update and bind
  28490. * @param data defines the data to store in the buffer
  28491. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28492. */
  28493. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28494. /**
  28495. * Apply all cached states (depth, culling, stencil and alpha)
  28496. */
  28497. applyStates(): void;
  28498. /**
  28499. * Send a draw order
  28500. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28501. * @param indexStart defines the starting index
  28502. * @param indexCount defines the number of index to draw
  28503. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28504. */
  28505. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28506. /**
  28507. * Draw a list of points
  28508. * @param verticesStart defines the index of first vertex to draw
  28509. * @param verticesCount defines the count of vertices to draw
  28510. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28511. */
  28512. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28513. /**
  28514. * Draw a list of unindexed primitives
  28515. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28516. * @param verticesStart defines the index of first vertex to draw
  28517. * @param verticesCount defines the count of vertices to draw
  28518. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28519. */
  28520. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28521. /**
  28522. * Draw a list of indexed primitives
  28523. * @param fillMode defines the primitive to use
  28524. * @param indexStart defines the starting index
  28525. * @param indexCount defines the number of index to draw
  28526. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28527. */
  28528. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28529. /**
  28530. * Draw a list of unindexed primitives
  28531. * @param fillMode defines the primitive to use
  28532. * @param verticesStart defines the index of first vertex to draw
  28533. * @param verticesCount defines the count of vertices to draw
  28534. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28535. */
  28536. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28537. private _drawMode;
  28538. /** @hidden */
  28539. _releaseEffect(effect: Effect): void;
  28540. /** @hidden */
  28541. _deleteProgram(program: WebGLProgram): void;
  28542. /**
  28543. * Create a new effect (used to store vertex/fragment shaders)
  28544. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28545. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28546. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28547. * @param samplers defines an array of string used to represent textures
  28548. * @param defines defines the string containing the defines to use to compile the shaders
  28549. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28550. * @param onCompiled defines a function to call when the effect creation is successful
  28551. * @param onError defines a function to call when the effect creation has failed
  28552. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28553. * @returns the new Effect
  28554. */
  28555. 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;
  28556. private _compileShader;
  28557. private _compileRawShader;
  28558. /**
  28559. * Directly creates a webGL program
  28560. * @param vertexCode defines the vertex shader code to use
  28561. * @param fragmentCode defines the fragment shader code to use
  28562. * @param context defines the webGL context to use (if not set, the current one will be used)
  28563. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28564. * @returns the new webGL program
  28565. */
  28566. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28567. /**
  28568. * Creates a webGL program
  28569. * @param vertexCode defines the vertex shader code to use
  28570. * @param fragmentCode defines the fragment shader code to use
  28571. * @param defines defines the string containing the defines to use to compile the shaders
  28572. * @param context defines the webGL context to use (if not set, the current one will be used)
  28573. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28574. * @returns the new webGL program
  28575. */
  28576. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28577. private _createShaderProgram;
  28578. private _finalizeProgram;
  28579. /** @hidden */
  28580. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  28581. /** @hidden */
  28582. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  28583. /**
  28584. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28585. * @param shaderProgram defines the webGL program to use
  28586. * @param uniformsNames defines the list of uniform names
  28587. * @returns an array of webGL uniform locations
  28588. */
  28589. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28590. /**
  28591. * Gets the lsit of active attributes for a given webGL program
  28592. * @param shaderProgram defines the webGL program to use
  28593. * @param attributesNames defines the list of attribute names to get
  28594. * @returns an array of indices indicating the offset of each attribute
  28595. */
  28596. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  28597. /**
  28598. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28599. * @param effect defines the effect to activate
  28600. */
  28601. enableEffect(effect: Nullable<Effect>): void;
  28602. /**
  28603. * Set the value of an uniform to an array of int32
  28604. * @param uniform defines the webGL uniform location where to store the value
  28605. * @param array defines the array of int32 to store
  28606. */
  28607. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28608. /**
  28609. * Set the value of an uniform to an array of int32 (stored as vec2)
  28610. * @param uniform defines the webGL uniform location where to store the value
  28611. * @param array defines the array of int32 to store
  28612. */
  28613. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28614. /**
  28615. * Set the value of an uniform to an array of int32 (stored as vec3)
  28616. * @param uniform defines the webGL uniform location where to store the value
  28617. * @param array defines the array of int32 to store
  28618. */
  28619. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28620. /**
  28621. * Set the value of an uniform to an array of int32 (stored as vec4)
  28622. * @param uniform defines the webGL uniform location where to store the value
  28623. * @param array defines the array of int32 to store
  28624. */
  28625. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28626. /**
  28627. * Set the value of an uniform to an array of float32
  28628. * @param uniform defines the webGL uniform location where to store the value
  28629. * @param array defines the array of float32 to store
  28630. */
  28631. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28632. /**
  28633. * Set the value of an uniform to an array of float32 (stored as vec2)
  28634. * @param uniform defines the webGL uniform location where to store the value
  28635. * @param array defines the array of float32 to store
  28636. */
  28637. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28638. /**
  28639. * Set the value of an uniform to an array of float32 (stored as vec3)
  28640. * @param uniform defines the webGL uniform location where to store the value
  28641. * @param array defines the array of float32 to store
  28642. */
  28643. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28644. /**
  28645. * Set the value of an uniform to an array of float32 (stored as vec4)
  28646. * @param uniform defines the webGL uniform location where to store the value
  28647. * @param array defines the array of float32 to store
  28648. */
  28649. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28650. /**
  28651. * Set the value of an uniform to an array of number
  28652. * @param uniform defines the webGL uniform location where to store the value
  28653. * @param array defines the array of number to store
  28654. */
  28655. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28656. /**
  28657. * Set the value of an uniform to an array of number (stored as vec2)
  28658. * @param uniform defines the webGL uniform location where to store the value
  28659. * @param array defines the array of number to store
  28660. */
  28661. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28662. /**
  28663. * Set the value of an uniform to an array of number (stored as vec3)
  28664. * @param uniform defines the webGL uniform location where to store the value
  28665. * @param array defines the array of number to store
  28666. */
  28667. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28668. /**
  28669. * Set the value of an uniform to an array of number (stored as vec4)
  28670. * @param uniform defines the webGL uniform location where to store the value
  28671. * @param array defines the array of number to store
  28672. */
  28673. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28674. /**
  28675. * Set the value of an uniform to an array of float32 (stored as matrices)
  28676. * @param uniform defines the webGL uniform location where to store the value
  28677. * @param matrices defines the array of float32 to store
  28678. */
  28679. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28680. /**
  28681. * Set the value of an uniform to a matrix
  28682. * @param uniform defines the webGL uniform location where to store the value
  28683. * @param matrix defines the matrix to store
  28684. */
  28685. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28686. /**
  28687. * Set the value of an uniform to a matrix (3x3)
  28688. * @param uniform defines the webGL uniform location where to store the value
  28689. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28690. */
  28691. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28692. /**
  28693. * Set the value of an uniform to a matrix (2x2)
  28694. * @param uniform defines the webGL uniform location where to store the value
  28695. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28696. */
  28697. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28698. /**
  28699. * Set the value of an uniform to a number (int)
  28700. * @param uniform defines the webGL uniform location where to store the value
  28701. * @param value defines the int number to store
  28702. */
  28703. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28704. /**
  28705. * Set the value of an uniform to a number (float)
  28706. * @param uniform defines the webGL uniform location where to store the value
  28707. * @param value defines the float number to store
  28708. */
  28709. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28710. /**
  28711. * Set the value of an uniform to a vec2
  28712. * @param uniform defines the webGL uniform location where to store the value
  28713. * @param x defines the 1st component of the value
  28714. * @param y defines the 2nd component of the value
  28715. */
  28716. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28717. /**
  28718. * Set the value of an uniform to a vec3
  28719. * @param uniform defines the webGL uniform location where to store the value
  28720. * @param x defines the 1st component of the value
  28721. * @param y defines the 2nd component of the value
  28722. * @param z defines the 3rd component of the value
  28723. */
  28724. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28725. /**
  28726. * Set the value of an uniform to a boolean
  28727. * @param uniform defines the webGL uniform location where to store the value
  28728. * @param bool defines the boolean to store
  28729. */
  28730. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28731. /**
  28732. * Set the value of an uniform to a vec4
  28733. * @param uniform defines the webGL uniform location where to store the value
  28734. * @param x defines the 1st component of the value
  28735. * @param y defines the 2nd component of the value
  28736. * @param z defines the 3rd component of the value
  28737. * @param w defines the 4th component of the value
  28738. */
  28739. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28740. /**
  28741. * Set the value of an uniform to a Color3
  28742. * @param uniform defines the webGL uniform location where to store the value
  28743. * @param color3 defines the color to store
  28744. */
  28745. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28746. /**
  28747. * Set the value of an uniform to a Color3 and an alpha value
  28748. * @param uniform defines the webGL uniform location where to store the value
  28749. * @param color3 defines the color to store
  28750. * @param alpha defines the alpha component to store
  28751. */
  28752. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28753. /**
  28754. * Sets a Color4 on a uniform variable
  28755. * @param uniform defines the uniform location
  28756. * @param color4 defines the value to be set
  28757. */
  28758. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28759. /**
  28760. * Set various states to the webGL context
  28761. * @param culling defines backface culling state
  28762. * @param zOffset defines the value to apply to zOffset (0 by default)
  28763. * @param force defines if states must be applied even if cache is up to date
  28764. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28765. */
  28766. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28767. /**
  28768. * Set the z offset to apply to current rendering
  28769. * @param value defines the offset to apply
  28770. */
  28771. setZOffset(value: number): void;
  28772. /**
  28773. * Gets the current value of the zOffset
  28774. * @returns the current zOffset state
  28775. */
  28776. getZOffset(): number;
  28777. /**
  28778. * Enable or disable depth buffering
  28779. * @param enable defines the state to set
  28780. */
  28781. setDepthBuffer(enable: boolean): void;
  28782. /**
  28783. * Gets a boolean indicating if depth writing is enabled
  28784. * @returns the current depth writing state
  28785. */
  28786. getDepthWrite(): boolean;
  28787. /**
  28788. * Enable or disable depth writing
  28789. * @param enable defines the state to set
  28790. */
  28791. setDepthWrite(enable: boolean): void;
  28792. /**
  28793. * Enable or disable color writing
  28794. * @param enable defines the state to set
  28795. */
  28796. setColorWrite(enable: boolean): void;
  28797. /**
  28798. * Gets a boolean indicating if color writing is enabled
  28799. * @returns the current color writing state
  28800. */
  28801. getColorWrite(): boolean;
  28802. /**
  28803. * Sets alpha constants used by some alpha blending modes
  28804. * @param r defines the red component
  28805. * @param g defines the green component
  28806. * @param b defines the blue component
  28807. * @param a defines the alpha component
  28808. */
  28809. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28810. /**
  28811. * Sets the current alpha mode
  28812. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28813. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28814. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28815. */
  28816. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28817. /**
  28818. * Gets the current alpha mode
  28819. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28820. * @returns the current alpha mode
  28821. */
  28822. getAlphaMode(): number;
  28823. /**
  28824. * Clears the list of texture accessible through engine.
  28825. * This can help preventing texture load conflict due to name collision.
  28826. */
  28827. clearInternalTexturesCache(): void;
  28828. /**
  28829. * Force the entire cache to be cleared
  28830. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28831. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28832. */
  28833. wipeCaches(bruteForce?: boolean): void;
  28834. /**
  28835. * Set the compressed texture format to use, based on the formats you have, and the formats
  28836. * supported by the hardware / browser.
  28837. *
  28838. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28839. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28840. * to API arguments needed to compressed textures. This puts the burden on the container
  28841. * generator to house the arcane code for determining these for current & future formats.
  28842. *
  28843. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28844. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28845. *
  28846. * Note: The result of this call is not taken into account when a texture is base64.
  28847. *
  28848. * @param formatsAvailable defines the list of those format families you have created
  28849. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28850. *
  28851. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28852. * @returns The extension selected.
  28853. */
  28854. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28855. private _getSamplingParameters;
  28856. private _partialLoadImg;
  28857. private _cascadeLoadImgs;
  28858. /** @hidden */
  28859. _createTexture(): WebGLTexture;
  28860. /**
  28861. * Usually called from Texture.ts.
  28862. * Passed information to create a WebGLTexture
  28863. * @param urlArg defines a value which contains one of the following:
  28864. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28865. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28866. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28867. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28868. * @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)
  28869. * @param scene needed for loading to the correct scene
  28870. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28871. * @param onLoad optional callback to be called upon successful completion
  28872. * @param onError optional callback to be called upon failure
  28873. * @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
  28874. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28875. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28876. * @param forcedExtension defines the extension to use to pick the right loader
  28877. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28878. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28879. */
  28880. 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;
  28881. private _rescaleTexture;
  28882. /**
  28883. * Update a raw texture
  28884. * @param texture defines the texture to update
  28885. * @param data defines the data to store in the texture
  28886. * @param format defines the format of the data
  28887. * @param invertY defines if data must be stored with Y axis inverted
  28888. * @param compression defines the compression used (null by default)
  28889. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28890. */
  28891. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  28892. /**
  28893. * Creates a raw texture
  28894. * @param data defines the data to store in the texture
  28895. * @param width defines the width of the texture
  28896. * @param height defines the height of the texture
  28897. * @param format defines the format of the data
  28898. * @param generateMipMaps defines if the engine should generate the mip levels
  28899. * @param invertY defines if data must be stored with Y axis inverted
  28900. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28901. * @param compression defines the compression used (null by default)
  28902. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28903. * @returns the raw texture inside an InternalTexture
  28904. */
  28905. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  28906. private _unpackFlipYCached;
  28907. /**
  28908. * In case you are sharing the context with other applications, it might
  28909. * be interested to not cache the unpack flip y state to ensure a consistent
  28910. * value would be set.
  28911. */
  28912. enableUnpackFlipYCached: boolean;
  28913. /** @hidden */
  28914. _unpackFlipY(value: boolean): void;
  28915. /** @hidden */
  28916. _getUnpackAlignement(): number;
  28917. /**
  28918. * Creates a dynamic texture
  28919. * @param width defines the width of the texture
  28920. * @param height defines the height of the texture
  28921. * @param generateMipMaps defines if the engine should generate the mip levels
  28922. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28923. * @returns the dynamic texture inside an InternalTexture
  28924. */
  28925. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28926. /**
  28927. * Update the sampling mode of a given texture
  28928. * @param samplingMode defines the required sampling mode
  28929. * @param texture defines the texture to update
  28930. */
  28931. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28932. /**
  28933. * Update the content of a dynamic texture
  28934. * @param texture defines the texture to update
  28935. * @param canvas defines the canvas containing the source
  28936. * @param invertY defines if data must be stored with Y axis inverted
  28937. * @param premulAlpha defines if alpha is stored as premultiplied
  28938. * @param format defines the format of the data
  28939. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28940. */
  28941. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28942. /**
  28943. * Update a video texture
  28944. * @param texture defines the texture to update
  28945. * @param video defines the video element to use
  28946. * @param invertY defines if data must be stored with Y axis inverted
  28947. */
  28948. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28949. /**
  28950. * Updates a depth texture Comparison Mode and Function.
  28951. * If the comparison Function is equal to 0, the mode will be set to none.
  28952. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28953. * @param texture The texture to set the comparison function for
  28954. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28955. */
  28956. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28957. private _setupDepthStencilTexture;
  28958. /**
  28959. * Creates a depth stencil texture.
  28960. * This is only available in WebGL 2 or with the depth texture extension available.
  28961. * @param size The size of face edge in the texture.
  28962. * @param options The options defining the texture.
  28963. * @returns The texture
  28964. */
  28965. createDepthStencilTexture(size: number | {
  28966. width: number;
  28967. height: number;
  28968. }, options: DepthTextureCreationOptions): InternalTexture;
  28969. /**
  28970. * Creates a depth stencil texture.
  28971. * This is only available in WebGL 2 or with the depth texture extension available.
  28972. * @param size The size of face edge in the texture.
  28973. * @param options The options defining the texture.
  28974. * @returns The texture
  28975. */
  28976. private _createDepthStencilTexture;
  28977. /**
  28978. * Creates a depth stencil cube texture.
  28979. * This is only available in WebGL 2.
  28980. * @param size The size of face edge in the cube texture.
  28981. * @param options The options defining the cube texture.
  28982. * @returns The cube texture
  28983. */
  28984. private _createDepthStencilCubeTexture;
  28985. /**
  28986. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28987. * @param renderTarget The render target to set the frame buffer for
  28988. */
  28989. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28990. /**
  28991. * Creates a new render target texture
  28992. * @param size defines the size of the texture
  28993. * @param options defines the options used to create the texture
  28994. * @returns a new render target texture stored in an InternalTexture
  28995. */
  28996. createRenderTargetTexture(size: number | {
  28997. width: number;
  28998. height: number;
  28999. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29000. /**
  29001. * Create a multi render target texture
  29002. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  29003. * @param size defines the size of the texture
  29004. * @param options defines the creation options
  29005. * @returns the cube texture as an InternalTexture
  29006. */
  29007. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  29008. private _setupFramebufferDepthAttachments;
  29009. /**
  29010. * Updates the sample count of a render target texture
  29011. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29012. * @param texture defines the texture to update
  29013. * @param samples defines the sample count to set
  29014. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29015. */
  29016. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29017. /**
  29018. * Update the sample count for a given multiple render target texture
  29019. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29020. * @param textures defines the textures to update
  29021. * @param samples defines the sample count to set
  29022. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29023. */
  29024. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  29025. /** @hidden */
  29026. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29027. /** @hidden */
  29028. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29029. /** @hidden */
  29030. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29031. /** @hidden */
  29032. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29033. /**
  29034. * Creates a new render target cube texture
  29035. * @param size defines the size of the texture
  29036. * @param options defines the options used to create the texture
  29037. * @returns a new render target cube texture stored in an InternalTexture
  29038. */
  29039. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  29040. /**
  29041. * Creates a cube texture
  29042. * @param rootUrl defines the url where the files to load is located
  29043. * @param scene defines the current scene
  29044. * @param files defines the list of files to load (1 per face)
  29045. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  29046. * @param onLoad defines an optional callback raised when the texture is loaded
  29047. * @param onError defines an optional callback raised if there is an issue to load the texture
  29048. * @param format defines the format of the data
  29049. * @param forcedExtension defines the extension to use to pick the right loader
  29050. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  29051. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  29052. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  29053. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  29054. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  29055. * @returns the cube texture as an InternalTexture
  29056. */
  29057. 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;
  29058. /**
  29059. * @hidden
  29060. */
  29061. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29062. /**
  29063. * Update a raw cube texture
  29064. * @param texture defines the texture to udpdate
  29065. * @param data defines the data to store
  29066. * @param format defines the data format
  29067. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29068. * @param invertY defines if data must be stored with Y axis inverted
  29069. * @param compression defines the compression used (null by default)
  29070. * @param level defines which level of the texture to update
  29071. */
  29072. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  29073. /**
  29074. * Creates a new raw cube texture
  29075. * @param data defines the array of data to use to create each face
  29076. * @param size defines the size of the textures
  29077. * @param format defines the format of the data
  29078. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29079. * @param generateMipMaps defines if the engine should generate the mip levels
  29080. * @param invertY defines if data must be stored with Y axis inverted
  29081. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29082. * @param compression defines the compression used (null by default)
  29083. * @returns the cube texture as an InternalTexture
  29084. */
  29085. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  29086. /**
  29087. * Creates a new raw cube texture from a specified url
  29088. * @param url defines the url where the data is located
  29089. * @param scene defines the current scene
  29090. * @param size defines the size of the textures
  29091. * @param format defines the format of the data
  29092. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29093. * @param noMipmap defines if the engine should avoid generating the mip levels
  29094. * @param callback defines a callback used to extract texture data from loaded data
  29095. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  29096. * @param onLoad defines a callback called when texture is loaded
  29097. * @param onError defines a callback called if there is an error
  29098. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29099. * @param invertY defines if data must be stored with Y axis inverted
  29100. * @returns the cube texture as an InternalTexture
  29101. */
  29102. 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;
  29103. /**
  29104. * Update a raw 3D texture
  29105. * @param texture defines the texture to update
  29106. * @param data defines the data to store
  29107. * @param format defines the data format
  29108. * @param invertY defines if data must be stored with Y axis inverted
  29109. * @param compression defines the used compression (can be null)
  29110. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  29111. */
  29112. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  29113. /**
  29114. * Creates a new raw 3D texture
  29115. * @param data defines the data used to create the texture
  29116. * @param width defines the width of the texture
  29117. * @param height defines the height of the texture
  29118. * @param depth defines the depth of the texture
  29119. * @param format defines the format of the texture
  29120. * @param generateMipMaps defines if the engine must generate mip levels
  29121. * @param invertY defines if data must be stored with Y axis inverted
  29122. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29123. * @param compression defines the compressed used (can be null)
  29124. * @param textureType defines the compressed used (can be null)
  29125. * @returns a new raw 3D texture (stored in an InternalTexture)
  29126. */
  29127. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  29128. private _prepareWebGLTextureContinuation;
  29129. private _prepareWebGLTexture;
  29130. private _convertRGBtoRGBATextureData;
  29131. /** @hidden */
  29132. _releaseFramebufferObjects(texture: InternalTexture): void;
  29133. /** @hidden */
  29134. _releaseTexture(texture: InternalTexture): void;
  29135. private setProgram;
  29136. private _boundUniforms;
  29137. /**
  29138. * Binds an effect to the webGL context
  29139. * @param effect defines the effect to bind
  29140. */
  29141. bindSamplers(effect: Effect): void;
  29142. private _moveBoundTextureOnTop;
  29143. private _getCorrectTextureChannel;
  29144. private _linkTrackers;
  29145. private _removeDesignatedSlot;
  29146. private _activateCurrentTexture;
  29147. /** @hidden */
  29148. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29149. /** @hidden */
  29150. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29151. /**
  29152. * Sets a texture to the webGL context from a postprocess
  29153. * @param channel defines the channel to use
  29154. * @param postProcess defines the source postprocess
  29155. */
  29156. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29157. /**
  29158. * Binds the output of the passed in post process to the texture channel specified
  29159. * @param channel The channel the texture should be bound to
  29160. * @param postProcess The post process which's output should be bound
  29161. */
  29162. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29163. /**
  29164. * Unbind all textures from the webGL context
  29165. */
  29166. unbindAllTextures(): void;
  29167. /**
  29168. * Sets a texture to the according uniform.
  29169. * @param channel The texture channel
  29170. * @param uniform The uniform to set
  29171. * @param texture The texture to apply
  29172. */
  29173. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29174. /**
  29175. * Sets a depth stencil texture from a render target to the according uniform.
  29176. * @param channel The texture channel
  29177. * @param uniform The uniform to set
  29178. * @param texture The render target texture containing the depth stencil texture to apply
  29179. */
  29180. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29181. private _bindSamplerUniformToChannel;
  29182. private _getTextureWrapMode;
  29183. private _setTexture;
  29184. /**
  29185. * Sets an array of texture to the webGL context
  29186. * @param channel defines the channel where the texture array must be set
  29187. * @param uniform defines the associated uniform location
  29188. * @param textures defines the array of textures to bind
  29189. */
  29190. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29191. /** @hidden */
  29192. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29193. private _setTextureParameterFloat;
  29194. private _setTextureParameterInteger;
  29195. /**
  29196. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29197. * @param x defines the x coordinate of the rectangle where pixels must be read
  29198. * @param y defines the y coordinate of the rectangle where pixels must be read
  29199. * @param width defines the width of the rectangle where pixels must be read
  29200. * @param height defines the height of the rectangle where pixels must be read
  29201. * @returns a Uint8Array containing RGBA colors
  29202. */
  29203. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29204. /**
  29205. * Add an externaly attached data from its key.
  29206. * This method call will fail and return false, if such key already exists.
  29207. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29208. * @param key the unique key that identifies the data
  29209. * @param data the data object to associate to the key for this Engine instance
  29210. * @return true if no such key were already present and the data was added successfully, false otherwise
  29211. */
  29212. addExternalData<T>(key: string, data: T): boolean;
  29213. /**
  29214. * Get an externaly attached data from its key
  29215. * @param key the unique key that identifies the data
  29216. * @return the associated data, if present (can be null), or undefined if not present
  29217. */
  29218. getExternalData<T>(key: string): T;
  29219. /**
  29220. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29221. * @param key the unique key that identifies the data
  29222. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29223. * @return the associated data, can be null if the factory returned null.
  29224. */
  29225. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29226. /**
  29227. * Remove an externaly attached data from the Engine instance
  29228. * @param key the unique key that identifies the data
  29229. * @return true if the data was successfully removed, false if it doesn't exist
  29230. */
  29231. removeExternalData(key: string): boolean;
  29232. /**
  29233. * Unbind all vertex attributes from the webGL context
  29234. */
  29235. unbindAllAttributes(): void;
  29236. /**
  29237. * 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
  29238. */
  29239. releaseEffects(): void;
  29240. /**
  29241. * Dispose and release all associated resources
  29242. */
  29243. dispose(): void;
  29244. /**
  29245. * Display the loading screen
  29246. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29247. */
  29248. displayLoadingUI(): void;
  29249. /**
  29250. * Hide the loading screen
  29251. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29252. */
  29253. hideLoadingUI(): void;
  29254. /**
  29255. * Gets the current loading screen object
  29256. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29257. */
  29258. /**
  29259. * Sets the current loading screen object
  29260. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29261. */
  29262. loadingScreen: ILoadingScreen;
  29263. /**
  29264. * Sets the current loading screen text
  29265. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29266. */
  29267. loadingUIText: string;
  29268. /**
  29269. * Sets the current loading screen background color
  29270. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29271. */
  29272. loadingUIBackgroundColor: string;
  29273. /**
  29274. * Attach a new callback raised when context lost event is fired
  29275. * @param callback defines the callback to call
  29276. */
  29277. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29278. /**
  29279. * Attach a new callback raised when context restored event is fired
  29280. * @param callback defines the callback to call
  29281. */
  29282. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29283. /**
  29284. * Gets the source code of the vertex shader associated with a specific webGL program
  29285. * @param program defines the program to use
  29286. * @returns a string containing the source code of the vertex shader associated with the program
  29287. */
  29288. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29289. /**
  29290. * Gets the source code of the fragment shader associated with a specific webGL program
  29291. * @param program defines the program to use
  29292. * @returns a string containing the source code of the fragment shader associated with the program
  29293. */
  29294. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29295. /**
  29296. * Get the current error code of the webGL context
  29297. * @returns the error code
  29298. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29299. */
  29300. getError(): number;
  29301. /**
  29302. * Gets the current framerate
  29303. * @returns a number representing the framerate
  29304. */
  29305. getFps(): number;
  29306. /**
  29307. * Gets the time spent between current and previous frame
  29308. * @returns a number representing the delta time in ms
  29309. */
  29310. getDeltaTime(): number;
  29311. private _measureFps;
  29312. /** @hidden */
  29313. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29314. private _canRenderToFloatFramebuffer;
  29315. private _canRenderToHalfFloatFramebuffer;
  29316. private _canRenderToFramebuffer;
  29317. /** @hidden */
  29318. _getWebGLTextureType(type: number): number;
  29319. private _getInternalFormat;
  29320. /** @hidden */
  29321. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29322. /** @hidden */
  29323. _getRGBAMultiSampleBufferFormat(type: number): number;
  29324. /** @hidden */
  29325. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  29326. /** @hidden */
  29327. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29328. private _partialLoadFile;
  29329. private _cascadeLoadFiles;
  29330. /**
  29331. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29332. * @returns true if the engine can be created
  29333. * @ignorenaming
  29334. */
  29335. static isSupported(): boolean;
  29336. }
  29337. }
  29338. declare module "babylonjs/Materials/effect" {
  29339. import { Observable } from "babylonjs/Misc/observable";
  29340. import { Nullable } from "babylonjs/types";
  29341. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  29342. import { Engine } from "babylonjs/Engines/engine";
  29343. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29344. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29345. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29346. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29347. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29348. /**
  29349. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29350. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29351. */
  29352. export class EffectFallbacks {
  29353. private _defines;
  29354. private _currentRank;
  29355. private _maxRank;
  29356. private _mesh;
  29357. /**
  29358. * Removes the fallback from the bound mesh.
  29359. */
  29360. unBindMesh(): void;
  29361. /**
  29362. * Adds a fallback on the specified property.
  29363. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29364. * @param define The name of the define in the shader
  29365. */
  29366. addFallback(rank: number, define: string): void;
  29367. /**
  29368. * Sets the mesh to use CPU skinning when needing to fallback.
  29369. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29370. * @param mesh The mesh to use the fallbacks.
  29371. */
  29372. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29373. /**
  29374. * Checks to see if more fallbacks are still availible.
  29375. */
  29376. readonly isMoreFallbacks: boolean;
  29377. /**
  29378. * Removes the defines that shoould be removed when falling back.
  29379. * @param currentDefines defines the current define statements for the shader.
  29380. * @param effect defines the current effect we try to compile
  29381. * @returns The resulting defines with defines of the current rank removed.
  29382. */
  29383. reduce(currentDefines: string, effect: Effect): string;
  29384. }
  29385. /**
  29386. * Options to be used when creating an effect.
  29387. */
  29388. export class EffectCreationOptions {
  29389. /**
  29390. * Atrributes that will be used in the shader.
  29391. */
  29392. attributes: string[];
  29393. /**
  29394. * Uniform varible names that will be set in the shader.
  29395. */
  29396. uniformsNames: string[];
  29397. /**
  29398. * Uniform buffer varible names that will be set in the shader.
  29399. */
  29400. uniformBuffersNames: string[];
  29401. /**
  29402. * Sampler texture variable names that will be set in the shader.
  29403. */
  29404. samplers: string[];
  29405. /**
  29406. * Define statements that will be set in the shader.
  29407. */
  29408. defines: any;
  29409. /**
  29410. * Possible fallbacks for this effect to improve performance when needed.
  29411. */
  29412. fallbacks: Nullable<EffectFallbacks>;
  29413. /**
  29414. * Callback that will be called when the shader is compiled.
  29415. */
  29416. onCompiled: Nullable<(effect: Effect) => void>;
  29417. /**
  29418. * Callback that will be called if an error occurs during shader compilation.
  29419. */
  29420. onError: Nullable<(effect: Effect, errors: string) => void>;
  29421. /**
  29422. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29423. */
  29424. indexParameters: any;
  29425. /**
  29426. * Max number of lights that can be used in the shader.
  29427. */
  29428. maxSimultaneousLights: number;
  29429. /**
  29430. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29431. */
  29432. transformFeedbackVaryings: Nullable<string[]>;
  29433. }
  29434. /**
  29435. * Effect containing vertex and fragment shader that can be executed on an object.
  29436. */
  29437. export class Effect {
  29438. /**
  29439. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29440. */
  29441. static ShadersRepository: string;
  29442. /**
  29443. * Name of the effect.
  29444. */
  29445. name: any;
  29446. /**
  29447. * String container all the define statements that should be set on the shader.
  29448. */
  29449. defines: string;
  29450. /**
  29451. * Callback that will be called when the shader is compiled.
  29452. */
  29453. onCompiled: Nullable<(effect: Effect) => void>;
  29454. /**
  29455. * Callback that will be called if an error occurs during shader compilation.
  29456. */
  29457. onError: Nullable<(effect: Effect, errors: string) => void>;
  29458. /**
  29459. * Callback that will be called when effect is bound.
  29460. */
  29461. onBind: Nullable<(effect: Effect) => void>;
  29462. /**
  29463. * Unique ID of the effect.
  29464. */
  29465. uniqueId: number;
  29466. /**
  29467. * Observable that will be called when the shader is compiled.
  29468. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29469. */
  29470. onCompileObservable: Observable<Effect>;
  29471. /**
  29472. * Observable that will be called if an error occurs during shader compilation.
  29473. */
  29474. onErrorObservable: Observable<Effect>;
  29475. /** @hidden */
  29476. _onBindObservable: Nullable<Observable<Effect>>;
  29477. /**
  29478. * Observable that will be called when effect is bound.
  29479. */
  29480. readonly onBindObservable: Observable<Effect>;
  29481. /** @hidden */
  29482. _bonesComputationForcedToCPU: boolean;
  29483. private static _uniqueIdSeed;
  29484. private _engine;
  29485. private _uniformBuffersNames;
  29486. private _uniformsNames;
  29487. private _samplers;
  29488. private _isReady;
  29489. private _compilationError;
  29490. private _attributesNames;
  29491. private _attributes;
  29492. private _uniforms;
  29493. /**
  29494. * Key for the effect.
  29495. * @hidden
  29496. */
  29497. _key: string;
  29498. private _indexParameters;
  29499. private _fallbacks;
  29500. private _vertexSourceCode;
  29501. private _fragmentSourceCode;
  29502. private _vertexSourceCodeOverride;
  29503. private _fragmentSourceCodeOverride;
  29504. private _transformFeedbackVaryings;
  29505. /**
  29506. * Compiled shader to webGL program.
  29507. * @hidden
  29508. */
  29509. _program: WebGLProgram;
  29510. private _valueCache;
  29511. private static _baseCache;
  29512. /**
  29513. * Instantiates an effect.
  29514. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29515. * @param baseName Name of the effect.
  29516. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29517. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29518. * @param samplers List of sampler variables that will be passed to the shader.
  29519. * @param engine Engine to be used to render the effect
  29520. * @param defines Define statements to be added to the shader.
  29521. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29522. * @param onCompiled Callback that will be called when the shader is compiled.
  29523. * @param onError Callback that will be called if an error occurs during shader compilation.
  29524. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29525. */
  29526. 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);
  29527. /**
  29528. * Unique key for this effect
  29529. */
  29530. readonly key: string;
  29531. /**
  29532. * If the effect has been compiled and prepared.
  29533. * @returns if the effect is compiled and prepared.
  29534. */
  29535. isReady(): boolean;
  29536. /**
  29537. * The engine the effect was initialized with.
  29538. * @returns the engine.
  29539. */
  29540. getEngine(): Engine;
  29541. /**
  29542. * The compiled webGL program for the effect
  29543. * @returns the webGL program.
  29544. */
  29545. getProgram(): WebGLProgram;
  29546. /**
  29547. * The set of names of attribute variables for the shader.
  29548. * @returns An array of attribute names.
  29549. */
  29550. getAttributesNames(): string[];
  29551. /**
  29552. * Returns the attribute at the given index.
  29553. * @param index The index of the attribute.
  29554. * @returns The location of the attribute.
  29555. */
  29556. getAttributeLocation(index: number): number;
  29557. /**
  29558. * Returns the attribute based on the name of the variable.
  29559. * @param name of the attribute to look up.
  29560. * @returns the attribute location.
  29561. */
  29562. getAttributeLocationByName(name: string): number;
  29563. /**
  29564. * The number of attributes.
  29565. * @returns the numnber of attributes.
  29566. */
  29567. getAttributesCount(): number;
  29568. /**
  29569. * Gets the index of a uniform variable.
  29570. * @param uniformName of the uniform to look up.
  29571. * @returns the index.
  29572. */
  29573. getUniformIndex(uniformName: string): number;
  29574. /**
  29575. * Returns the attribute based on the name of the variable.
  29576. * @param uniformName of the uniform to look up.
  29577. * @returns the location of the uniform.
  29578. */
  29579. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29580. /**
  29581. * Returns an array of sampler variable names
  29582. * @returns The array of sampler variable neames.
  29583. */
  29584. getSamplers(): string[];
  29585. /**
  29586. * The error from the last compilation.
  29587. * @returns the error string.
  29588. */
  29589. getCompilationError(): string;
  29590. /**
  29591. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29592. * @param func The callback to be used.
  29593. */
  29594. executeWhenCompiled(func: (effect: Effect) => void): void;
  29595. private _checkIsReady;
  29596. /** @hidden */
  29597. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29598. /** @hidden */
  29599. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29600. /** @hidden */
  29601. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29602. private _processShaderConversion;
  29603. private _processIncludes;
  29604. private _processPrecision;
  29605. /**
  29606. * Recompiles the webGL program
  29607. * @param vertexSourceCode The source code for the vertex shader.
  29608. * @param fragmentSourceCode The source code for the fragment shader.
  29609. * @param onCompiled Callback called when completed.
  29610. * @param onError Callback called on error.
  29611. * @hidden
  29612. */
  29613. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  29614. /**
  29615. * Gets the uniform locations of the the specified variable names
  29616. * @param names THe names of the variables to lookup.
  29617. * @returns Array of locations in the same order as variable names.
  29618. */
  29619. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  29620. /**
  29621. * Prepares the effect
  29622. * @hidden
  29623. */
  29624. _prepareEffect(): void;
  29625. /**
  29626. * Checks if the effect is supported. (Must be called after compilation)
  29627. */
  29628. readonly isSupported: boolean;
  29629. /**
  29630. * Binds a texture to the engine to be used as output of the shader.
  29631. * @param channel Name of the output variable.
  29632. * @param texture Texture to bind.
  29633. * @hidden
  29634. */
  29635. _bindTexture(channel: string, texture: InternalTexture): void;
  29636. /**
  29637. * Sets a texture on the engine to be used in the shader.
  29638. * @param channel Name of the sampler variable.
  29639. * @param texture Texture to set.
  29640. */
  29641. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29642. /**
  29643. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29644. * @param channel Name of the sampler variable.
  29645. * @param texture Texture to set.
  29646. */
  29647. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29648. /**
  29649. * Sets an array of textures on the engine to be used in the shader.
  29650. * @param channel Name of the variable.
  29651. * @param textures Textures to set.
  29652. */
  29653. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29654. /**
  29655. * 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)
  29656. * @param channel Name of the sampler variable.
  29657. * @param postProcess Post process to get the input texture from.
  29658. */
  29659. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29660. /**
  29661. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29662. * 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)
  29663. * @param channel Name of the sampler variable.
  29664. * @param postProcess Post process to get the output texture from.
  29665. */
  29666. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29667. /** @hidden */
  29668. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29669. /** @hidden */
  29670. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29671. /** @hidden */
  29672. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29673. /** @hidden */
  29674. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29675. /**
  29676. * Binds a buffer to a uniform.
  29677. * @param buffer Buffer to bind.
  29678. * @param name Name of the uniform variable to bind to.
  29679. */
  29680. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29681. /**
  29682. * Binds block to a uniform.
  29683. * @param blockName Name of the block to bind.
  29684. * @param index Index to bind.
  29685. */
  29686. bindUniformBlock(blockName: string, index: number): void;
  29687. /**
  29688. * Sets an interger value on a uniform variable.
  29689. * @param uniformName Name of the variable.
  29690. * @param value Value to be set.
  29691. * @returns this effect.
  29692. */
  29693. setInt(uniformName: string, value: number): Effect;
  29694. /**
  29695. * Sets an int array on a uniform variable.
  29696. * @param uniformName Name of the variable.
  29697. * @param array array to be set.
  29698. * @returns this effect.
  29699. */
  29700. setIntArray(uniformName: string, array: Int32Array): Effect;
  29701. /**
  29702. * 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)
  29703. * @param uniformName Name of the variable.
  29704. * @param array array to be set.
  29705. * @returns this effect.
  29706. */
  29707. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29708. /**
  29709. * 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)
  29710. * @param uniformName Name of the variable.
  29711. * @param array array to be set.
  29712. * @returns this effect.
  29713. */
  29714. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29715. /**
  29716. * 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)
  29717. * @param uniformName Name of the variable.
  29718. * @param array array to be set.
  29719. * @returns this effect.
  29720. */
  29721. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29722. /**
  29723. * Sets an float array on a uniform variable.
  29724. * @param uniformName Name of the variable.
  29725. * @param array array to be set.
  29726. * @returns this effect.
  29727. */
  29728. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29729. /**
  29730. * 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)
  29731. * @param uniformName Name of the variable.
  29732. * @param array array to be set.
  29733. * @returns this effect.
  29734. */
  29735. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29736. /**
  29737. * 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)
  29738. * @param uniformName Name of the variable.
  29739. * @param array array to be set.
  29740. * @returns this effect.
  29741. */
  29742. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29743. /**
  29744. * 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)
  29745. * @param uniformName Name of the variable.
  29746. * @param array array to be set.
  29747. * @returns this effect.
  29748. */
  29749. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29750. /**
  29751. * Sets an array on a uniform variable.
  29752. * @param uniformName Name of the variable.
  29753. * @param array array to be set.
  29754. * @returns this effect.
  29755. */
  29756. setArray(uniformName: string, array: number[]): Effect;
  29757. /**
  29758. * 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)
  29759. * @param uniformName Name of the variable.
  29760. * @param array array to be set.
  29761. * @returns this effect.
  29762. */
  29763. setArray2(uniformName: string, array: number[]): Effect;
  29764. /**
  29765. * 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)
  29766. * @param uniformName Name of the variable.
  29767. * @param array array to be set.
  29768. * @returns this effect.
  29769. */
  29770. setArray3(uniformName: string, array: number[]): Effect;
  29771. /**
  29772. * 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)
  29773. * @param uniformName Name of the variable.
  29774. * @param array array to be set.
  29775. * @returns this effect.
  29776. */
  29777. setArray4(uniformName: string, array: number[]): Effect;
  29778. /**
  29779. * Sets matrices on a uniform variable.
  29780. * @param uniformName Name of the variable.
  29781. * @param matrices matrices to be set.
  29782. * @returns this effect.
  29783. */
  29784. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29785. /**
  29786. * Sets matrix on a uniform variable.
  29787. * @param uniformName Name of the variable.
  29788. * @param matrix matrix to be set.
  29789. * @returns this effect.
  29790. */
  29791. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29792. /**
  29793. * 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)
  29794. * @param uniformName Name of the variable.
  29795. * @param matrix matrix to be set.
  29796. * @returns this effect.
  29797. */
  29798. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29799. /**
  29800. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29801. * @param uniformName Name of the variable.
  29802. * @param matrix matrix to be set.
  29803. * @returns this effect.
  29804. */
  29805. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29806. /**
  29807. * Sets a float on a uniform variable.
  29808. * @param uniformName Name of the variable.
  29809. * @param value value to be set.
  29810. * @returns this effect.
  29811. */
  29812. setFloat(uniformName: string, value: number): Effect;
  29813. /**
  29814. * Sets a boolean on a uniform variable.
  29815. * @param uniformName Name of the variable.
  29816. * @param bool value to be set.
  29817. * @returns this effect.
  29818. */
  29819. setBool(uniformName: string, bool: boolean): Effect;
  29820. /**
  29821. * Sets a Vector2 on a uniform variable.
  29822. * @param uniformName Name of the variable.
  29823. * @param vector2 vector2 to be set.
  29824. * @returns this effect.
  29825. */
  29826. setVector2(uniformName: string, vector2: Vector2): Effect;
  29827. /**
  29828. * Sets a float2 on a uniform variable.
  29829. * @param uniformName Name of the variable.
  29830. * @param x First float in float2.
  29831. * @param y Second float in float2.
  29832. * @returns this effect.
  29833. */
  29834. setFloat2(uniformName: string, x: number, y: number): Effect;
  29835. /**
  29836. * Sets a Vector3 on a uniform variable.
  29837. * @param uniformName Name of the variable.
  29838. * @param vector3 Value to be set.
  29839. * @returns this effect.
  29840. */
  29841. setVector3(uniformName: string, vector3: Vector3): Effect;
  29842. /**
  29843. * Sets a float3 on a uniform variable.
  29844. * @param uniformName Name of the variable.
  29845. * @param x First float in float3.
  29846. * @param y Second float in float3.
  29847. * @param z Third float in float3.
  29848. * @returns this effect.
  29849. */
  29850. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29851. /**
  29852. * Sets a Vector4 on a uniform variable.
  29853. * @param uniformName Name of the variable.
  29854. * @param vector4 Value to be set.
  29855. * @returns this effect.
  29856. */
  29857. setVector4(uniformName: string, vector4: Vector4): Effect;
  29858. /**
  29859. * Sets a float4 on a uniform variable.
  29860. * @param uniformName Name of the variable.
  29861. * @param x First float in float4.
  29862. * @param y Second float in float4.
  29863. * @param z Third float in float4.
  29864. * @param w Fourth float in float4.
  29865. * @returns this effect.
  29866. */
  29867. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29868. /**
  29869. * Sets a Color3 on a uniform variable.
  29870. * @param uniformName Name of the variable.
  29871. * @param color3 Value to be set.
  29872. * @returns this effect.
  29873. */
  29874. setColor3(uniformName: string, color3: Color3): Effect;
  29875. /**
  29876. * Sets a Color4 on a uniform variable.
  29877. * @param uniformName Name of the variable.
  29878. * @param color3 Value to be set.
  29879. * @param alpha Alpha value to be set.
  29880. * @returns this effect.
  29881. */
  29882. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29883. /**
  29884. * Sets a Color4 on a uniform variable
  29885. * @param uniformName defines the name of the variable
  29886. * @param color4 defines the value to be set
  29887. * @returns this effect.
  29888. */
  29889. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29890. /**
  29891. * This function will add a new shader to the shader store
  29892. * @param name the name of the shader
  29893. * @param pixelShader optional pixel shader content
  29894. * @param vertexShader optional vertex shader content
  29895. */
  29896. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29897. /**
  29898. * Store of each shader (The can be looked up using effect.key)
  29899. */
  29900. static ShadersStore: {
  29901. [key: string]: string;
  29902. };
  29903. /**
  29904. * Store of each included file for a shader (The can be looked up using effect.key)
  29905. */
  29906. static IncludesShadersStore: {
  29907. [key: string]: string;
  29908. };
  29909. /**
  29910. * Resets the cache of effects.
  29911. */
  29912. static ResetCache(): void;
  29913. }
  29914. }
  29915. declare module "babylonjs/Materials/colorCurves" {
  29916. import { Effect } from "babylonjs/Materials/effect";
  29917. /**
  29918. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29919. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29920. * 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;
  29921. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29922. */
  29923. export class ColorCurves {
  29924. private _dirty;
  29925. private _tempColor;
  29926. private _globalCurve;
  29927. private _highlightsCurve;
  29928. private _midtonesCurve;
  29929. private _shadowsCurve;
  29930. private _positiveCurve;
  29931. private _negativeCurve;
  29932. private _globalHue;
  29933. private _globalDensity;
  29934. private _globalSaturation;
  29935. private _globalExposure;
  29936. /**
  29937. * Gets the global Hue value.
  29938. * 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).
  29939. */
  29940. /**
  29941. * Sets the global Hue value.
  29942. * 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).
  29943. */
  29944. globalHue: number;
  29945. /**
  29946. * Gets the global Density value.
  29947. * 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.
  29948. * Values less than zero provide a filter of opposite hue.
  29949. */
  29950. /**
  29951. * Sets the global Density value.
  29952. * 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.
  29953. * Values less than zero provide a filter of opposite hue.
  29954. */
  29955. globalDensity: number;
  29956. /**
  29957. * Gets the global Saturation value.
  29958. * 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.
  29959. */
  29960. /**
  29961. * Sets the global Saturation value.
  29962. * 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.
  29963. */
  29964. globalSaturation: number;
  29965. /**
  29966. * Gets the global Exposure value.
  29967. * 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.
  29968. */
  29969. /**
  29970. * Sets the global Exposure value.
  29971. * 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.
  29972. */
  29973. globalExposure: number;
  29974. private _highlightsHue;
  29975. private _highlightsDensity;
  29976. private _highlightsSaturation;
  29977. private _highlightsExposure;
  29978. /**
  29979. * Gets the highlights Hue value.
  29980. * 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).
  29981. */
  29982. /**
  29983. * Sets the highlights Hue value.
  29984. * 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).
  29985. */
  29986. highlightsHue: number;
  29987. /**
  29988. * Gets the highlights Density value.
  29989. * 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.
  29990. * Values less than zero provide a filter of opposite hue.
  29991. */
  29992. /**
  29993. * Sets the highlights Density value.
  29994. * 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.
  29995. * Values less than zero provide a filter of opposite hue.
  29996. */
  29997. highlightsDensity: number;
  29998. /**
  29999. * Gets the highlights Saturation value.
  30000. * 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.
  30001. */
  30002. /**
  30003. * Sets the highlights Saturation value.
  30004. * 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.
  30005. */
  30006. highlightsSaturation: number;
  30007. /**
  30008. * Gets the highlights Exposure value.
  30009. * 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.
  30010. */
  30011. /**
  30012. * Sets the highlights Exposure value.
  30013. * 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.
  30014. */
  30015. highlightsExposure: number;
  30016. private _midtonesHue;
  30017. private _midtonesDensity;
  30018. private _midtonesSaturation;
  30019. private _midtonesExposure;
  30020. /**
  30021. * Gets the midtones Hue value.
  30022. * 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).
  30023. */
  30024. /**
  30025. * Sets the midtones Hue value.
  30026. * 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).
  30027. */
  30028. midtonesHue: number;
  30029. /**
  30030. * Gets the midtones Density value.
  30031. * 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.
  30032. * Values less than zero provide a filter of opposite hue.
  30033. */
  30034. /**
  30035. * Sets the midtones Density value.
  30036. * 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.
  30037. * Values less than zero provide a filter of opposite hue.
  30038. */
  30039. midtonesDensity: number;
  30040. /**
  30041. * Gets the midtones Saturation value.
  30042. * 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.
  30043. */
  30044. /**
  30045. * Sets the midtones Saturation value.
  30046. * 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.
  30047. */
  30048. midtonesSaturation: number;
  30049. /**
  30050. * Gets the midtones Exposure value.
  30051. * 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.
  30052. */
  30053. /**
  30054. * Sets the midtones Exposure value.
  30055. * 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.
  30056. */
  30057. midtonesExposure: number;
  30058. private _shadowsHue;
  30059. private _shadowsDensity;
  30060. private _shadowsSaturation;
  30061. private _shadowsExposure;
  30062. /**
  30063. * Gets the shadows Hue value.
  30064. * 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).
  30065. */
  30066. /**
  30067. * Sets the shadows Hue value.
  30068. * 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).
  30069. */
  30070. shadowsHue: number;
  30071. /**
  30072. * Gets the shadows Density value.
  30073. * 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.
  30074. * Values less than zero provide a filter of opposite hue.
  30075. */
  30076. /**
  30077. * Sets the shadows Density value.
  30078. * 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.
  30079. * Values less than zero provide a filter of opposite hue.
  30080. */
  30081. shadowsDensity: number;
  30082. /**
  30083. * Gets the shadows Saturation value.
  30084. * 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.
  30085. */
  30086. /**
  30087. * Sets the shadows Saturation value.
  30088. * 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.
  30089. */
  30090. shadowsSaturation: number;
  30091. /**
  30092. * Gets the shadows Exposure value.
  30093. * 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.
  30094. */
  30095. /**
  30096. * Sets the shadows Exposure value.
  30097. * 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.
  30098. */
  30099. shadowsExposure: number;
  30100. /**
  30101. * Returns the class name
  30102. * @returns The class name
  30103. */
  30104. getClassName(): string;
  30105. /**
  30106. * Binds the color curves to the shader.
  30107. * @param colorCurves The color curve to bind
  30108. * @param effect The effect to bind to
  30109. * @param positiveUniform The positive uniform shader parameter
  30110. * @param neutralUniform The neutral uniform shader parameter
  30111. * @param negativeUniform The negative uniform shader parameter
  30112. */
  30113. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30114. /**
  30115. * Prepare the list of uniforms associated with the ColorCurves effects.
  30116. * @param uniformsList The list of uniforms used in the effect
  30117. */
  30118. static PrepareUniforms(uniformsList: string[]): void;
  30119. /**
  30120. * Returns color grading data based on a hue, density, saturation and exposure value.
  30121. * @param filterHue The hue of the color filter.
  30122. * @param filterDensity The density of the color filter.
  30123. * @param saturation The saturation.
  30124. * @param exposure The exposure.
  30125. * @param result The result data container.
  30126. */
  30127. private getColorGradingDataToRef;
  30128. /**
  30129. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30130. * @param value The input slider value in range [-100,100].
  30131. * @returns Adjusted value.
  30132. */
  30133. private static applyColorGradingSliderNonlinear;
  30134. /**
  30135. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30136. * @param hue The hue (H) input.
  30137. * @param saturation The saturation (S) input.
  30138. * @param brightness The brightness (B) input.
  30139. * @result An RGBA color represented as Vector4.
  30140. */
  30141. private static fromHSBToRef;
  30142. /**
  30143. * Returns a value clamped between min and max
  30144. * @param value The value to clamp
  30145. * @param min The minimum of value
  30146. * @param max The maximum of value
  30147. * @returns The clamped value.
  30148. */
  30149. private static clamp;
  30150. /**
  30151. * Clones the current color curve instance.
  30152. * @return The cloned curves
  30153. */
  30154. clone(): ColorCurves;
  30155. /**
  30156. * Serializes the current color curve instance to a json representation.
  30157. * @return a JSON representation
  30158. */
  30159. serialize(): any;
  30160. /**
  30161. * Parses the color curve from a json representation.
  30162. * @param source the JSON source to parse
  30163. * @return The parsed curves
  30164. */
  30165. static Parse(source: any): ColorCurves;
  30166. }
  30167. }
  30168. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30169. import { Observable } from "babylonjs/Misc/observable";
  30170. import { Nullable } from "babylonjs/types";
  30171. import { Color4 } from "babylonjs/Maths/math";
  30172. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30173. import { Effect } from "babylonjs/Materials/effect";
  30174. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30175. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30176. /**
  30177. * Interface to follow in your material defines to integrate easily the
  30178. * Image proccessing functions.
  30179. * @hidden
  30180. */
  30181. export interface IImageProcessingConfigurationDefines {
  30182. IMAGEPROCESSING: boolean;
  30183. VIGNETTE: boolean;
  30184. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30185. VIGNETTEBLENDMODEOPAQUE: boolean;
  30186. TONEMAPPING: boolean;
  30187. TONEMAPPING_ACES: boolean;
  30188. CONTRAST: boolean;
  30189. EXPOSURE: boolean;
  30190. COLORCURVES: boolean;
  30191. COLORGRADING: boolean;
  30192. COLORGRADING3D: boolean;
  30193. SAMPLER3DGREENDEPTH: boolean;
  30194. SAMPLER3DBGRMAP: boolean;
  30195. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30196. }
  30197. /**
  30198. * @hidden
  30199. */
  30200. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30201. IMAGEPROCESSING: boolean;
  30202. VIGNETTE: boolean;
  30203. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30204. VIGNETTEBLENDMODEOPAQUE: boolean;
  30205. TONEMAPPING: boolean;
  30206. TONEMAPPING_ACES: boolean;
  30207. CONTRAST: boolean;
  30208. COLORCURVES: boolean;
  30209. COLORGRADING: boolean;
  30210. COLORGRADING3D: boolean;
  30211. SAMPLER3DGREENDEPTH: boolean;
  30212. SAMPLER3DBGRMAP: boolean;
  30213. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30214. EXPOSURE: boolean;
  30215. constructor();
  30216. }
  30217. /**
  30218. * This groups together the common properties used for image processing either in direct forward pass
  30219. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30220. * or not.
  30221. */
  30222. export class ImageProcessingConfiguration {
  30223. /**
  30224. * Default tone mapping applied in BabylonJS.
  30225. */
  30226. static readonly TONEMAPPING_STANDARD: number;
  30227. /**
  30228. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30229. * to other engines rendering to increase portability.
  30230. */
  30231. static readonly TONEMAPPING_ACES: number;
  30232. /**
  30233. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30234. */
  30235. colorCurves: Nullable<ColorCurves>;
  30236. private _colorCurvesEnabled;
  30237. /**
  30238. * Gets wether the color curves effect is enabled.
  30239. */
  30240. /**
  30241. * Sets wether the color curves effect is enabled.
  30242. */
  30243. colorCurvesEnabled: boolean;
  30244. private _colorGradingTexture;
  30245. /**
  30246. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30247. */
  30248. /**
  30249. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30250. */
  30251. colorGradingTexture: Nullable<BaseTexture>;
  30252. private _colorGradingEnabled;
  30253. /**
  30254. * Gets wether the color grading effect is enabled.
  30255. */
  30256. /**
  30257. * Sets wether the color grading effect is enabled.
  30258. */
  30259. colorGradingEnabled: boolean;
  30260. private _colorGradingWithGreenDepth;
  30261. /**
  30262. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30263. */
  30264. /**
  30265. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30266. */
  30267. colorGradingWithGreenDepth: boolean;
  30268. private _colorGradingBGR;
  30269. /**
  30270. * Gets wether the color grading texture contains BGR values.
  30271. */
  30272. /**
  30273. * Sets wether the color grading texture contains BGR values.
  30274. */
  30275. colorGradingBGR: boolean;
  30276. /** @hidden */
  30277. _exposure: number;
  30278. /**
  30279. * Gets the Exposure used in the effect.
  30280. */
  30281. /**
  30282. * Sets the Exposure used in the effect.
  30283. */
  30284. exposure: number;
  30285. private _toneMappingEnabled;
  30286. /**
  30287. * Gets wether the tone mapping effect is enabled.
  30288. */
  30289. /**
  30290. * Sets wether the tone mapping effect is enabled.
  30291. */
  30292. toneMappingEnabled: boolean;
  30293. private _toneMappingType;
  30294. /**
  30295. * Gets the type of tone mapping effect.
  30296. */
  30297. /**
  30298. * Sets the type of tone mapping effect used in BabylonJS.
  30299. */
  30300. toneMappingType: number;
  30301. protected _contrast: number;
  30302. /**
  30303. * Gets the contrast used in the effect.
  30304. */
  30305. /**
  30306. * Sets the contrast used in the effect.
  30307. */
  30308. contrast: number;
  30309. /**
  30310. * Vignette stretch size.
  30311. */
  30312. vignetteStretch: number;
  30313. /**
  30314. * Vignette centre X Offset.
  30315. */
  30316. vignetteCentreX: number;
  30317. /**
  30318. * Vignette centre Y Offset.
  30319. */
  30320. vignetteCentreY: number;
  30321. /**
  30322. * Vignette weight or intensity of the vignette effect.
  30323. */
  30324. vignetteWeight: number;
  30325. /**
  30326. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30327. * if vignetteEnabled is set to true.
  30328. */
  30329. vignetteColor: Color4;
  30330. /**
  30331. * Camera field of view used by the Vignette effect.
  30332. */
  30333. vignetteCameraFov: number;
  30334. private _vignetteBlendMode;
  30335. /**
  30336. * Gets the vignette blend mode allowing different kind of effect.
  30337. */
  30338. /**
  30339. * Sets the vignette blend mode allowing different kind of effect.
  30340. */
  30341. vignetteBlendMode: number;
  30342. private _vignetteEnabled;
  30343. /**
  30344. * Gets wether the vignette effect is enabled.
  30345. */
  30346. /**
  30347. * Sets wether the vignette effect is enabled.
  30348. */
  30349. vignetteEnabled: boolean;
  30350. private _applyByPostProcess;
  30351. /**
  30352. * Gets wether the image processing is applied through a post process or not.
  30353. */
  30354. /**
  30355. * Sets wether the image processing is applied through a post process or not.
  30356. */
  30357. applyByPostProcess: boolean;
  30358. private _isEnabled;
  30359. /**
  30360. * Gets wether the image processing is enabled or not.
  30361. */
  30362. /**
  30363. * Sets wether the image processing is enabled or not.
  30364. */
  30365. isEnabled: boolean;
  30366. /**
  30367. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30368. */
  30369. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30370. /**
  30371. * Method called each time the image processing information changes requires to recompile the effect.
  30372. */
  30373. protected _updateParameters(): void;
  30374. /**
  30375. * Gets the current class name.
  30376. * @return "ImageProcessingConfiguration"
  30377. */
  30378. getClassName(): string;
  30379. /**
  30380. * Prepare the list of uniforms associated with the Image Processing effects.
  30381. * @param uniforms The list of uniforms used in the effect
  30382. * @param defines the list of defines currently in use
  30383. */
  30384. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30385. /**
  30386. * Prepare the list of samplers associated with the Image Processing effects.
  30387. * @param samplersList The list of uniforms used in the effect
  30388. * @param defines the list of defines currently in use
  30389. */
  30390. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30391. /**
  30392. * Prepare the list of defines associated to the shader.
  30393. * @param defines the list of defines to complete
  30394. * @param forPostProcess Define if we are currently in post process mode or not
  30395. */
  30396. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30397. /**
  30398. * Returns true if all the image processing information are ready.
  30399. * @returns True if ready, otherwise, false
  30400. */
  30401. isReady(): boolean;
  30402. /**
  30403. * Binds the image processing to the shader.
  30404. * @param effect The effect to bind to
  30405. * @param aspectRatio Define the current aspect ratio of the effect
  30406. */
  30407. bind(effect: Effect, aspectRatio?: number): void;
  30408. /**
  30409. * Clones the current image processing instance.
  30410. * @return The cloned image processing
  30411. */
  30412. clone(): ImageProcessingConfiguration;
  30413. /**
  30414. * Serializes the current image processing instance to a json representation.
  30415. * @return a JSON representation
  30416. */
  30417. serialize(): any;
  30418. /**
  30419. * Parses the image processing from a json representation.
  30420. * @param source the JSON source to parse
  30421. * @return The parsed image processing
  30422. */
  30423. static Parse(source: any): ImageProcessingConfiguration;
  30424. private static _VIGNETTEMODE_MULTIPLY;
  30425. private static _VIGNETTEMODE_OPAQUE;
  30426. /**
  30427. * Used to apply the vignette as a mix with the pixel color.
  30428. */
  30429. static readonly VIGNETTEMODE_MULTIPLY: number;
  30430. /**
  30431. * Used to apply the vignette as a replacement of the pixel color.
  30432. */
  30433. static readonly VIGNETTEMODE_OPAQUE: number;
  30434. }
  30435. }
  30436. declare module "babylonjs/Materials/fresnelParameters" {
  30437. import { Color3 } from "babylonjs/Maths/math";
  30438. /**
  30439. * This represents all the required information to add a fresnel effect on a material:
  30440. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30441. */
  30442. export class FresnelParameters {
  30443. private _isEnabled;
  30444. /**
  30445. * Define if the fresnel effect is enable or not.
  30446. */
  30447. isEnabled: boolean;
  30448. /**
  30449. * Define the color used on edges (grazing angle)
  30450. */
  30451. leftColor: Color3;
  30452. /**
  30453. * Define the color used on center
  30454. */
  30455. rightColor: Color3;
  30456. /**
  30457. * Define bias applied to computed fresnel term
  30458. */
  30459. bias: number;
  30460. /**
  30461. * Defined the power exponent applied to fresnel term
  30462. */
  30463. power: number;
  30464. /**
  30465. * Clones the current fresnel and its valuues
  30466. * @returns a clone fresnel configuration
  30467. */
  30468. clone(): FresnelParameters;
  30469. /**
  30470. * Serializes the current fresnel parameters to a JSON representation.
  30471. * @return the JSON serialization
  30472. */
  30473. serialize(): any;
  30474. /**
  30475. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30476. * @param parsedFresnelParameters Define the JSON representation
  30477. * @returns the parsed parameters
  30478. */
  30479. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30480. }
  30481. }
  30482. declare module "babylonjs/Misc/decorators" {
  30483. import { Nullable } from "babylonjs/types";
  30484. import { Scene } from "babylonjs/scene";
  30485. import { IAnimatable } from "babylonjs/Misc/tools";
  30486. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30487. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30488. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30489. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30490. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30491. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30492. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30493. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30494. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30495. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30496. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30497. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30498. /**
  30499. * Decorator used to define property that can be serialized as reference to a camera
  30500. * @param sourceName defines the name of the property to decorate
  30501. */
  30502. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30503. /**
  30504. * Class used to help serialization objects
  30505. */
  30506. export class SerializationHelper {
  30507. /** hidden */
  30508. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30509. /** hidden */
  30510. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30511. /** hidden */
  30512. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30513. /** hidden */
  30514. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30515. /**
  30516. * Appends the serialized animations from the source animations
  30517. * @param source Source containing the animations
  30518. * @param destination Target to store the animations
  30519. */
  30520. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30521. /**
  30522. * Static function used to serialized a specific entity
  30523. * @param entity defines the entity to serialize
  30524. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30525. * @returns a JSON compatible object representing the serialization of the entity
  30526. */
  30527. static Serialize<T>(entity: T, serializationObject?: any): any;
  30528. /**
  30529. * Creates a new entity from a serialization data object
  30530. * @param creationFunction defines a function used to instanciated the new entity
  30531. * @param source defines the source serialization data
  30532. * @param scene defines the hosting scene
  30533. * @param rootUrl defines the root url for resources
  30534. * @returns a new entity
  30535. */
  30536. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30537. /**
  30538. * Clones an object
  30539. * @param creationFunction defines the function used to instanciate the new object
  30540. * @param source defines the source object
  30541. * @returns the cloned object
  30542. */
  30543. static Clone<T>(creationFunction: () => T, source: T): T;
  30544. /**
  30545. * Instanciates a new object based on a source one (some data will be shared between both object)
  30546. * @param creationFunction defines the function used to instanciate the new object
  30547. * @param source defines the source object
  30548. * @returns the new object
  30549. */
  30550. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30551. }
  30552. }
  30553. declare module "babylonjs/Cameras/camera" {
  30554. import { SmartArray } from "babylonjs/Misc/smartArray";
  30555. import { Observable } from "babylonjs/Misc/observable";
  30556. import { Nullable } from "babylonjs/types";
  30557. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30558. import { Scene } from "babylonjs/scene";
  30559. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30560. import { Node } from "babylonjs/node";
  30561. import { Mesh } from "babylonjs/Meshes/mesh";
  30562. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30563. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30564. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30565. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30566. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30567. import { Ray } from "babylonjs/Culling/ray";
  30568. /**
  30569. * This is the base class of all the camera used in the application.
  30570. * @see http://doc.babylonjs.com/features/cameras
  30571. */
  30572. export class Camera extends Node {
  30573. /** @hidden */
  30574. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30575. /**
  30576. * This is the default projection mode used by the cameras.
  30577. * It helps recreating a feeling of perspective and better appreciate depth.
  30578. * This is the best way to simulate real life cameras.
  30579. */
  30580. static readonly PERSPECTIVE_CAMERA: number;
  30581. /**
  30582. * This helps creating camera with an orthographic mode.
  30583. * 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.
  30584. */
  30585. static readonly ORTHOGRAPHIC_CAMERA: number;
  30586. /**
  30587. * This is the default FOV mode for perspective cameras.
  30588. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30589. */
  30590. static readonly FOVMODE_VERTICAL_FIXED: number;
  30591. /**
  30592. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30593. */
  30594. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30595. /**
  30596. * This specifies ther is no need for a camera rig.
  30597. * Basically only one eye is rendered corresponding to the camera.
  30598. */
  30599. static readonly RIG_MODE_NONE: number;
  30600. /**
  30601. * Simulates a camera Rig with one blue eye and one red eye.
  30602. * This can be use with 3d blue and red glasses.
  30603. */
  30604. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30605. /**
  30606. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30607. */
  30608. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30609. /**
  30610. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30611. */
  30612. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30613. /**
  30614. * Defines that both eyes of the camera will be rendered over under each other.
  30615. */
  30616. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30617. /**
  30618. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30619. */
  30620. static readonly RIG_MODE_VR: number;
  30621. /**
  30622. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30623. */
  30624. static readonly RIG_MODE_WEBVR: number;
  30625. /**
  30626. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30627. */
  30628. static readonly RIG_MODE_CUSTOM: number;
  30629. /**
  30630. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30631. */
  30632. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30633. /**
  30634. * @hidden
  30635. * Might be removed once multiview will be a thing
  30636. */
  30637. static UseAlternateWebVRRendering: boolean;
  30638. /**
  30639. * Define the input manager associated with the camera.
  30640. */
  30641. inputs: CameraInputsManager<Camera>;
  30642. /** @hidden */
  30643. _position: Vector3;
  30644. /**
  30645. * Define the current local position of the camera in the scene
  30646. */
  30647. position: Vector3;
  30648. /**
  30649. * The vector the camera should consider as up.
  30650. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30651. */
  30652. upVector: Vector3;
  30653. /**
  30654. * Define the current limit on the left side for an orthographic camera
  30655. * In scene unit
  30656. */
  30657. orthoLeft: Nullable<number>;
  30658. /**
  30659. * Define the current limit on the right side for an orthographic camera
  30660. * In scene unit
  30661. */
  30662. orthoRight: Nullable<number>;
  30663. /**
  30664. * Define the current limit on the bottom side for an orthographic camera
  30665. * In scene unit
  30666. */
  30667. orthoBottom: Nullable<number>;
  30668. /**
  30669. * Define the current limit on the top side for an orthographic camera
  30670. * In scene unit
  30671. */
  30672. orthoTop: Nullable<number>;
  30673. /**
  30674. * Field Of View is set in Radians. (default is 0.8)
  30675. */
  30676. fov: number;
  30677. /**
  30678. * Define the minimum distance the camera can see from.
  30679. * This is important to note that the depth buffer are not infinite and the closer it starts
  30680. * the more your scene might encounter depth fighting issue.
  30681. */
  30682. minZ: number;
  30683. /**
  30684. * Define the maximum distance the camera can see to.
  30685. * This is important to note that the depth buffer are not infinite and the further it end
  30686. * the more your scene might encounter depth fighting issue.
  30687. */
  30688. maxZ: number;
  30689. /**
  30690. * Define the default inertia of the camera.
  30691. * This helps giving a smooth feeling to the camera movement.
  30692. */
  30693. inertia: number;
  30694. /**
  30695. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30696. */
  30697. mode: number;
  30698. /**
  30699. * Define wether the camera is intermediate.
  30700. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30701. */
  30702. isIntermediate: boolean;
  30703. /**
  30704. * Define the viewport of the camera.
  30705. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30706. */
  30707. viewport: Viewport;
  30708. /**
  30709. * Restricts the camera to viewing objects with the same layerMask.
  30710. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30711. */
  30712. layerMask: number;
  30713. /**
  30714. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30715. */
  30716. fovMode: number;
  30717. /**
  30718. * Rig mode of the camera.
  30719. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30720. * This is normally controlled byt the camera themselves as internal use.
  30721. */
  30722. cameraRigMode: number;
  30723. /**
  30724. * Defines the distance between both "eyes" in case of a RIG
  30725. */
  30726. interaxialDistance: number;
  30727. /**
  30728. * Defines if stereoscopic rendering is done side by side or over under.
  30729. */
  30730. isStereoscopicSideBySide: boolean;
  30731. /**
  30732. * 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
  30733. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30734. * else in the scene.
  30735. */
  30736. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30737. /**
  30738. * When set, the camera will render to this render target instead of the default canvas
  30739. */
  30740. outputRenderTarget: Nullable<RenderTargetTexture>;
  30741. /**
  30742. * Observable triggered when the camera view matrix has changed.
  30743. */
  30744. onViewMatrixChangedObservable: Observable<Camera>;
  30745. /**
  30746. * Observable triggered when the camera Projection matrix has changed.
  30747. */
  30748. onProjectionMatrixChangedObservable: Observable<Camera>;
  30749. /**
  30750. * Observable triggered when the inputs have been processed.
  30751. */
  30752. onAfterCheckInputsObservable: Observable<Camera>;
  30753. /**
  30754. * Observable triggered when reset has been called and applied to the camera.
  30755. */
  30756. onRestoreStateObservable: Observable<Camera>;
  30757. /** @hidden */
  30758. _cameraRigParams: any;
  30759. /** @hidden */
  30760. _rigCameras: Camera[];
  30761. /** @hidden */
  30762. _rigPostProcess: Nullable<PostProcess>;
  30763. protected _webvrViewMatrix: Matrix;
  30764. /** @hidden */
  30765. _skipRendering: boolean;
  30766. /** @hidden */
  30767. _alternateCamera: Camera;
  30768. /** @hidden */
  30769. _projectionMatrix: Matrix;
  30770. /** @hidden */
  30771. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30772. /** @hidden */
  30773. _activeMeshes: SmartArray<AbstractMesh>;
  30774. protected _globalPosition: Vector3;
  30775. /** hidden */
  30776. _computedViewMatrix: Matrix;
  30777. private _doNotComputeProjectionMatrix;
  30778. private _transformMatrix;
  30779. private _frustumPlanes;
  30780. private _refreshFrustumPlanes;
  30781. private _storedFov;
  30782. private _stateStored;
  30783. /**
  30784. * Instantiates a new camera object.
  30785. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30786. * @see http://doc.babylonjs.com/features/cameras
  30787. * @param name Defines the name of the camera in the scene
  30788. * @param position Defines the position of the camera
  30789. * @param scene Defines the scene the camera belongs too
  30790. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30791. */
  30792. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30793. /**
  30794. * Store current camera state (fov, position, etc..)
  30795. * @returns the camera
  30796. */
  30797. storeState(): Camera;
  30798. /**
  30799. * Restores the camera state values if it has been stored. You must call storeState() first
  30800. */
  30801. protected _restoreStateValues(): boolean;
  30802. /**
  30803. * Restored camera state. You must call storeState() first.
  30804. * @returns true if restored and false otherwise
  30805. */
  30806. restoreState(): boolean;
  30807. /**
  30808. * Gets the class name of the camera.
  30809. * @returns the class name
  30810. */
  30811. getClassName(): string;
  30812. /** @hidden */
  30813. readonly _isCamera: boolean;
  30814. /**
  30815. * Gets a string representation of the camera useful for debug purpose.
  30816. * @param fullDetails Defines that a more verboe level of logging is required
  30817. * @returns the string representation
  30818. */
  30819. toString(fullDetails?: boolean): string;
  30820. /**
  30821. * Gets the current world space position of the camera.
  30822. */
  30823. readonly globalPosition: Vector3;
  30824. /**
  30825. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30826. * @returns the active meshe list
  30827. */
  30828. getActiveMeshes(): SmartArray<AbstractMesh>;
  30829. /**
  30830. * Check wether a mesh is part of the current active mesh list of the camera
  30831. * @param mesh Defines the mesh to check
  30832. * @returns true if active, false otherwise
  30833. */
  30834. isActiveMesh(mesh: Mesh): boolean;
  30835. /**
  30836. * Is this camera ready to be used/rendered
  30837. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30838. * @return true if the camera is ready
  30839. */
  30840. isReady(completeCheck?: boolean): boolean;
  30841. /** @hidden */
  30842. _initCache(): void;
  30843. /** @hidden */
  30844. _updateCache(ignoreParentClass?: boolean): void;
  30845. /** @hidden */
  30846. _isSynchronized(): boolean;
  30847. /** @hidden */
  30848. _isSynchronizedViewMatrix(): boolean;
  30849. /** @hidden */
  30850. _isSynchronizedProjectionMatrix(): boolean;
  30851. /**
  30852. * Attach the input controls to a specific dom element to get the input from.
  30853. * @param element Defines the element the controls should be listened from
  30854. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30855. */
  30856. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30857. /**
  30858. * Detach the current controls from the specified dom element.
  30859. * @param element Defines the element to stop listening the inputs from
  30860. */
  30861. detachControl(element: HTMLElement): void;
  30862. /**
  30863. * Update the camera state according to the different inputs gathered during the frame.
  30864. */
  30865. update(): void;
  30866. /** @hidden */
  30867. _checkInputs(): void;
  30868. /** @hidden */
  30869. readonly rigCameras: Camera[];
  30870. /**
  30871. * Gets the post process used by the rig cameras
  30872. */
  30873. readonly rigPostProcess: Nullable<PostProcess>;
  30874. /**
  30875. * Internal, gets the first post proces.
  30876. * @returns the first post process to be run on this camera.
  30877. */
  30878. _getFirstPostProcess(): Nullable<PostProcess>;
  30879. private _cascadePostProcessesToRigCams;
  30880. /**
  30881. * Attach a post process to the camera.
  30882. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30883. * @param postProcess The post process to attach to the camera
  30884. * @param insertAt The position of the post process in case several of them are in use in the scene
  30885. * @returns the position the post process has been inserted at
  30886. */
  30887. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30888. /**
  30889. * Detach a post process to the camera.
  30890. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30891. * @param postProcess The post process to detach from the camera
  30892. */
  30893. detachPostProcess(postProcess: PostProcess): void;
  30894. /**
  30895. * Gets the current world matrix of the camera
  30896. */
  30897. getWorldMatrix(): Matrix;
  30898. /** @hidden */
  30899. _getViewMatrix(): Matrix;
  30900. /**
  30901. * Gets the current view matrix of the camera.
  30902. * @param force forces the camera to recompute the matrix without looking at the cached state
  30903. * @returns the view matrix
  30904. */
  30905. getViewMatrix(force?: boolean): Matrix;
  30906. /**
  30907. * Freeze the projection matrix.
  30908. * It will prevent the cache check of the camera projection compute and can speed up perf
  30909. * if no parameter of the camera are meant to change
  30910. * @param projection Defines manually a projection if necessary
  30911. */
  30912. freezeProjectionMatrix(projection?: Matrix): void;
  30913. /**
  30914. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30915. */
  30916. unfreezeProjectionMatrix(): void;
  30917. /**
  30918. * Gets the current projection matrix of the camera.
  30919. * @param force forces the camera to recompute the matrix without looking at the cached state
  30920. * @returns the projection matrix
  30921. */
  30922. getProjectionMatrix(force?: boolean): Matrix;
  30923. /**
  30924. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30925. * @returns a Matrix
  30926. */
  30927. getTransformationMatrix(): Matrix;
  30928. private _updateFrustumPlanes;
  30929. /**
  30930. * Checks if a cullable object (mesh...) is in the camera frustum
  30931. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30932. * @param target The object to check
  30933. * @returns true if the object is in frustum otherwise false
  30934. */
  30935. isInFrustum(target: ICullable): boolean;
  30936. /**
  30937. * Checks if a cullable object (mesh...) is in the camera frustum
  30938. * Unlike isInFrustum this cheks the full bounding box
  30939. * @param target The object to check
  30940. * @returns true if the object is in frustum otherwise false
  30941. */
  30942. isCompletelyInFrustum(target: ICullable): boolean;
  30943. /**
  30944. * Gets a ray in the forward direction from the camera.
  30945. * @param length Defines the length of the ray to create
  30946. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30947. * @param origin Defines the start point of the ray which defaults to the camera position
  30948. * @returns the forward ray
  30949. */
  30950. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30951. /**
  30952. * Releases resources associated with this node.
  30953. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30954. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30955. */
  30956. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30957. /** @hidden */
  30958. _isLeftCamera: boolean;
  30959. /**
  30960. * Gets the left camera of a rig setup in case of Rigged Camera
  30961. */
  30962. readonly isLeftCamera: boolean;
  30963. /** @hidden */
  30964. _isRightCamera: boolean;
  30965. /**
  30966. * Gets the right camera of a rig setup in case of Rigged Camera
  30967. */
  30968. readonly isRightCamera: boolean;
  30969. /**
  30970. * Gets the left camera of a rig setup in case of Rigged Camera
  30971. */
  30972. readonly leftCamera: Nullable<FreeCamera>;
  30973. /**
  30974. * Gets the right camera of a rig setup in case of Rigged Camera
  30975. */
  30976. readonly rightCamera: Nullable<FreeCamera>;
  30977. /**
  30978. * Gets the left camera target of a rig setup in case of Rigged Camera
  30979. * @returns the target position
  30980. */
  30981. getLeftTarget(): Nullable<Vector3>;
  30982. /**
  30983. * Gets the right camera target of a rig setup in case of Rigged Camera
  30984. * @returns the target position
  30985. */
  30986. getRightTarget(): Nullable<Vector3>;
  30987. /**
  30988. * @hidden
  30989. */
  30990. setCameraRigMode(mode: number, rigParams: any): void;
  30991. /** @hidden */
  30992. static _setStereoscopicRigMode(camera: Camera): void;
  30993. /** @hidden */
  30994. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30995. /** @hidden */
  30996. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30997. /** @hidden */
  30998. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30999. /** @hidden */
  31000. _getVRProjectionMatrix(): Matrix;
  31001. protected _updateCameraRotationMatrix(): void;
  31002. protected _updateWebVRCameraRotationMatrix(): void;
  31003. /**
  31004. * This function MUST be overwritten by the different WebVR cameras available.
  31005. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31006. * @hidden
  31007. */
  31008. _getWebVRProjectionMatrix(): Matrix;
  31009. /**
  31010. * This function MUST be overwritten by the different WebVR cameras available.
  31011. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31012. * @hidden
  31013. */
  31014. _getWebVRViewMatrix(): Matrix;
  31015. /** @hidden */
  31016. setCameraRigParameter(name: string, value: any): void;
  31017. /**
  31018. * needs to be overridden by children so sub has required properties to be copied
  31019. * @hidden
  31020. */
  31021. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31022. /**
  31023. * May need to be overridden by children
  31024. * @hidden
  31025. */
  31026. _updateRigCameras(): void;
  31027. /** @hidden */
  31028. _setupInputs(): void;
  31029. /**
  31030. * Serialiaze the camera setup to a json represention
  31031. * @returns the JSON representation
  31032. */
  31033. serialize(): any;
  31034. /**
  31035. * Clones the current camera.
  31036. * @param name The cloned camera name
  31037. * @returns the cloned camera
  31038. */
  31039. clone(name: string): Camera;
  31040. /**
  31041. * Gets the direction of the camera relative to a given local axis.
  31042. * @param localAxis Defines the reference axis to provide a relative direction.
  31043. * @return the direction
  31044. */
  31045. getDirection(localAxis: Vector3): Vector3;
  31046. /**
  31047. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31048. * @param localAxis Defines the reference axis to provide a relative direction.
  31049. * @param result Defines the vector to store the result in
  31050. */
  31051. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31052. /**
  31053. * Gets a camera constructor for a given camera type
  31054. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31055. * @param name The name of the camera the result will be able to instantiate
  31056. * @param scene The scene the result will construct the camera in
  31057. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31058. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31059. * @returns a factory method to construc the camera
  31060. */
  31061. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31062. /**
  31063. * Compute the world matrix of the camera.
  31064. * @returns the camera workd matrix
  31065. */
  31066. computeWorldMatrix(): Matrix;
  31067. /**
  31068. * Parse a JSON and creates the camera from the parsed information
  31069. * @param parsedCamera The JSON to parse
  31070. * @param scene The scene to instantiate the camera in
  31071. * @returns the newly constructed camera
  31072. */
  31073. static Parse(parsedCamera: any, scene: Scene): Camera;
  31074. }
  31075. }
  31076. declare module "babylonjs/Misc/tools" {
  31077. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31078. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31079. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31080. import { Observable } from "babylonjs/Misc/observable";
  31081. import { DomManagement } from "babylonjs/Misc/domManagement";
  31082. import { WebRequest } from "babylonjs/Misc/webRequest";
  31083. import { Camera } from "babylonjs/Cameras/camera";
  31084. import { Engine } from "babylonjs/Engines/engine";
  31085. import { Animation } from "babylonjs/Animations/animation";
  31086. /**
  31087. * Interface for any object that can request an animation frame
  31088. */
  31089. export interface ICustomAnimationFrameRequester {
  31090. /**
  31091. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31092. */
  31093. renderFunction?: Function;
  31094. /**
  31095. * Called to request the next frame to render to
  31096. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31097. */
  31098. requestAnimationFrame: Function;
  31099. /**
  31100. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31101. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31102. */
  31103. requestID?: number;
  31104. }
  31105. /**
  31106. * Interface containing an array of animations
  31107. */
  31108. export interface IAnimatable {
  31109. /**
  31110. * Array of animations
  31111. */
  31112. animations: Array<Animation>;
  31113. }
  31114. /** Interface used by value gradients (color, factor, ...) */
  31115. export interface IValueGradient {
  31116. /**
  31117. * Gets or sets the gradient value (between 0 and 1)
  31118. */
  31119. gradient: number;
  31120. }
  31121. /** Class used to store color4 gradient */
  31122. export class ColorGradient implements IValueGradient {
  31123. /**
  31124. * Gets or sets the gradient value (between 0 and 1)
  31125. */
  31126. gradient: number;
  31127. /**
  31128. * Gets or sets first associated color
  31129. */
  31130. color1: Color4;
  31131. /**
  31132. * Gets or sets second associated color
  31133. */
  31134. color2?: Color4;
  31135. /**
  31136. * Will get a color picked randomly between color1 and color2.
  31137. * If color2 is undefined then color1 will be used
  31138. * @param result defines the target Color4 to store the result in
  31139. */
  31140. getColorToRef(result: Color4): void;
  31141. }
  31142. /** Class used to store color 3 gradient */
  31143. export class Color3Gradient implements IValueGradient {
  31144. /**
  31145. * Gets or sets the gradient value (between 0 and 1)
  31146. */
  31147. gradient: number;
  31148. /**
  31149. * Gets or sets the associated color
  31150. */
  31151. color: Color3;
  31152. }
  31153. /** Class used to store factor gradient */
  31154. export class FactorGradient implements IValueGradient {
  31155. /**
  31156. * Gets or sets the gradient value (between 0 and 1)
  31157. */
  31158. gradient: number;
  31159. /**
  31160. * Gets or sets first associated factor
  31161. */
  31162. factor1: number;
  31163. /**
  31164. * Gets or sets second associated factor
  31165. */
  31166. factor2?: number;
  31167. /**
  31168. * Will get a number picked randomly between factor1 and factor2.
  31169. * If factor2 is undefined then factor1 will be used
  31170. * @returns the picked number
  31171. */
  31172. getFactor(): number;
  31173. }
  31174. /**
  31175. * @ignore
  31176. * Application error to support additional information when loading a file
  31177. */
  31178. export class LoadFileError extends Error {
  31179. /** defines the optional web request */
  31180. request?: WebRequest | undefined;
  31181. private static _setPrototypeOf;
  31182. /**
  31183. * Creates a new LoadFileError
  31184. * @param message defines the message of the error
  31185. * @param request defines the optional web request
  31186. */
  31187. constructor(message: string,
  31188. /** defines the optional web request */
  31189. request?: WebRequest | undefined);
  31190. }
  31191. /**
  31192. * Class used to define a retry strategy when error happens while loading assets
  31193. */
  31194. export class RetryStrategy {
  31195. /**
  31196. * Function used to defines an exponential back off strategy
  31197. * @param maxRetries defines the maximum number of retries (3 by default)
  31198. * @param baseInterval defines the interval between retries
  31199. * @returns the strategy function to use
  31200. */
  31201. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31202. }
  31203. /**
  31204. * File request interface
  31205. */
  31206. export interface IFileRequest {
  31207. /**
  31208. * Raised when the request is complete (success or error).
  31209. */
  31210. onCompleteObservable: Observable<IFileRequest>;
  31211. /**
  31212. * Aborts the request for a file.
  31213. */
  31214. abort: () => void;
  31215. }
  31216. /**
  31217. * Class containing a set of static utilities functions
  31218. */
  31219. export class Tools {
  31220. /**
  31221. * Gets or sets the base URL to use to load assets
  31222. */
  31223. static BaseUrl: string;
  31224. /**
  31225. * Enable/Disable Custom HTTP Request Headers globally.
  31226. * default = false
  31227. * @see CustomRequestHeaders
  31228. */
  31229. static UseCustomRequestHeaders: boolean;
  31230. /**
  31231. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31232. * i.e. when loading files, where the server/service expects an Authorization header
  31233. */
  31234. static CustomRequestHeaders: {
  31235. [key: string]: string;
  31236. };
  31237. /**
  31238. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31239. */
  31240. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31241. /**
  31242. * Default behaviour for cors in the application.
  31243. * It can be a string if the expected behavior is identical in the entire app.
  31244. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31245. */
  31246. static CorsBehavior: string | ((url: string | string[]) => string);
  31247. /**
  31248. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31249. * @ignorenaming
  31250. */
  31251. static UseFallbackTexture: boolean;
  31252. /**
  31253. * Use this object to register external classes like custom textures or material
  31254. * to allow the laoders to instantiate them
  31255. */
  31256. static RegisteredExternalClasses: {
  31257. [key: string]: Object;
  31258. };
  31259. /**
  31260. * Texture content used if a texture cannot loaded
  31261. * @ignorenaming
  31262. */
  31263. static fallbackTexture: string;
  31264. /**
  31265. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31266. * @param u defines the coordinate on X axis
  31267. * @param v defines the coordinate on Y axis
  31268. * @param width defines the width of the source data
  31269. * @param height defines the height of the source data
  31270. * @param pixels defines the source byte array
  31271. * @param color defines the output color
  31272. */
  31273. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31274. /**
  31275. * Interpolates between a and b via alpha
  31276. * @param a The lower value (returned when alpha = 0)
  31277. * @param b The upper value (returned when alpha = 1)
  31278. * @param alpha The interpolation-factor
  31279. * @return The mixed value
  31280. */
  31281. static Mix(a: number, b: number, alpha: number): number;
  31282. /**
  31283. * Tries to instantiate a new object from a given class name
  31284. * @param className defines the class name to instantiate
  31285. * @returns the new object or null if the system was not able to do the instantiation
  31286. */
  31287. static Instantiate(className: string): any;
  31288. /**
  31289. * Provides a slice function that will work even on IE
  31290. * @param data defines the array to slice
  31291. * @param start defines the start of the data (optional)
  31292. * @param end defines the end of the data (optional)
  31293. * @returns the new sliced array
  31294. */
  31295. static Slice<T>(data: T, start?: number, end?: number): T;
  31296. /**
  31297. * Polyfill for setImmediate
  31298. * @param action defines the action to execute after the current execution block
  31299. */
  31300. static SetImmediate(action: () => void): void;
  31301. /**
  31302. * Function indicating if a number is an exponent of 2
  31303. * @param value defines the value to test
  31304. * @returns true if the value is an exponent of 2
  31305. */
  31306. static IsExponentOfTwo(value: number): boolean;
  31307. private static _tmpFloatArray;
  31308. /**
  31309. * Returns the nearest 32-bit single precision float representation of a Number
  31310. * @param value A Number. If the parameter is of a different type, it will get converted
  31311. * to a number or to NaN if it cannot be converted
  31312. * @returns number
  31313. */
  31314. static FloatRound(value: number): number;
  31315. /**
  31316. * Find the next highest power of two.
  31317. * @param x Number to start search from.
  31318. * @return Next highest power of two.
  31319. */
  31320. static CeilingPOT(x: number): number;
  31321. /**
  31322. * Find the next lowest power of two.
  31323. * @param x Number to start search from.
  31324. * @return Next lowest power of two.
  31325. */
  31326. static FloorPOT(x: number): number;
  31327. /**
  31328. * Find the nearest power of two.
  31329. * @param x Number to start search from.
  31330. * @return Next nearest power of two.
  31331. */
  31332. static NearestPOT(x: number): number;
  31333. /**
  31334. * Get the closest exponent of two
  31335. * @param value defines the value to approximate
  31336. * @param max defines the maximum value to return
  31337. * @param mode defines how to define the closest value
  31338. * @returns closest exponent of two of the given value
  31339. */
  31340. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31341. /**
  31342. * Extracts the filename from a path
  31343. * @param path defines the path to use
  31344. * @returns the filename
  31345. */
  31346. static GetFilename(path: string): string;
  31347. /**
  31348. * Extracts the "folder" part of a path (everything before the filename).
  31349. * @param uri The URI to extract the info from
  31350. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31351. * @returns The "folder" part of the path
  31352. */
  31353. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31354. /**
  31355. * Extracts text content from a DOM element hierarchy
  31356. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31357. */
  31358. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31359. /**
  31360. * Convert an angle in radians to degrees
  31361. * @param angle defines the angle to convert
  31362. * @returns the angle in degrees
  31363. */
  31364. static ToDegrees(angle: number): number;
  31365. /**
  31366. * Convert an angle in degrees to radians
  31367. * @param angle defines the angle to convert
  31368. * @returns the angle in radians
  31369. */
  31370. static ToRadians(angle: number): number;
  31371. /**
  31372. * Encode a buffer to a base64 string
  31373. * @param buffer defines the buffer to encode
  31374. * @returns the encoded string
  31375. */
  31376. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31377. /**
  31378. * Extracts minimum and maximum values from a list of indexed positions
  31379. * @param positions defines the positions to use
  31380. * @param indices defines the indices to the positions
  31381. * @param indexStart defines the start index
  31382. * @param indexCount defines the end index
  31383. * @param bias defines bias value to add to the result
  31384. * @return minimum and maximum values
  31385. */
  31386. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31387. minimum: Vector3;
  31388. maximum: Vector3;
  31389. };
  31390. /**
  31391. * Extracts minimum and maximum values from a list of positions
  31392. * @param positions defines the positions to use
  31393. * @param start defines the start index in the positions array
  31394. * @param count defines the number of positions to handle
  31395. * @param bias defines bias value to add to the result
  31396. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31397. * @return minimum and maximum values
  31398. */
  31399. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31400. minimum: Vector3;
  31401. maximum: Vector3;
  31402. };
  31403. /**
  31404. * Returns an array if obj is not an array
  31405. * @param obj defines the object to evaluate as an array
  31406. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31407. * @returns either obj directly if obj is an array or a new array containing obj
  31408. */
  31409. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31410. /**
  31411. * Gets the pointer prefix to use
  31412. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31413. */
  31414. static GetPointerPrefix(): string;
  31415. /**
  31416. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31417. * @param func - the function to be called
  31418. * @param requester - the object that will request the next frame. Falls back to window.
  31419. * @returns frame number
  31420. */
  31421. static QueueNewFrame(func: () => void, requester?: any): number;
  31422. /**
  31423. * Ask the browser to promote the current element to fullscreen rendering mode
  31424. * @param element defines the DOM element to promote
  31425. */
  31426. static RequestFullscreen(element: HTMLElement): void;
  31427. /**
  31428. * Asks the browser to exit fullscreen mode
  31429. */
  31430. static ExitFullscreen(): void;
  31431. /**
  31432. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31433. * @param url define the url we are trying
  31434. * @param element define the dom element where to configure the cors policy
  31435. */
  31436. static SetCorsBehavior(url: string | string[], element: {
  31437. crossOrigin: string | null;
  31438. }): void;
  31439. /**
  31440. * Removes unwanted characters from an url
  31441. * @param url defines the url to clean
  31442. * @returns the cleaned url
  31443. */
  31444. static CleanUrl(url: string): string;
  31445. /**
  31446. * Gets or sets a function used to pre-process url before using them to load assets
  31447. */
  31448. static PreprocessUrl: (url: string) => string;
  31449. /**
  31450. * Loads an image as an HTMLImageElement.
  31451. * @param input url string, ArrayBuffer, or Blob to load
  31452. * @param onLoad callback called when the image successfully loads
  31453. * @param onError callback called when the image fails to load
  31454. * @param offlineProvider offline provider for caching
  31455. * @returns the HTMLImageElement of the loaded image
  31456. */
  31457. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31458. /**
  31459. * Loads a file
  31460. * @param url url string, ArrayBuffer, or Blob to load
  31461. * @param onSuccess callback called when the file successfully loads
  31462. * @param onProgress callback called while file is loading (if the server supports this mode)
  31463. * @param offlineProvider defines the offline provider for caching
  31464. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31465. * @param onError callback called when the file fails to load
  31466. * @returns a file request object
  31467. */
  31468. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  31469. /**
  31470. * Load a script (identified by an url). When the url returns, the
  31471. * content of this file is added into a new script element, attached to the DOM (body element)
  31472. * @param scriptUrl defines the url of the script to laod
  31473. * @param onSuccess defines the callback called when the script is loaded
  31474. * @param onError defines the callback to call if an error occurs
  31475. */
  31476. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  31477. /**
  31478. * Loads a file from a blob
  31479. * @param fileToLoad defines the blob to use
  31480. * @param callback defines the callback to call when data is loaded
  31481. * @param progressCallback defines the callback to call during loading process
  31482. * @returns a file request object
  31483. */
  31484. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31485. /**
  31486. * Loads a file
  31487. * @param fileToLoad defines the file to load
  31488. * @param callback defines the callback to call when data is loaded
  31489. * @param progressCallBack defines the callback to call during loading process
  31490. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31491. * @returns a file request object
  31492. */
  31493. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31494. /**
  31495. * Creates a data url from a given string content
  31496. * @param content defines the content to convert
  31497. * @returns the new data url link
  31498. */
  31499. static FileAsURL(content: string): string;
  31500. /**
  31501. * Format the given number to a specific decimal format
  31502. * @param value defines the number to format
  31503. * @param decimals defines the number of decimals to use
  31504. * @returns the formatted string
  31505. */
  31506. static Format(value: number, decimals?: number): string;
  31507. /**
  31508. * Checks if a given vector is inside a specific range
  31509. * @param v defines the vector to test
  31510. * @param min defines the minimum range
  31511. * @param max defines the maximum range
  31512. */
  31513. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31514. /**
  31515. * Tries to copy an object by duplicating every property
  31516. * @param source defines the source object
  31517. * @param destination defines the target object
  31518. * @param doNotCopyList defines a list of properties to avoid
  31519. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31520. */
  31521. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31522. /**
  31523. * Gets a boolean indicating if the given object has no own property
  31524. * @param obj defines the object to test
  31525. * @returns true if object has no own property
  31526. */
  31527. static IsEmpty(obj: any): boolean;
  31528. /**
  31529. * Function used to register events at window level
  31530. * @param events defines the events to register
  31531. */
  31532. static RegisterTopRootEvents(events: {
  31533. name: string;
  31534. handler: Nullable<(e: FocusEvent) => any>;
  31535. }[]): void;
  31536. /**
  31537. * Function used to unregister events from window level
  31538. * @param events defines the events to unregister
  31539. */
  31540. static UnregisterTopRootEvents(events: {
  31541. name: string;
  31542. handler: Nullable<(e: FocusEvent) => any>;
  31543. }[]): void;
  31544. /**
  31545. * @ignore
  31546. */
  31547. static _ScreenshotCanvas: HTMLCanvasElement;
  31548. /**
  31549. * Dumps the current bound framebuffer
  31550. * @param width defines the rendering width
  31551. * @param height defines the rendering height
  31552. * @param engine defines the hosting engine
  31553. * @param successCallback defines the callback triggered once the data are available
  31554. * @param mimeType defines the mime type of the result
  31555. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31556. */
  31557. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31558. /**
  31559. * Converts the canvas data to blob.
  31560. * This acts as a polyfill for browsers not supporting the to blob function.
  31561. * @param canvas Defines the canvas to extract the data from
  31562. * @param successCallback Defines the callback triggered once the data are available
  31563. * @param mimeType Defines the mime type of the result
  31564. */
  31565. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31566. /**
  31567. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31568. * @param successCallback defines the callback triggered once the data are available
  31569. * @param mimeType defines the mime type of the result
  31570. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31571. */
  31572. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31573. /**
  31574. * Downloads a blob in the browser
  31575. * @param blob defines the blob to download
  31576. * @param fileName defines the name of the downloaded file
  31577. */
  31578. static Download(blob: Blob, fileName: string): void;
  31579. /**
  31580. * Captures a screenshot of the current rendering
  31581. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31582. * @param engine defines the rendering engine
  31583. * @param camera defines the source camera
  31584. * @param size This parameter can be set to a single number or to an object with the
  31585. * following (optional) properties: precision, width, height. If a single number is passed,
  31586. * it will be used for both width and height. If an object is passed, the screenshot size
  31587. * will be derived from the parameters. The precision property is a multiplier allowing
  31588. * rendering at a higher or lower resolution
  31589. * @param successCallback defines the callback receives a single parameter which contains the
  31590. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31591. * src parameter of an <img> to display it
  31592. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31593. * Check your browser for supported MIME types
  31594. */
  31595. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31596. /**
  31597. * Generates an image screenshot from the specified camera.
  31598. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31599. * @param engine The engine to use for rendering
  31600. * @param camera The camera to use for rendering
  31601. * @param size This parameter can be set to a single number or to an object with the
  31602. * following (optional) properties: precision, width, height. If a single number is passed,
  31603. * it will be used for both width and height. If an object is passed, the screenshot size
  31604. * will be derived from the parameters. The precision property is a multiplier allowing
  31605. * rendering at a higher or lower resolution
  31606. * @param successCallback The callback receives a single parameter which contains the
  31607. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31608. * src parameter of an <img> to display it
  31609. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31610. * Check your browser for supported MIME types
  31611. * @param samples Texture samples (default: 1)
  31612. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31613. * @param fileName A name for for the downloaded file.
  31614. */
  31615. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31616. /**
  31617. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31618. * Be aware Math.random() could cause collisions, but:
  31619. * "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"
  31620. * @returns a pseudo random id
  31621. */
  31622. static RandomId(): string;
  31623. /**
  31624. * Test if the given uri is a base64 string
  31625. * @param uri The uri to test
  31626. * @return True if the uri is a base64 string or false otherwise
  31627. */
  31628. static IsBase64(uri: string): boolean;
  31629. /**
  31630. * Decode the given base64 uri.
  31631. * @param uri The uri to decode
  31632. * @return The decoded base64 data.
  31633. */
  31634. static DecodeBase64(uri: string): ArrayBuffer;
  31635. /**
  31636. * No log
  31637. */
  31638. static readonly NoneLogLevel: number;
  31639. /**
  31640. * Only message logs
  31641. */
  31642. static readonly MessageLogLevel: number;
  31643. /**
  31644. * Only warning logs
  31645. */
  31646. static readonly WarningLogLevel: number;
  31647. /**
  31648. * Only error logs
  31649. */
  31650. static readonly ErrorLogLevel: number;
  31651. /**
  31652. * All logs
  31653. */
  31654. static readonly AllLogLevel: number;
  31655. /**
  31656. * Gets a value indicating the number of loading errors
  31657. * @ignorenaming
  31658. */
  31659. static readonly errorsCount: number;
  31660. /**
  31661. * Callback called when a new log is added
  31662. */
  31663. static OnNewCacheEntry: (entry: string) => void;
  31664. /**
  31665. * Log a message to the console
  31666. * @param message defines the message to log
  31667. */
  31668. static Log(message: string): void;
  31669. /**
  31670. * Write a warning message to the console
  31671. * @param message defines the message to log
  31672. */
  31673. static Warn(message: string): void;
  31674. /**
  31675. * Write an error message to the console
  31676. * @param message defines the message to log
  31677. */
  31678. static Error(message: string): void;
  31679. /**
  31680. * Gets current log cache (list of logs)
  31681. */
  31682. static readonly LogCache: string;
  31683. /**
  31684. * Clears the log cache
  31685. */
  31686. static ClearLogCache(): void;
  31687. /**
  31688. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31689. */
  31690. static LogLevels: number;
  31691. /**
  31692. * Checks if the loaded document was accessed via `file:`-Protocol.
  31693. * @returns boolean
  31694. */
  31695. static IsFileURL(): boolean;
  31696. /**
  31697. * Checks if the window object exists
  31698. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31699. */
  31700. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31701. /**
  31702. * No performance log
  31703. */
  31704. static readonly PerformanceNoneLogLevel: number;
  31705. /**
  31706. * Use user marks to log performance
  31707. */
  31708. static readonly PerformanceUserMarkLogLevel: number;
  31709. /**
  31710. * Log performance to the console
  31711. */
  31712. static readonly PerformanceConsoleLogLevel: number;
  31713. private static _performance;
  31714. /**
  31715. * Sets the current performance log level
  31716. */
  31717. static PerformanceLogLevel: number;
  31718. private static _StartPerformanceCounterDisabled;
  31719. private static _EndPerformanceCounterDisabled;
  31720. private static _StartUserMark;
  31721. private static _EndUserMark;
  31722. private static _StartPerformanceConsole;
  31723. private static _EndPerformanceConsole;
  31724. /**
  31725. * Starts a performance counter
  31726. */
  31727. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31728. /**
  31729. * Ends a specific performance coutner
  31730. */
  31731. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31732. /**
  31733. * Gets either window.performance.now() if supported or Date.now() else
  31734. */
  31735. static readonly Now: number;
  31736. /**
  31737. * This method will return the name of the class used to create the instance of the given object.
  31738. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31739. * @param object the object to get the class name from
  31740. * @param isType defines if the object is actually a type
  31741. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31742. */
  31743. static GetClassName(object: any, isType?: boolean): string;
  31744. /**
  31745. * Gets the first element of an array satisfying a given predicate
  31746. * @param array defines the array to browse
  31747. * @param predicate defines the predicate to use
  31748. * @returns null if not found or the element
  31749. */
  31750. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31751. /**
  31752. * This method will return the name of the full name of the class, including its owning module (if any).
  31753. * 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).
  31754. * @param object the object to get the class name from
  31755. * @param isType defines if the object is actually a type
  31756. * @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.
  31757. * @ignorenaming
  31758. */
  31759. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31760. /**
  31761. * Returns a promise that resolves after the given amount of time.
  31762. * @param delay Number of milliseconds to delay
  31763. * @returns Promise that resolves after the given amount of time
  31764. */
  31765. static DelayAsync(delay: number): Promise<void>;
  31766. /**
  31767. * Gets the current gradient from an array of IValueGradient
  31768. * @param ratio defines the current ratio to get
  31769. * @param gradients defines the array of IValueGradient
  31770. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31771. */
  31772. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31773. }
  31774. /**
  31775. * This class is used to track a performance counter which is number based.
  31776. * The user has access to many properties which give statistics of different nature.
  31777. *
  31778. * The implementer can track two kinds of Performance Counter: time and count.
  31779. * 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.
  31780. * 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.
  31781. */
  31782. export class PerfCounter {
  31783. /**
  31784. * Gets or sets a global boolean to turn on and off all the counters
  31785. */
  31786. static Enabled: boolean;
  31787. /**
  31788. * Returns the smallest value ever
  31789. */
  31790. readonly min: number;
  31791. /**
  31792. * Returns the biggest value ever
  31793. */
  31794. readonly max: number;
  31795. /**
  31796. * Returns the average value since the performance counter is running
  31797. */
  31798. readonly average: number;
  31799. /**
  31800. * Returns the average value of the last second the counter was monitored
  31801. */
  31802. readonly lastSecAverage: number;
  31803. /**
  31804. * Returns the current value
  31805. */
  31806. readonly current: number;
  31807. /**
  31808. * Gets the accumulated total
  31809. */
  31810. readonly total: number;
  31811. /**
  31812. * Gets the total value count
  31813. */
  31814. readonly count: number;
  31815. /**
  31816. * Creates a new counter
  31817. */
  31818. constructor();
  31819. /**
  31820. * Call this method to start monitoring a new frame.
  31821. * 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.
  31822. */
  31823. fetchNewFrame(): void;
  31824. /**
  31825. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31826. * @param newCount the count value to add to the monitored count
  31827. * @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.
  31828. */
  31829. addCount(newCount: number, fetchResult: boolean): void;
  31830. /**
  31831. * Start monitoring this performance counter
  31832. */
  31833. beginMonitoring(): void;
  31834. /**
  31835. * Compute the time lapsed since the previous beginMonitoring() call.
  31836. * @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
  31837. */
  31838. endMonitoring(newFrame?: boolean): void;
  31839. private _fetchResult;
  31840. private _startMonitoringTime;
  31841. private _min;
  31842. private _max;
  31843. private _average;
  31844. private _current;
  31845. private _totalValueCount;
  31846. private _totalAccumulated;
  31847. private _lastSecAverage;
  31848. private _lastSecAccumulated;
  31849. private _lastSecTime;
  31850. private _lastSecValueCount;
  31851. }
  31852. /**
  31853. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31854. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31855. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31856. * @param name The name of the class, case should be preserved
  31857. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31858. */
  31859. export function className(name: string, module?: string): (target: Object) => void;
  31860. /**
  31861. * An implementation of a loop for asynchronous functions.
  31862. */
  31863. export class AsyncLoop {
  31864. /**
  31865. * Defines the number of iterations for the loop
  31866. */
  31867. iterations: number;
  31868. /**
  31869. * Defines the current index of the loop.
  31870. */
  31871. index: number;
  31872. private _done;
  31873. private _fn;
  31874. private _successCallback;
  31875. /**
  31876. * Constructor.
  31877. * @param iterations the number of iterations.
  31878. * @param func the function to run each iteration
  31879. * @param successCallback the callback that will be called upon succesful execution
  31880. * @param offset starting offset.
  31881. */
  31882. constructor(
  31883. /**
  31884. * Defines the number of iterations for the loop
  31885. */
  31886. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31887. /**
  31888. * Execute the next iteration. Must be called after the last iteration was finished.
  31889. */
  31890. executeNext(): void;
  31891. /**
  31892. * Break the loop and run the success callback.
  31893. */
  31894. breakLoop(): void;
  31895. /**
  31896. * Create and run an async loop.
  31897. * @param iterations the number of iterations.
  31898. * @param fn the function to run each iteration
  31899. * @param successCallback the callback that will be called upon succesful execution
  31900. * @param offset starting offset.
  31901. * @returns the created async loop object
  31902. */
  31903. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31904. /**
  31905. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31906. * @param iterations total number of iterations
  31907. * @param syncedIterations number of synchronous iterations in each async iteration.
  31908. * @param fn the function to call each iteration.
  31909. * @param callback a success call back that will be called when iterating stops.
  31910. * @param breakFunction a break condition (optional)
  31911. * @param timeout timeout settings for the setTimeout function. default - 0.
  31912. * @returns the created async loop object
  31913. */
  31914. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31915. }
  31916. }
  31917. declare module "babylonjs/Collisions/collisionCoordinator" {
  31918. import { Nullable } from "babylonjs/types";
  31919. import { Scene } from "babylonjs/scene";
  31920. import { Vector3 } from "babylonjs/Maths/math";
  31921. import { Collider } from "babylonjs/Collisions/collider";
  31922. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31923. /** @hidden */
  31924. export interface ICollisionCoordinator {
  31925. createCollider(): Collider;
  31926. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31927. init(scene: Scene): void;
  31928. }
  31929. /** @hidden */
  31930. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31931. private _scene;
  31932. private _scaledPosition;
  31933. private _scaledVelocity;
  31934. private _finalPosition;
  31935. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31936. createCollider(): Collider;
  31937. init(scene: Scene): void;
  31938. private _collideWithWorld;
  31939. }
  31940. }
  31941. declare module "babylonjs/Animations/animationGroup" {
  31942. import { Animatable } from "babylonjs/Animations/animatable";
  31943. import { Animation } from "babylonjs/Animations/animation";
  31944. import { Scene, IDisposable } from "babylonjs/scene";
  31945. import { Observable } from "babylonjs/Misc/observable";
  31946. import { Nullable } from "babylonjs/types";
  31947. /**
  31948. * This class defines the direct association between an animation and a target
  31949. */
  31950. export class TargetedAnimation {
  31951. /**
  31952. * Animation to perform
  31953. */
  31954. animation: Animation;
  31955. /**
  31956. * Target to animate
  31957. */
  31958. target: any;
  31959. }
  31960. /**
  31961. * Use this class to create coordinated animations on multiple targets
  31962. */
  31963. export class AnimationGroup implements IDisposable {
  31964. /** The name of the animation group */
  31965. name: string;
  31966. private _scene;
  31967. private _targetedAnimations;
  31968. private _animatables;
  31969. private _from;
  31970. private _to;
  31971. private _isStarted;
  31972. private _isPaused;
  31973. private _speedRatio;
  31974. /**
  31975. * Gets or sets the unique id of the node
  31976. */
  31977. uniqueId: number;
  31978. /**
  31979. * This observable will notify when one animation have ended
  31980. */
  31981. onAnimationEndObservable: Observable<TargetedAnimation>;
  31982. /**
  31983. * Observer raised when one animation loops
  31984. */
  31985. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31986. /**
  31987. * This observable will notify when all animations have ended.
  31988. */
  31989. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31990. /**
  31991. * This observable will notify when all animations have paused.
  31992. */
  31993. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31994. /**
  31995. * This observable will notify when all animations are playing.
  31996. */
  31997. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31998. /**
  31999. * Gets the first frame
  32000. */
  32001. readonly from: number;
  32002. /**
  32003. * Gets the last frame
  32004. */
  32005. readonly to: number;
  32006. /**
  32007. * Define if the animations are started
  32008. */
  32009. readonly isStarted: boolean;
  32010. /**
  32011. * Gets a value indicating that the current group is playing
  32012. */
  32013. readonly isPlaying: boolean;
  32014. /**
  32015. * Gets or sets the speed ratio to use for all animations
  32016. */
  32017. /**
  32018. * Gets or sets the speed ratio to use for all animations
  32019. */
  32020. speedRatio: number;
  32021. /**
  32022. * Gets the targeted animations for this animation group
  32023. */
  32024. readonly targetedAnimations: Array<TargetedAnimation>;
  32025. /**
  32026. * returning the list of animatables controlled by this animation group.
  32027. */
  32028. readonly animatables: Array<Animatable>;
  32029. /**
  32030. * Instantiates a new Animation Group.
  32031. * This helps managing several animations at once.
  32032. * @see http://doc.babylonjs.com/how_to/group
  32033. * @param name Defines the name of the group
  32034. * @param scene Defines the scene the group belongs to
  32035. */
  32036. constructor(
  32037. /** The name of the animation group */
  32038. name: string, scene?: Nullable<Scene>);
  32039. /**
  32040. * Add an animation (with its target) in the group
  32041. * @param animation defines the animation we want to add
  32042. * @param target defines the target of the animation
  32043. * @returns the TargetedAnimation object
  32044. */
  32045. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32046. /**
  32047. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32048. * It can add constant keys at begin or end
  32049. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32050. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32051. * @returns the animation group
  32052. */
  32053. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32054. /**
  32055. * Start all animations on given targets
  32056. * @param loop defines if animations must loop
  32057. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32058. * @param from defines the from key (optional)
  32059. * @param to defines the to key (optional)
  32060. * @returns the current animation group
  32061. */
  32062. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32063. /**
  32064. * Pause all animations
  32065. * @returns the animation group
  32066. */
  32067. pause(): AnimationGroup;
  32068. /**
  32069. * Play all animations to initial state
  32070. * This function will start() the animations if they were not started or will restart() them if they were paused
  32071. * @param loop defines if animations must loop
  32072. * @returns the animation group
  32073. */
  32074. play(loop?: boolean): AnimationGroup;
  32075. /**
  32076. * Reset all animations to initial state
  32077. * @returns the animation group
  32078. */
  32079. reset(): AnimationGroup;
  32080. /**
  32081. * Restart animations from key 0
  32082. * @returns the animation group
  32083. */
  32084. restart(): AnimationGroup;
  32085. /**
  32086. * Stop all animations
  32087. * @returns the animation group
  32088. */
  32089. stop(): AnimationGroup;
  32090. /**
  32091. * Set animation weight for all animatables
  32092. * @param weight defines the weight to use
  32093. * @return the animationGroup
  32094. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32095. */
  32096. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32097. /**
  32098. * Synchronize and normalize all animatables with a source animatable
  32099. * @param root defines the root animatable to synchronize with
  32100. * @return the animationGroup
  32101. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32102. */
  32103. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32104. /**
  32105. * Goes to a specific frame in this animation group
  32106. * @param frame the frame number to go to
  32107. * @return the animationGroup
  32108. */
  32109. goToFrame(frame: number): AnimationGroup;
  32110. /**
  32111. * Dispose all associated resources
  32112. */
  32113. dispose(): void;
  32114. private _checkAnimationGroupEnded;
  32115. /**
  32116. * Clone the current animation group and returns a copy
  32117. * @param newName defines the name of the new group
  32118. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32119. * @returns the new aniamtion group
  32120. */
  32121. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32122. /**
  32123. * Returns a new AnimationGroup object parsed from the source provided.
  32124. * @param parsedAnimationGroup defines the source
  32125. * @param scene defines the scene that will receive the animationGroup
  32126. * @returns a new AnimationGroup
  32127. */
  32128. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32129. /**
  32130. * Returns the string "AnimationGroup"
  32131. * @returns "AnimationGroup"
  32132. */
  32133. getClassName(): string;
  32134. /**
  32135. * Creates a detailled string about the object
  32136. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32137. * @returns a string representing the object
  32138. */
  32139. toString(fullDetails?: boolean): string;
  32140. }
  32141. }
  32142. declare module "babylonjs/scene" {
  32143. import { Nullable } from "babylonjs/types";
  32144. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  32145. import { Observable } from "babylonjs/Misc/observable";
  32146. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  32147. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  32148. import { Geometry } from "babylonjs/Meshes/geometry";
  32149. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32150. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32151. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32152. import { Mesh } from "babylonjs/Meshes/mesh";
  32153. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32154. import { Bone } from "babylonjs/Bones/bone";
  32155. import { Skeleton } from "babylonjs/Bones/skeleton";
  32156. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  32157. import { Camera } from "babylonjs/Cameras/camera";
  32158. import { AbstractScene } from "babylonjs/abstractScene";
  32159. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32160. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32161. import { Material } from "babylonjs/Materials/material";
  32162. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  32163. import { Effect } from "babylonjs/Materials/effect";
  32164. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32165. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32166. import { Light } from "babylonjs/Lights/light";
  32167. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32168. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  32169. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  32170. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  32171. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32172. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  32173. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32174. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  32175. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction } from "babylonjs/sceneComponent";
  32176. import { Engine } from "babylonjs/Engines/engine";
  32177. import { Node } from "babylonjs/node";
  32178. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32179. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32180. import { WebRequest } from "babylonjs/Misc/webRequest";
  32181. import { Ray } from "babylonjs/Culling/ray";
  32182. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32183. import { Animation } from "babylonjs/Animations/animation";
  32184. import { Animatable } from "babylonjs/Animations/animatable";
  32185. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  32186. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32187. import { Collider } from "babylonjs/Collisions/collider";
  32188. /**
  32189. * Define an interface for all classes that will hold resources
  32190. */
  32191. export interface IDisposable {
  32192. /**
  32193. * Releases all held resources
  32194. */
  32195. dispose(): void;
  32196. }
  32197. /** Interface defining initialization parameters for Scene class */
  32198. export interface SceneOptions {
  32199. /**
  32200. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32201. * It will improve performance when the number of geometries becomes important.
  32202. */
  32203. useGeometryUniqueIdsMap?: boolean;
  32204. /**
  32205. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32206. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32207. */
  32208. useMaterialMeshMap?: boolean;
  32209. /**
  32210. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32211. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32212. */
  32213. useClonedMeshhMap?: boolean;
  32214. }
  32215. /**
  32216. * Represents a scene to be rendered by the engine.
  32217. * @see http://doc.babylonjs.com/features/scene
  32218. */
  32219. export class Scene extends AbstractScene implements IAnimatable {
  32220. private static _uniqueIdCounter;
  32221. /** The fog is deactivated */
  32222. static readonly FOGMODE_NONE: number;
  32223. /** The fog density is following an exponential function */
  32224. static readonly FOGMODE_EXP: number;
  32225. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32226. static readonly FOGMODE_EXP2: number;
  32227. /** The fog density is following a linear function. */
  32228. static readonly FOGMODE_LINEAR: number;
  32229. /**
  32230. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32231. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32232. */
  32233. static MinDeltaTime: number;
  32234. /**
  32235. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32236. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32237. */
  32238. static MaxDeltaTime: number;
  32239. /**
  32240. * Factory used to create the default material.
  32241. * @param name The name of the material to create
  32242. * @param scene The scene to create the material for
  32243. * @returns The default material
  32244. */
  32245. static DefaultMaterialFactory(scene: Scene): Material;
  32246. /**
  32247. * Factory used to create the a collision coordinator.
  32248. * @returns The collision coordinator
  32249. */
  32250. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32251. /** @hidden */
  32252. readonly _isScene: boolean;
  32253. /**
  32254. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32255. */
  32256. autoClear: boolean;
  32257. /**
  32258. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32259. */
  32260. autoClearDepthAndStencil: boolean;
  32261. /**
  32262. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32263. */
  32264. clearColor: Color4;
  32265. /**
  32266. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32267. */
  32268. ambientColor: Color3;
  32269. /** @hidden */
  32270. _environmentBRDFTexture: BaseTexture;
  32271. /** @hidden */
  32272. protected _environmentTexture: Nullable<BaseTexture>;
  32273. /**
  32274. * Texture used in all pbr material as the reflection texture.
  32275. * As in the majority of the scene they are the same (exception for multi room and so on),
  32276. * this is easier to reference from here than from all the materials.
  32277. */
  32278. /**
  32279. * Texture used in all pbr material as the reflection texture.
  32280. * As in the majority of the scene they are the same (exception for multi room and so on),
  32281. * this is easier to set here than in all the materials.
  32282. */
  32283. environmentTexture: Nullable<BaseTexture>;
  32284. /** @hidden */
  32285. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32286. /**
  32287. * Default image processing configuration used either in the rendering
  32288. * Forward main pass or through the imageProcessingPostProcess if present.
  32289. * As in the majority of the scene they are the same (exception for multi camera),
  32290. * this is easier to reference from here than from all the materials and post process.
  32291. *
  32292. * No setter as we it is a shared configuration, you can set the values instead.
  32293. */
  32294. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32295. private _forceWireframe;
  32296. /**
  32297. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32298. */
  32299. forceWireframe: boolean;
  32300. private _forcePointsCloud;
  32301. /**
  32302. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32303. */
  32304. forcePointsCloud: boolean;
  32305. /**
  32306. * Gets or sets the active clipplane 1
  32307. */
  32308. clipPlane: Nullable<Plane>;
  32309. /**
  32310. * Gets or sets the active clipplane 2
  32311. */
  32312. clipPlane2: Nullable<Plane>;
  32313. /**
  32314. * Gets or sets the active clipplane 3
  32315. */
  32316. clipPlane3: Nullable<Plane>;
  32317. /**
  32318. * Gets or sets the active clipplane 4
  32319. */
  32320. clipPlane4: Nullable<Plane>;
  32321. /**
  32322. * Gets or sets a boolean indicating if animations are enabled
  32323. */
  32324. animationsEnabled: boolean;
  32325. private _animationPropertiesOverride;
  32326. /**
  32327. * Gets or sets the animation properties override
  32328. */
  32329. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32330. /**
  32331. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32332. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32333. */
  32334. useConstantAnimationDeltaTime: boolean;
  32335. /**
  32336. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32337. * Please note that it requires to run a ray cast through the scene on every frame
  32338. */
  32339. constantlyUpdateMeshUnderPointer: boolean;
  32340. /**
  32341. * Defines the HTML cursor to use when hovering over interactive elements
  32342. */
  32343. hoverCursor: string;
  32344. /**
  32345. * Defines the HTML default cursor to use (empty by default)
  32346. */
  32347. defaultCursor: string;
  32348. /**
  32349. * This is used to call preventDefault() on pointer down
  32350. * in order to block unwanted artifacts like system double clicks
  32351. */
  32352. preventDefaultOnPointerDown: boolean;
  32353. /**
  32354. * This is used to call preventDefault() on pointer up
  32355. * in order to block unwanted artifacts like system double clicks
  32356. */
  32357. preventDefaultOnPointerUp: boolean;
  32358. /**
  32359. * Gets or sets user defined metadata
  32360. */
  32361. metadata: any;
  32362. /**
  32363. * For internal use only. Please do not use.
  32364. */
  32365. reservedDataStore: any;
  32366. /**
  32367. * Gets the name of the plugin used to load this scene (null by default)
  32368. */
  32369. loadingPluginName: string;
  32370. /**
  32371. * Use this array to add regular expressions used to disable offline support for specific urls
  32372. */
  32373. disableOfflineSupportExceptionRules: RegExp[];
  32374. /**
  32375. * An event triggered when the scene is disposed.
  32376. */
  32377. onDisposeObservable: Observable<Scene>;
  32378. private _onDisposeObserver;
  32379. /** Sets a function to be executed when this scene is disposed. */
  32380. onDispose: () => void;
  32381. /**
  32382. * An event triggered before rendering the scene (right after animations and physics)
  32383. */
  32384. onBeforeRenderObservable: Observable<Scene>;
  32385. private _onBeforeRenderObserver;
  32386. /** Sets a function to be executed before rendering this scene */
  32387. beforeRender: Nullable<() => void>;
  32388. /**
  32389. * An event triggered after rendering the scene
  32390. */
  32391. onAfterRenderObservable: Observable<Scene>;
  32392. private _onAfterRenderObserver;
  32393. /** Sets a function to be executed after rendering this scene */
  32394. afterRender: Nullable<() => void>;
  32395. /**
  32396. * An event triggered before animating the scene
  32397. */
  32398. onBeforeAnimationsObservable: Observable<Scene>;
  32399. /**
  32400. * An event triggered after animations processing
  32401. */
  32402. onAfterAnimationsObservable: Observable<Scene>;
  32403. /**
  32404. * An event triggered before draw calls are ready to be sent
  32405. */
  32406. onBeforeDrawPhaseObservable: Observable<Scene>;
  32407. /**
  32408. * An event triggered after draw calls have been sent
  32409. */
  32410. onAfterDrawPhaseObservable: Observable<Scene>;
  32411. /**
  32412. * An event triggered when the scene is ready
  32413. */
  32414. onReadyObservable: Observable<Scene>;
  32415. /**
  32416. * An event triggered before rendering a camera
  32417. */
  32418. onBeforeCameraRenderObservable: Observable<Camera>;
  32419. private _onBeforeCameraRenderObserver;
  32420. /** Sets a function to be executed before rendering a camera*/
  32421. beforeCameraRender: () => void;
  32422. /**
  32423. * An event triggered after rendering a camera
  32424. */
  32425. onAfterCameraRenderObservable: Observable<Camera>;
  32426. private _onAfterCameraRenderObserver;
  32427. /** Sets a function to be executed after rendering a camera*/
  32428. afterCameraRender: () => void;
  32429. /**
  32430. * An event triggered when active meshes evaluation is about to start
  32431. */
  32432. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32433. /**
  32434. * An event triggered when active meshes evaluation is done
  32435. */
  32436. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32437. /**
  32438. * An event triggered when particles rendering is about to start
  32439. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32440. */
  32441. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32442. /**
  32443. * An event triggered when particles rendering is done
  32444. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32445. */
  32446. onAfterParticlesRenderingObservable: Observable<Scene>;
  32447. /**
  32448. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32449. */
  32450. onDataLoadedObservable: Observable<Scene>;
  32451. /**
  32452. * An event triggered when a camera is created
  32453. */
  32454. onNewCameraAddedObservable: Observable<Camera>;
  32455. /**
  32456. * An event triggered when a camera is removed
  32457. */
  32458. onCameraRemovedObservable: Observable<Camera>;
  32459. /**
  32460. * An event triggered when a light is created
  32461. */
  32462. onNewLightAddedObservable: Observable<Light>;
  32463. /**
  32464. * An event triggered when a light is removed
  32465. */
  32466. onLightRemovedObservable: Observable<Light>;
  32467. /**
  32468. * An event triggered when a geometry is created
  32469. */
  32470. onNewGeometryAddedObservable: Observable<Geometry>;
  32471. /**
  32472. * An event triggered when a geometry is removed
  32473. */
  32474. onGeometryRemovedObservable: Observable<Geometry>;
  32475. /**
  32476. * An event triggered when a transform node is created
  32477. */
  32478. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32479. /**
  32480. * An event triggered when a transform node is removed
  32481. */
  32482. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32483. /**
  32484. * An event triggered when a mesh is created
  32485. */
  32486. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32487. /**
  32488. * An event triggered when a mesh is removed
  32489. */
  32490. onMeshRemovedObservable: Observable<AbstractMesh>;
  32491. /**
  32492. * An event triggered when a skeleton is created
  32493. */
  32494. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32495. /**
  32496. * An event triggered when a skeleton is removed
  32497. */
  32498. onSkeletonRemovedObservable: Observable<Skeleton>;
  32499. /**
  32500. * An event triggered when a material is created
  32501. */
  32502. onNewMaterialAddedObservable: Observable<Material>;
  32503. /**
  32504. * An event triggered when a material is removed
  32505. */
  32506. onMaterialRemovedObservable: Observable<Material>;
  32507. /**
  32508. * An event triggered when a texture is created
  32509. */
  32510. onNewTextureAddedObservable: Observable<BaseTexture>;
  32511. /**
  32512. * An event triggered when a texture is removed
  32513. */
  32514. onTextureRemovedObservable: Observable<BaseTexture>;
  32515. /**
  32516. * An event triggered when render targets are about to be rendered
  32517. * Can happen multiple times per frame.
  32518. */
  32519. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32520. /**
  32521. * An event triggered when render targets were rendered.
  32522. * Can happen multiple times per frame.
  32523. */
  32524. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32525. /**
  32526. * An event triggered before calculating deterministic simulation step
  32527. */
  32528. onBeforeStepObservable: Observable<Scene>;
  32529. /**
  32530. * An event triggered after calculating deterministic simulation step
  32531. */
  32532. onAfterStepObservable: Observable<Scene>;
  32533. /**
  32534. * An event triggered when the activeCamera property is updated
  32535. */
  32536. onActiveCameraChanged: Observable<Scene>;
  32537. /**
  32538. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32539. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32540. * 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)
  32541. */
  32542. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32543. /**
  32544. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32545. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32546. * 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)
  32547. */
  32548. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32549. /**
  32550. * This Observable will when a mesh has been imported into the scene.
  32551. */
  32552. onMeshImportedObservable: Observable<AbstractMesh>;
  32553. /**
  32554. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32555. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32556. */
  32557. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32558. /** @hidden */
  32559. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32560. /**
  32561. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32562. */
  32563. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32564. /**
  32565. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32566. */
  32567. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32568. /**
  32569. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32570. */
  32571. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32572. private _onPointerMove;
  32573. private _onPointerDown;
  32574. private _onPointerUp;
  32575. /** Callback called when a pointer move is detected */
  32576. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32577. /** Callback called when a pointer down is detected */
  32578. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32579. /** Callback called when a pointer up is detected */
  32580. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32581. /** Callback called when a pointer pick is detected */
  32582. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32583. /**
  32584. * 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).
  32585. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32586. */
  32587. onPrePointerObservable: Observable<PointerInfoPre>;
  32588. /**
  32589. * Observable event triggered each time an input event is received from the rendering canvas
  32590. */
  32591. onPointerObservable: Observable<PointerInfo>;
  32592. /**
  32593. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32594. */
  32595. readonly unTranslatedPointer: Vector2;
  32596. /** The distance in pixel that you have to move to prevent some events */
  32597. static DragMovementThreshold: number;
  32598. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32599. static LongPressDelay: number;
  32600. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32601. static DoubleClickDelay: number;
  32602. /** If you need to check double click without raising a single click at first click, enable this flag */
  32603. static ExclusiveDoubleClickMode: boolean;
  32604. private _initClickEvent;
  32605. private _initActionManager;
  32606. private _delayedSimpleClick;
  32607. private _delayedSimpleClickTimeout;
  32608. private _previousDelayedSimpleClickTimeout;
  32609. private _meshPickProceed;
  32610. private _previousButtonPressed;
  32611. private _currentPickResult;
  32612. private _previousPickResult;
  32613. private _totalPointersPressed;
  32614. private _doubleClickOccured;
  32615. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32616. cameraToUseForPointers: Nullable<Camera>;
  32617. private _pointerX;
  32618. private _pointerY;
  32619. private _unTranslatedPointerX;
  32620. private _unTranslatedPointerY;
  32621. private _startingPointerPosition;
  32622. private _previousStartingPointerPosition;
  32623. private _startingPointerTime;
  32624. private _previousStartingPointerTime;
  32625. private _pointerCaptures;
  32626. private _timeAccumulator;
  32627. private _currentStepId;
  32628. private _currentInternalStep;
  32629. /** @hidden */
  32630. _mirroredCameraPosition: Nullable<Vector3>;
  32631. /**
  32632. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32633. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32634. */
  32635. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32636. /**
  32637. * Observable event triggered each time an keyboard event is received from the hosting window
  32638. */
  32639. onKeyboardObservable: Observable<KeyboardInfo>;
  32640. private _onKeyDown;
  32641. private _onKeyUp;
  32642. private _onCanvasFocusObserver;
  32643. private _onCanvasBlurObserver;
  32644. private _useRightHandedSystem;
  32645. /**
  32646. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32647. */
  32648. useRightHandedSystem: boolean;
  32649. /**
  32650. * Sets the step Id used by deterministic lock step
  32651. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32652. * @param newStepId defines the step Id
  32653. */
  32654. setStepId(newStepId: number): void;
  32655. /**
  32656. * Gets the step Id used by deterministic lock step
  32657. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32658. * @returns the step Id
  32659. */
  32660. getStepId(): number;
  32661. /**
  32662. * Gets the internal step used by deterministic lock step
  32663. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32664. * @returns the internal step
  32665. */
  32666. getInternalStep(): number;
  32667. private _fogEnabled;
  32668. /**
  32669. * Gets or sets a boolean indicating if fog is enabled on this scene
  32670. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32671. * (Default is true)
  32672. */
  32673. fogEnabled: boolean;
  32674. private _fogMode;
  32675. /**
  32676. * Gets or sets the fog mode to use
  32677. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32678. * | mode | value |
  32679. * | --- | --- |
  32680. * | FOGMODE_NONE | 0 |
  32681. * | FOGMODE_EXP | 1 |
  32682. * | FOGMODE_EXP2 | 2 |
  32683. * | FOGMODE_LINEAR | 3 |
  32684. */
  32685. fogMode: number;
  32686. /**
  32687. * Gets or sets the fog color to use
  32688. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32689. * (Default is Color3(0.2, 0.2, 0.3))
  32690. */
  32691. fogColor: Color3;
  32692. /**
  32693. * Gets or sets the fog density to use
  32694. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32695. * (Default is 0.1)
  32696. */
  32697. fogDensity: number;
  32698. /**
  32699. * Gets or sets the fog start distance to use
  32700. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32701. * (Default is 0)
  32702. */
  32703. fogStart: number;
  32704. /**
  32705. * Gets or sets the fog end distance to use
  32706. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32707. * (Default is 1000)
  32708. */
  32709. fogEnd: number;
  32710. private _shadowsEnabled;
  32711. /**
  32712. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32713. */
  32714. shadowsEnabled: boolean;
  32715. private _lightsEnabled;
  32716. /**
  32717. * Gets or sets a boolean indicating if lights are enabled on this scene
  32718. */
  32719. lightsEnabled: boolean;
  32720. /** All of the active cameras added to this scene. */
  32721. activeCameras: Camera[];
  32722. private _activeCamera;
  32723. /** Gets or sets the current active camera */
  32724. activeCamera: Nullable<Camera>;
  32725. private _defaultMaterial;
  32726. /** The default material used on meshes when no material is affected */
  32727. /** The default material used on meshes when no material is affected */
  32728. defaultMaterial: Material;
  32729. private _texturesEnabled;
  32730. /**
  32731. * Gets or sets a boolean indicating if textures are enabled on this scene
  32732. */
  32733. texturesEnabled: boolean;
  32734. /**
  32735. * Gets or sets a boolean indicating if particles are enabled on this scene
  32736. */
  32737. particlesEnabled: boolean;
  32738. /**
  32739. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32740. */
  32741. spritesEnabled: boolean;
  32742. private _skeletonsEnabled;
  32743. /**
  32744. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32745. */
  32746. skeletonsEnabled: boolean;
  32747. /**
  32748. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32749. */
  32750. lensFlaresEnabled: boolean;
  32751. /**
  32752. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32753. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32754. */
  32755. collisionsEnabled: boolean;
  32756. private _collisionCoordinator;
  32757. /** @hidden */
  32758. readonly collisionCoordinator: ICollisionCoordinator;
  32759. /**
  32760. * Defines the gravity applied to this scene (used only for collisions)
  32761. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32762. */
  32763. gravity: Vector3;
  32764. /**
  32765. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32766. */
  32767. postProcessesEnabled: boolean;
  32768. /**
  32769. * The list of postprocesses added to the scene
  32770. */
  32771. postProcesses: PostProcess[];
  32772. /**
  32773. * Gets the current postprocess manager
  32774. */
  32775. postProcessManager: PostProcessManager;
  32776. /**
  32777. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32778. */
  32779. renderTargetsEnabled: boolean;
  32780. /**
  32781. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32782. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32783. */
  32784. dumpNextRenderTargets: boolean;
  32785. /**
  32786. * The list of user defined render targets added to the scene
  32787. */
  32788. customRenderTargets: RenderTargetTexture[];
  32789. /**
  32790. * Defines if texture loading must be delayed
  32791. * If true, textures will only be loaded when they need to be rendered
  32792. */
  32793. useDelayedTextureLoading: boolean;
  32794. /**
  32795. * Gets the list of meshes imported to the scene through SceneLoader
  32796. */
  32797. importedMeshesFiles: String[];
  32798. /**
  32799. * Gets or sets a boolean indicating if probes are enabled on this scene
  32800. */
  32801. probesEnabled: boolean;
  32802. /**
  32803. * Gets or sets the current offline provider to use to store scene data
  32804. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32805. */
  32806. offlineProvider: IOfflineProvider;
  32807. /**
  32808. * Gets or sets the action manager associated with the scene
  32809. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32810. */
  32811. actionManager: AbstractActionManager;
  32812. private _meshesForIntersections;
  32813. /**
  32814. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32815. */
  32816. proceduralTexturesEnabled: boolean;
  32817. private _engine;
  32818. private _totalVertices;
  32819. /** @hidden */
  32820. _activeIndices: PerfCounter;
  32821. /** @hidden */
  32822. _activeParticles: PerfCounter;
  32823. /** @hidden */
  32824. _activeBones: PerfCounter;
  32825. private _animationRatio;
  32826. /** @hidden */
  32827. _animationTimeLast: number;
  32828. /** @hidden */
  32829. _animationTime: number;
  32830. /**
  32831. * Gets or sets a general scale for animation speed
  32832. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32833. */
  32834. animationTimeScale: number;
  32835. /** @hidden */
  32836. _cachedMaterial: Nullable<Material>;
  32837. /** @hidden */
  32838. _cachedEffect: Nullable<Effect>;
  32839. /** @hidden */
  32840. _cachedVisibility: Nullable<number>;
  32841. private _renderId;
  32842. private _frameId;
  32843. private _executeWhenReadyTimeoutId;
  32844. private _intermediateRendering;
  32845. private _viewUpdateFlag;
  32846. private _projectionUpdateFlag;
  32847. private _alternateViewUpdateFlag;
  32848. private _alternateProjectionUpdateFlag;
  32849. /** @hidden */
  32850. _toBeDisposed: Nullable<IDisposable>[];
  32851. private _activeRequests;
  32852. /** @hidden */
  32853. _pendingData: any[];
  32854. private _isDisposed;
  32855. /**
  32856. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32857. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32858. */
  32859. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32860. private _activeMeshes;
  32861. private _processedMaterials;
  32862. private _renderTargets;
  32863. /** @hidden */
  32864. _activeParticleSystems: SmartArray<IParticleSystem>;
  32865. private _activeSkeletons;
  32866. private _softwareSkinnedMeshes;
  32867. private _renderingManager;
  32868. /** @hidden */
  32869. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  32870. private _transformMatrix;
  32871. private _sceneUbo;
  32872. private _alternateSceneUbo;
  32873. private _viewMatrix;
  32874. private _projectionMatrix;
  32875. private _alternateViewMatrix;
  32876. private _alternateProjectionMatrix;
  32877. private _alternateTransformMatrix;
  32878. private _useAlternateCameraConfiguration;
  32879. private _alternateRendering;
  32880. private _wheelEventName;
  32881. /** @hidden */
  32882. _forcedViewPosition: Nullable<Vector3>;
  32883. /** @hidden */
  32884. readonly _isAlternateRenderingEnabled: boolean;
  32885. private _frustumPlanes;
  32886. /**
  32887. * Gets the list of frustum planes (built from the active camera)
  32888. */
  32889. readonly frustumPlanes: Plane[];
  32890. /**
  32891. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32892. * This is useful if there are more lights that the maximum simulteanous authorized
  32893. */
  32894. requireLightSorting: boolean;
  32895. /** @hidden */
  32896. readonly useMaterialMeshMap: boolean;
  32897. /** @hidden */
  32898. readonly useClonedMeshhMap: boolean;
  32899. private _pointerOverMesh;
  32900. private _pickedDownMesh;
  32901. private _pickedUpMesh;
  32902. private _externalData;
  32903. private _uid;
  32904. /**
  32905. * @hidden
  32906. * Backing store of defined scene components.
  32907. */
  32908. _components: ISceneComponent[];
  32909. /**
  32910. * @hidden
  32911. * Backing store of defined scene components.
  32912. */
  32913. _serializableComponents: ISceneSerializableComponent[];
  32914. /**
  32915. * List of components to register on the next registration step.
  32916. */
  32917. private _transientComponents;
  32918. /**
  32919. * Registers the transient components if needed.
  32920. */
  32921. private _registerTransientComponents;
  32922. /**
  32923. * @hidden
  32924. * Add a component to the scene.
  32925. * Note that the ccomponent could be registered on th next frame if this is called after
  32926. * the register component stage.
  32927. * @param component Defines the component to add to the scene
  32928. */
  32929. _addComponent(component: ISceneComponent): void;
  32930. /**
  32931. * @hidden
  32932. * Gets a component from the scene.
  32933. * @param name defines the name of the component to retrieve
  32934. * @returns the component or null if not present
  32935. */
  32936. _getComponent(name: string): Nullable<ISceneComponent>;
  32937. /**
  32938. * @hidden
  32939. * Defines the actions happening before camera updates.
  32940. */
  32941. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32942. /**
  32943. * @hidden
  32944. * Defines the actions happening before clear the canvas.
  32945. */
  32946. _beforeClearStage: Stage<SimpleStageAction>;
  32947. /**
  32948. * @hidden
  32949. * Defines the actions when collecting render targets for the frame.
  32950. */
  32951. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32952. /**
  32953. * @hidden
  32954. * Defines the actions happening for one camera in the frame.
  32955. */
  32956. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32957. /**
  32958. * @hidden
  32959. * Defines the actions happening during the per mesh ready checks.
  32960. */
  32961. _isReadyForMeshStage: Stage<MeshStageAction>;
  32962. /**
  32963. * @hidden
  32964. * Defines the actions happening before evaluate active mesh checks.
  32965. */
  32966. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32967. /**
  32968. * @hidden
  32969. * Defines the actions happening during the evaluate sub mesh checks.
  32970. */
  32971. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32972. /**
  32973. * @hidden
  32974. * Defines the actions happening during the active mesh stage.
  32975. */
  32976. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32977. /**
  32978. * @hidden
  32979. * Defines the actions happening during the per camera render target step.
  32980. */
  32981. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  32982. /**
  32983. * @hidden
  32984. * Defines the actions happening just before the active camera is drawing.
  32985. */
  32986. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32987. /**
  32988. * @hidden
  32989. * Defines the actions happening just before a render target is drawing.
  32990. */
  32991. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32992. /**
  32993. * @hidden
  32994. * Defines the actions happening just before a rendering group is drawing.
  32995. */
  32996. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32997. /**
  32998. * @hidden
  32999. * Defines the actions happening just before a mesh is drawing.
  33000. */
  33001. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33002. /**
  33003. * @hidden
  33004. * Defines the actions happening just after a mesh has been drawn.
  33005. */
  33006. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33007. /**
  33008. * @hidden
  33009. * Defines the actions happening just after a rendering group has been drawn.
  33010. */
  33011. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33012. /**
  33013. * @hidden
  33014. * Defines the actions happening just after the active camera has been drawn.
  33015. */
  33016. _afterCameraDrawStage: Stage<CameraStageAction>;
  33017. /**
  33018. * @hidden
  33019. * Defines the actions happening just after a render target has been drawn.
  33020. */
  33021. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33022. /**
  33023. * @hidden
  33024. * Defines the actions happening just after rendering all cameras and computing intersections.
  33025. */
  33026. _afterRenderStage: Stage<SimpleStageAction>;
  33027. /**
  33028. * @hidden
  33029. * Defines the actions happening when a pointer move event happens.
  33030. */
  33031. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33032. /**
  33033. * @hidden
  33034. * Defines the actions happening when a pointer down event happens.
  33035. */
  33036. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33037. /**
  33038. * @hidden
  33039. * Defines the actions happening when a pointer up event happens.
  33040. */
  33041. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33042. /**
  33043. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33044. */
  33045. private geometriesByUniqueId;
  33046. /**
  33047. * Creates a new Scene
  33048. * @param engine defines the engine to use to render this scene
  33049. * @param options defines the scene options
  33050. */
  33051. constructor(engine: Engine, options?: SceneOptions);
  33052. private _defaultMeshCandidates;
  33053. /**
  33054. * @hidden
  33055. */
  33056. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33057. private _defaultSubMeshCandidates;
  33058. /**
  33059. * @hidden
  33060. */
  33061. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33062. /**
  33063. * Sets the default candidate providers for the scene.
  33064. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33065. * and getCollidingSubMeshCandidates to their default function
  33066. */
  33067. setDefaultCandidateProviders(): void;
  33068. /**
  33069. * Gets the mesh that is currently under the pointer
  33070. */
  33071. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33072. /**
  33073. * Gets or sets the current on-screen X position of the pointer
  33074. */
  33075. pointerX: number;
  33076. /**
  33077. * Gets or sets the current on-screen Y position of the pointer
  33078. */
  33079. pointerY: number;
  33080. /**
  33081. * Gets the cached material (ie. the latest rendered one)
  33082. * @returns the cached material
  33083. */
  33084. getCachedMaterial(): Nullable<Material>;
  33085. /**
  33086. * Gets the cached effect (ie. the latest rendered one)
  33087. * @returns the cached effect
  33088. */
  33089. getCachedEffect(): Nullable<Effect>;
  33090. /**
  33091. * Gets the cached visibility state (ie. the latest rendered one)
  33092. * @returns the cached visibility state
  33093. */
  33094. getCachedVisibility(): Nullable<number>;
  33095. /**
  33096. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33097. * @param material defines the current material
  33098. * @param effect defines the current effect
  33099. * @param visibility defines the current visibility state
  33100. * @returns true if one parameter is not cached
  33101. */
  33102. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33103. /**
  33104. * Gets the engine associated with the scene
  33105. * @returns an Engine
  33106. */
  33107. getEngine(): Engine;
  33108. /**
  33109. * Gets the total number of vertices rendered per frame
  33110. * @returns the total number of vertices rendered per frame
  33111. */
  33112. getTotalVertices(): number;
  33113. /**
  33114. * Gets the performance counter for total vertices
  33115. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33116. */
  33117. readonly totalVerticesPerfCounter: PerfCounter;
  33118. /**
  33119. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33120. * @returns the total number of active indices rendered per frame
  33121. */
  33122. getActiveIndices(): number;
  33123. /**
  33124. * Gets the performance counter for active indices
  33125. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33126. */
  33127. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33128. /**
  33129. * Gets the total number of active particles rendered per frame
  33130. * @returns the total number of active particles rendered per frame
  33131. */
  33132. getActiveParticles(): number;
  33133. /**
  33134. * Gets the performance counter for active particles
  33135. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33136. */
  33137. readonly activeParticlesPerfCounter: PerfCounter;
  33138. /**
  33139. * Gets the total number of active bones rendered per frame
  33140. * @returns the total number of active bones rendered per frame
  33141. */
  33142. getActiveBones(): number;
  33143. /**
  33144. * Gets the performance counter for active bones
  33145. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33146. */
  33147. readonly activeBonesPerfCounter: PerfCounter;
  33148. /**
  33149. * Gets the array of active meshes
  33150. * @returns an array of AbstractMesh
  33151. */
  33152. getActiveMeshes(): SmartArray<AbstractMesh>;
  33153. /**
  33154. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33155. * @returns a number
  33156. */
  33157. getAnimationRatio(): number;
  33158. /**
  33159. * Gets an unique Id for the current render phase
  33160. * @returns a number
  33161. */
  33162. getRenderId(): number;
  33163. /**
  33164. * Gets an unique Id for the current frame
  33165. * @returns a number
  33166. */
  33167. getFrameId(): number;
  33168. /** Call this function if you want to manually increment the render Id*/
  33169. incrementRenderId(): void;
  33170. private _updatePointerPosition;
  33171. private _createUbo;
  33172. private _createAlternateUbo;
  33173. private _setRayOnPointerInfo;
  33174. /**
  33175. * Use this method to simulate a pointer move on a mesh
  33176. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33177. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33178. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33179. * @returns the current scene
  33180. */
  33181. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33182. private _processPointerMove;
  33183. private _checkPrePointerObservable;
  33184. /**
  33185. * Use this method to simulate a pointer down on a mesh
  33186. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33187. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33188. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33189. * @returns the current scene
  33190. */
  33191. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33192. private _processPointerDown;
  33193. /**
  33194. * Use this method to simulate a pointer up on a mesh
  33195. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33196. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33197. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33198. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33199. * @returns the current scene
  33200. */
  33201. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33202. private _processPointerUp;
  33203. /**
  33204. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33205. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33206. * @returns true if the pointer was captured
  33207. */
  33208. isPointerCaptured(pointerId?: number): boolean;
  33209. /** @hidden */
  33210. _isPointerSwiping(): boolean;
  33211. /**
  33212. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33213. * @param attachUp defines if you want to attach events to pointerup
  33214. * @param attachDown defines if you want to attach events to pointerdown
  33215. * @param attachMove defines if you want to attach events to pointermove
  33216. */
  33217. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33218. /** Detaches all event handlers*/
  33219. detachControl(): void;
  33220. /**
  33221. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33222. * Delay loaded resources are not taking in account
  33223. * @return true if all required resources are ready
  33224. */
  33225. isReady(): boolean;
  33226. /** Resets all cached information relative to material (including effect and visibility) */
  33227. resetCachedMaterial(): void;
  33228. /**
  33229. * Registers a function to be called before every frame render
  33230. * @param func defines the function to register
  33231. */
  33232. registerBeforeRender(func: () => void): void;
  33233. /**
  33234. * Unregisters a function called before every frame render
  33235. * @param func defines the function to unregister
  33236. */
  33237. unregisterBeforeRender(func: () => void): void;
  33238. /**
  33239. * Registers a function to be called after every frame render
  33240. * @param func defines the function to register
  33241. */
  33242. registerAfterRender(func: () => void): void;
  33243. /**
  33244. * Unregisters a function called after every frame render
  33245. * @param func defines the function to unregister
  33246. */
  33247. unregisterAfterRender(func: () => void): void;
  33248. private _executeOnceBeforeRender;
  33249. /**
  33250. * The provided function will run before render once and will be disposed afterwards.
  33251. * A timeout delay can be provided so that the function will be executed in N ms.
  33252. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33253. * @param func The function to be executed.
  33254. * @param timeout optional delay in ms
  33255. */
  33256. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33257. /** @hidden */
  33258. _addPendingData(data: any): void;
  33259. /** @hidden */
  33260. _removePendingData(data: any): void;
  33261. /**
  33262. * Returns the number of items waiting to be loaded
  33263. * @returns the number of items waiting to be loaded
  33264. */
  33265. getWaitingItemsCount(): number;
  33266. /**
  33267. * Returns a boolean indicating if the scene is still loading data
  33268. */
  33269. readonly isLoading: boolean;
  33270. /**
  33271. * Registers a function to be executed when the scene is ready
  33272. * @param {Function} func - the function to be executed
  33273. */
  33274. executeWhenReady(func: () => void): void;
  33275. /**
  33276. * Returns a promise that resolves when the scene is ready
  33277. * @returns A promise that resolves when the scene is ready
  33278. */
  33279. whenReadyAsync(): Promise<void>;
  33280. /** @hidden */
  33281. _checkIsReady(): void;
  33282. /**
  33283. * Gets all animatable attached to the scene
  33284. */
  33285. readonly animatables: Animatable[];
  33286. /**
  33287. * Resets the last animation time frame.
  33288. * Useful to override when animations start running when loading a scene for the first time.
  33289. */
  33290. resetLastAnimationTimeFrame(): void;
  33291. /** @hidden */
  33292. _switchToAlternateCameraConfiguration(active: boolean): void;
  33293. /**
  33294. * Gets the current view matrix
  33295. * @returns a Matrix
  33296. */
  33297. getViewMatrix(): Matrix;
  33298. /**
  33299. * Gets the current projection matrix
  33300. * @returns a Matrix
  33301. */
  33302. getProjectionMatrix(): Matrix;
  33303. /**
  33304. * Gets the current transform matrix
  33305. * @returns a Matrix made of View * Projection
  33306. */
  33307. getTransformMatrix(): Matrix;
  33308. /**
  33309. * Sets the current transform matrix
  33310. * @param view defines the View matrix to use
  33311. * @param projection defines the Projection matrix to use
  33312. */
  33313. setTransformMatrix(view: Matrix, projection: Matrix): void;
  33314. /** @hidden */
  33315. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  33316. /**
  33317. * Gets the uniform buffer used to store scene data
  33318. * @returns a UniformBuffer
  33319. */
  33320. getSceneUniformBuffer(): UniformBuffer;
  33321. /**
  33322. * Gets an unique (relatively to the current scene) Id
  33323. * @returns an unique number for the scene
  33324. */
  33325. getUniqueId(): number;
  33326. /**
  33327. * Add a mesh to the list of scene's meshes
  33328. * @param newMesh defines the mesh to add
  33329. * @param recursive if all child meshes should also be added to the scene
  33330. */
  33331. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33332. /**
  33333. * Remove a mesh for the list of scene's meshes
  33334. * @param toRemove defines the mesh to remove
  33335. * @param recursive if all child meshes should also be removed from the scene
  33336. * @returns the index where the mesh was in the mesh list
  33337. */
  33338. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33339. /**
  33340. * Add a transform node to the list of scene's transform nodes
  33341. * @param newTransformNode defines the transform node to add
  33342. */
  33343. addTransformNode(newTransformNode: TransformNode): void;
  33344. /**
  33345. * Remove a transform node for the list of scene's transform nodes
  33346. * @param toRemove defines the transform node to remove
  33347. * @returns the index where the transform node was in the transform node list
  33348. */
  33349. removeTransformNode(toRemove: TransformNode): number;
  33350. /**
  33351. * Remove a skeleton for the list of scene's skeletons
  33352. * @param toRemove defines the skeleton to remove
  33353. * @returns the index where the skeleton was in the skeleton list
  33354. */
  33355. removeSkeleton(toRemove: Skeleton): number;
  33356. /**
  33357. * Remove a morph target for the list of scene's morph targets
  33358. * @param toRemove defines the morph target to remove
  33359. * @returns the index where the morph target was in the morph target list
  33360. */
  33361. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33362. /**
  33363. * Remove a light for the list of scene's lights
  33364. * @param toRemove defines the light to remove
  33365. * @returns the index where the light was in the light list
  33366. */
  33367. removeLight(toRemove: Light): number;
  33368. /**
  33369. * Remove a camera for the list of scene's cameras
  33370. * @param toRemove defines the camera to remove
  33371. * @returns the index where the camera was in the camera list
  33372. */
  33373. removeCamera(toRemove: Camera): number;
  33374. /**
  33375. * Remove a particle system for the list of scene's particle systems
  33376. * @param toRemove defines the particle system to remove
  33377. * @returns the index where the particle system was in the particle system list
  33378. */
  33379. removeParticleSystem(toRemove: IParticleSystem): number;
  33380. /**
  33381. * Remove a animation for the list of scene's animations
  33382. * @param toRemove defines the animation to remove
  33383. * @returns the index where the animation was in the animation list
  33384. */
  33385. removeAnimation(toRemove: Animation): number;
  33386. /**
  33387. * Removes the given animation group from this scene.
  33388. * @param toRemove The animation group to remove
  33389. * @returns The index of the removed animation group
  33390. */
  33391. removeAnimationGroup(toRemove: AnimationGroup): number;
  33392. /**
  33393. * Removes the given multi-material from this scene.
  33394. * @param toRemove The multi-material to remove
  33395. * @returns The index of the removed multi-material
  33396. */
  33397. removeMultiMaterial(toRemove: MultiMaterial): number;
  33398. /**
  33399. * Removes the given material from this scene.
  33400. * @param toRemove The material to remove
  33401. * @returns The index of the removed material
  33402. */
  33403. removeMaterial(toRemove: Material): number;
  33404. /**
  33405. * Removes the given action manager from this scene.
  33406. * @param toRemove The action manager to remove
  33407. * @returns The index of the removed action manager
  33408. */
  33409. removeActionManager(toRemove: AbstractActionManager): number;
  33410. /**
  33411. * Removes the given texture from this scene.
  33412. * @param toRemove The texture to remove
  33413. * @returns The index of the removed texture
  33414. */
  33415. removeTexture(toRemove: BaseTexture): number;
  33416. /**
  33417. * Adds the given light to this scene
  33418. * @param newLight The light to add
  33419. */
  33420. addLight(newLight: Light): void;
  33421. /**
  33422. * Sorts the list list based on light priorities
  33423. */
  33424. sortLightsByPriority(): void;
  33425. /**
  33426. * Adds the given camera to this scene
  33427. * @param newCamera The camera to add
  33428. */
  33429. addCamera(newCamera: Camera): void;
  33430. /**
  33431. * Adds the given skeleton to this scene
  33432. * @param newSkeleton The skeleton to add
  33433. */
  33434. addSkeleton(newSkeleton: Skeleton): void;
  33435. /**
  33436. * Adds the given particle system to this scene
  33437. * @param newParticleSystem The particle system to add
  33438. */
  33439. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33440. /**
  33441. * Adds the given animation to this scene
  33442. * @param newAnimation The animation to add
  33443. */
  33444. addAnimation(newAnimation: Animation): void;
  33445. /**
  33446. * Adds the given animation group to this scene.
  33447. * @param newAnimationGroup The animation group to add
  33448. */
  33449. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33450. /**
  33451. * Adds the given multi-material to this scene
  33452. * @param newMultiMaterial The multi-material to add
  33453. */
  33454. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33455. /**
  33456. * Adds the given material to this scene
  33457. * @param newMaterial The material to add
  33458. */
  33459. addMaterial(newMaterial: Material): void;
  33460. /**
  33461. * Adds the given morph target to this scene
  33462. * @param newMorphTargetManager The morph target to add
  33463. */
  33464. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33465. /**
  33466. * Adds the given geometry to this scene
  33467. * @param newGeometry The geometry to add
  33468. */
  33469. addGeometry(newGeometry: Geometry): void;
  33470. /**
  33471. * Adds the given action manager to this scene
  33472. * @param newActionManager The action manager to add
  33473. */
  33474. addActionManager(newActionManager: AbstractActionManager): void;
  33475. /**
  33476. * Adds the given texture to this scene.
  33477. * @param newTexture The texture to add
  33478. */
  33479. addTexture(newTexture: BaseTexture): void;
  33480. /**
  33481. * Switch active camera
  33482. * @param newCamera defines the new active camera
  33483. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33484. */
  33485. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33486. /**
  33487. * sets the active camera of the scene using its ID
  33488. * @param id defines the camera's ID
  33489. * @return the new active camera or null if none found.
  33490. */
  33491. setActiveCameraByID(id: string): Nullable<Camera>;
  33492. /**
  33493. * sets the active camera of the scene using its name
  33494. * @param name defines the camera's name
  33495. * @returns the new active camera or null if none found.
  33496. */
  33497. setActiveCameraByName(name: string): Nullable<Camera>;
  33498. /**
  33499. * get an animation group using its name
  33500. * @param name defines the material's name
  33501. * @return the animation group or null if none found.
  33502. */
  33503. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33504. /**
  33505. * Get a material using its unique id
  33506. * @param uniqueId defines the material's unique id
  33507. * @return the material or null if none found.
  33508. */
  33509. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33510. /**
  33511. * get a material using its id
  33512. * @param id defines the material's ID
  33513. * @return the material or null if none found.
  33514. */
  33515. getMaterialByID(id: string): Nullable<Material>;
  33516. /**
  33517. * Gets a material using its name
  33518. * @param name defines the material's name
  33519. * @return the material or null if none found.
  33520. */
  33521. getMaterialByName(name: string): Nullable<Material>;
  33522. /**
  33523. * Gets a camera using its id
  33524. * @param id defines the id to look for
  33525. * @returns the camera or null if not found
  33526. */
  33527. getCameraByID(id: string): Nullable<Camera>;
  33528. /**
  33529. * Gets a camera using its unique id
  33530. * @param uniqueId defines the unique id to look for
  33531. * @returns the camera or null if not found
  33532. */
  33533. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33534. /**
  33535. * Gets a camera using its name
  33536. * @param name defines the camera's name
  33537. * @return the camera or null if none found.
  33538. */
  33539. getCameraByName(name: string): Nullable<Camera>;
  33540. /**
  33541. * Gets a bone using its id
  33542. * @param id defines the bone's id
  33543. * @return the bone or null if not found
  33544. */
  33545. getBoneByID(id: string): Nullable<Bone>;
  33546. /**
  33547. * Gets a bone using its id
  33548. * @param name defines the bone's name
  33549. * @return the bone or null if not found
  33550. */
  33551. getBoneByName(name: string): Nullable<Bone>;
  33552. /**
  33553. * Gets a light node using its name
  33554. * @param name defines the the light's name
  33555. * @return the light or null if none found.
  33556. */
  33557. getLightByName(name: string): Nullable<Light>;
  33558. /**
  33559. * Gets a light node using its id
  33560. * @param id defines the light's id
  33561. * @return the light or null if none found.
  33562. */
  33563. getLightByID(id: string): Nullable<Light>;
  33564. /**
  33565. * Gets a light node using its scene-generated unique ID
  33566. * @param uniqueId defines the light's unique id
  33567. * @return the light or null if none found.
  33568. */
  33569. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33570. /**
  33571. * Gets a particle system by id
  33572. * @param id defines the particle system id
  33573. * @return the corresponding system or null if none found
  33574. */
  33575. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33576. /**
  33577. * Gets a geometry using its ID
  33578. * @param id defines the geometry's id
  33579. * @return the geometry or null if none found.
  33580. */
  33581. getGeometryByID(id: string): Nullable<Geometry>;
  33582. private _getGeometryByUniqueID;
  33583. /**
  33584. * Add a new geometry to this scene
  33585. * @param geometry defines the geometry to be added to the scene.
  33586. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33587. * @return a boolean defining if the geometry was added or not
  33588. */
  33589. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33590. /**
  33591. * Removes an existing geometry
  33592. * @param geometry defines the geometry to be removed from the scene
  33593. * @return a boolean defining if the geometry was removed or not
  33594. */
  33595. removeGeometry(geometry: Geometry): boolean;
  33596. /**
  33597. * Gets the list of geometries attached to the scene
  33598. * @returns an array of Geometry
  33599. */
  33600. getGeometries(): Geometry[];
  33601. /**
  33602. * Gets the first added mesh found of a given ID
  33603. * @param id defines the id to search for
  33604. * @return the mesh found or null if not found at all
  33605. */
  33606. getMeshByID(id: string): Nullable<AbstractMesh>;
  33607. /**
  33608. * Gets a list of meshes using their id
  33609. * @param id defines the id to search for
  33610. * @returns a list of meshes
  33611. */
  33612. getMeshesByID(id: string): Array<AbstractMesh>;
  33613. /**
  33614. * Gets the first added transform node found of a given ID
  33615. * @param id defines the id to search for
  33616. * @return the found transform node or null if not found at all.
  33617. */
  33618. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33619. /**
  33620. * Gets a transform node with its auto-generated unique id
  33621. * @param uniqueId efines the unique id to search for
  33622. * @return the found transform node or null if not found at all.
  33623. */
  33624. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33625. /**
  33626. * Gets a list of transform nodes using their id
  33627. * @param id defines the id to search for
  33628. * @returns a list of transform nodes
  33629. */
  33630. getTransformNodesByID(id: string): Array<TransformNode>;
  33631. /**
  33632. * Gets a mesh with its auto-generated unique id
  33633. * @param uniqueId defines the unique id to search for
  33634. * @return the found mesh or null if not found at all.
  33635. */
  33636. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33637. /**
  33638. * Gets a the last added mesh using a given id
  33639. * @param id defines the id to search for
  33640. * @return the found mesh or null if not found at all.
  33641. */
  33642. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33643. /**
  33644. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33645. * @param id defines the id to search for
  33646. * @return the found node or null if not found at all
  33647. */
  33648. getLastEntryByID(id: string): Nullable<Node>;
  33649. /**
  33650. * Gets a node (Mesh, Camera, Light) using a given id
  33651. * @param id defines the id to search for
  33652. * @return the found node or null if not found at all
  33653. */
  33654. getNodeByID(id: string): Nullable<Node>;
  33655. /**
  33656. * Gets a node (Mesh, Camera, Light) using a given name
  33657. * @param name defines the name to search for
  33658. * @return the found node or null if not found at all.
  33659. */
  33660. getNodeByName(name: string): Nullable<Node>;
  33661. /**
  33662. * Gets a mesh using a given name
  33663. * @param name defines the name to search for
  33664. * @return the found mesh or null if not found at all.
  33665. */
  33666. getMeshByName(name: string): Nullable<AbstractMesh>;
  33667. /**
  33668. * Gets a transform node using a given name
  33669. * @param name defines the name to search for
  33670. * @return the found transform node or null if not found at all.
  33671. */
  33672. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33673. /**
  33674. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33675. * @param id defines the id to search for
  33676. * @return the found skeleton or null if not found at all.
  33677. */
  33678. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33679. /**
  33680. * Gets a skeleton using a given auto generated unique id
  33681. * @param uniqueId defines the unique id to search for
  33682. * @return the found skeleton or null if not found at all.
  33683. */
  33684. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33685. /**
  33686. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33687. * @param id defines the id to search for
  33688. * @return the found skeleton or null if not found at all.
  33689. */
  33690. getSkeletonById(id: string): Nullable<Skeleton>;
  33691. /**
  33692. * Gets a skeleton using a given name
  33693. * @param name defines the name to search for
  33694. * @return the found skeleton or null if not found at all.
  33695. */
  33696. getSkeletonByName(name: string): Nullable<Skeleton>;
  33697. /**
  33698. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33699. * @param id defines the id to search for
  33700. * @return the found morph target manager or null if not found at all.
  33701. */
  33702. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33703. /**
  33704. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33705. * @param id defines the id to search for
  33706. * @return the found morph target or null if not found at all.
  33707. */
  33708. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33709. /**
  33710. * Gets a boolean indicating if the given mesh is active
  33711. * @param mesh defines the mesh to look for
  33712. * @returns true if the mesh is in the active list
  33713. */
  33714. isActiveMesh(mesh: AbstractMesh): boolean;
  33715. /**
  33716. * Return a unique id as a string which can serve as an identifier for the scene
  33717. */
  33718. readonly uid: string;
  33719. /**
  33720. * Add an externaly attached data from its key.
  33721. * This method call will fail and return false, if such key already exists.
  33722. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33723. * @param key the unique key that identifies the data
  33724. * @param data the data object to associate to the key for this Engine instance
  33725. * @return true if no such key were already present and the data was added successfully, false otherwise
  33726. */
  33727. addExternalData<T>(key: string, data: T): boolean;
  33728. /**
  33729. * Get an externaly attached data from its key
  33730. * @param key the unique key that identifies the data
  33731. * @return the associated data, if present (can be null), or undefined if not present
  33732. */
  33733. getExternalData<T>(key: string): Nullable<T>;
  33734. /**
  33735. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33736. * @param key the unique key that identifies the data
  33737. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33738. * @return the associated data, can be null if the factory returned null.
  33739. */
  33740. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33741. /**
  33742. * Remove an externaly attached data from the Engine instance
  33743. * @param key the unique key that identifies the data
  33744. * @return true if the data was successfully removed, false if it doesn't exist
  33745. */
  33746. removeExternalData(key: string): boolean;
  33747. private _evaluateSubMesh;
  33748. /**
  33749. * Clear the processed materials smart array preventing retention point in material dispose.
  33750. */
  33751. freeProcessedMaterials(): void;
  33752. private _preventFreeActiveMeshesAndRenderingGroups;
  33753. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33754. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33755. * when disposing several meshes in a row or a hierarchy of meshes.
  33756. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33757. */
  33758. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33759. /**
  33760. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33761. */
  33762. freeActiveMeshes(): void;
  33763. /**
  33764. * Clear the info related to rendering groups preventing retention points during dispose.
  33765. */
  33766. freeRenderingGroups(): void;
  33767. /** @hidden */
  33768. _isInIntermediateRendering(): boolean;
  33769. /**
  33770. * Lambda returning the list of potentially active meshes.
  33771. */
  33772. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33773. /**
  33774. * Lambda returning the list of potentially active sub meshes.
  33775. */
  33776. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33777. /**
  33778. * Lambda returning the list of potentially intersecting sub meshes.
  33779. */
  33780. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33781. /**
  33782. * Lambda returning the list of potentially colliding sub meshes.
  33783. */
  33784. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33785. private _activeMeshesFrozen;
  33786. /**
  33787. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33788. * @returns the current scene
  33789. */
  33790. freezeActiveMeshes(): Scene;
  33791. /**
  33792. * Use this function to restart evaluating active meshes on every frame
  33793. * @returns the current scene
  33794. */
  33795. unfreezeActiveMeshes(): Scene;
  33796. private _evaluateActiveMeshes;
  33797. private _activeMesh;
  33798. /**
  33799. * Update the transform matrix to update from the current active camera
  33800. * @param force defines a boolean used to force the update even if cache is up to date
  33801. */
  33802. updateTransformMatrix(force?: boolean): void;
  33803. /**
  33804. * 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)
  33805. * @param alternateCamera defines the camera to use
  33806. */
  33807. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  33808. /** @hidden */
  33809. _allowPostProcessClearColor: boolean;
  33810. private _renderForCamera;
  33811. private _processSubCameras;
  33812. private _checkIntersections;
  33813. /** @hidden */
  33814. _advancePhysicsEngineStep(step: number): void;
  33815. /**
  33816. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33817. */
  33818. getDeterministicFrameTime: () => number;
  33819. /** @hidden */
  33820. _animate(): void;
  33821. /**
  33822. * Render the scene
  33823. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33824. */
  33825. render(updateCameras?: boolean): void;
  33826. /**
  33827. * Freeze all materials
  33828. * A frozen material will not be updatable but should be faster to render
  33829. */
  33830. freezeMaterials(): void;
  33831. /**
  33832. * Unfreeze all materials
  33833. * A frozen material will not be updatable but should be faster to render
  33834. */
  33835. unfreezeMaterials(): void;
  33836. /**
  33837. * Releases all held ressources
  33838. */
  33839. dispose(): void;
  33840. /**
  33841. * Gets if the scene is already disposed
  33842. */
  33843. readonly isDisposed: boolean;
  33844. /**
  33845. * Call this function to reduce memory footprint of the scene.
  33846. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33847. */
  33848. clearCachedVertexData(): void;
  33849. /**
  33850. * This function will remove the local cached buffer data from texture.
  33851. * It will save memory but will prevent the texture from being rebuilt
  33852. */
  33853. cleanCachedTextureBuffer(): void;
  33854. /**
  33855. * Get the world extend vectors with an optional filter
  33856. *
  33857. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33858. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33859. */
  33860. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33861. min: Vector3;
  33862. max: Vector3;
  33863. };
  33864. /**
  33865. * Creates a ray that can be used to pick in the scene
  33866. * @param x defines the x coordinate of the origin (on-screen)
  33867. * @param y defines the y coordinate of the origin (on-screen)
  33868. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33869. * @param camera defines the camera to use for the picking
  33870. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33871. * @returns a Ray
  33872. */
  33873. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33874. /**
  33875. * Creates a ray that can be used to pick in the scene
  33876. * @param x defines the x coordinate of the origin (on-screen)
  33877. * @param y defines the y coordinate of the origin (on-screen)
  33878. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33879. * @param result defines the ray where to store the picking ray
  33880. * @param camera defines the camera to use for the picking
  33881. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33882. * @returns the current scene
  33883. */
  33884. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33885. /**
  33886. * Creates a ray that can be used to pick in the scene
  33887. * @param x defines the x coordinate of the origin (on-screen)
  33888. * @param y defines the y coordinate of the origin (on-screen)
  33889. * @param camera defines the camera to use for the picking
  33890. * @returns a Ray
  33891. */
  33892. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33893. /**
  33894. * Creates a ray that can be used to pick in the scene
  33895. * @param x defines the x coordinate of the origin (on-screen)
  33896. * @param y defines the y coordinate of the origin (on-screen)
  33897. * @param result defines the ray where to store the picking ray
  33898. * @param camera defines the camera to use for the picking
  33899. * @returns the current scene
  33900. */
  33901. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33902. /** Launch a ray to try to pick a mesh in the scene
  33903. * @param x position on screen
  33904. * @param y position on screen
  33905. * @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
  33906. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33907. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33908. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33909. * @returns a PickingInfo
  33910. */
  33911. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  33912. /** Use the given ray to pick a mesh in the scene
  33913. * @param ray The ray to use to pick meshes
  33914. * @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
  33915. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33916. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33917. * @returns a PickingInfo
  33918. */
  33919. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33920. /**
  33921. * Launch a ray to try to pick a mesh in the scene
  33922. * @param x X position on screen
  33923. * @param y Y position on screen
  33924. * @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
  33925. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33926. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33927. * @returns an array of PickingInfo
  33928. */
  33929. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33930. /**
  33931. * Launch a ray to try to pick a mesh in the scene
  33932. * @param ray Ray to use
  33933. * @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
  33934. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33935. * @returns an array of PickingInfo
  33936. */
  33937. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33938. /**
  33939. * Force the value of meshUnderPointer
  33940. * @param mesh defines the mesh to use
  33941. */
  33942. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33943. /**
  33944. * Gets the mesh under the pointer
  33945. * @returns a Mesh or null if no mesh is under the pointer
  33946. */
  33947. getPointerOverMesh(): Nullable<AbstractMesh>;
  33948. /** @hidden */
  33949. _rebuildGeometries(): void;
  33950. /** @hidden */
  33951. _rebuildTextures(): void;
  33952. private _getByTags;
  33953. /**
  33954. * Get a list of meshes by tags
  33955. * @param tagsQuery defines the tags query to use
  33956. * @param forEach defines a predicate used to filter results
  33957. * @returns an array of Mesh
  33958. */
  33959. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33960. /**
  33961. * Get a list of cameras by tags
  33962. * @param tagsQuery defines the tags query to use
  33963. * @param forEach defines a predicate used to filter results
  33964. * @returns an array of Camera
  33965. */
  33966. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33967. /**
  33968. * Get a list of lights by tags
  33969. * @param tagsQuery defines the tags query to use
  33970. * @param forEach defines a predicate used to filter results
  33971. * @returns an array of Light
  33972. */
  33973. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33974. /**
  33975. * Get a list of materials by tags
  33976. * @param tagsQuery defines the tags query to use
  33977. * @param forEach defines a predicate used to filter results
  33978. * @returns an array of Material
  33979. */
  33980. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33981. /**
  33982. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33983. * This allowed control for front to back rendering or reversly depending of the special needs.
  33984. *
  33985. * @param renderingGroupId The rendering group id corresponding to its index
  33986. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33987. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33988. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33989. */
  33990. 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;
  33991. /**
  33992. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33993. *
  33994. * @param renderingGroupId The rendering group id corresponding to its index
  33995. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33996. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33997. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33998. */
  33999. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34000. /**
  34001. * Gets the current auto clear configuration for one rendering group of the rendering
  34002. * manager.
  34003. * @param index the rendering group index to get the information for
  34004. * @returns The auto clear setup for the requested rendering group
  34005. */
  34006. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34007. private _blockMaterialDirtyMechanism;
  34008. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34009. blockMaterialDirtyMechanism: boolean;
  34010. /**
  34011. * Will flag all materials as dirty to trigger new shader compilation
  34012. * @param flag defines the flag used to specify which material part must be marked as dirty
  34013. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34014. */
  34015. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34016. /** @hidden */
  34017. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  34018. /** @hidden */
  34019. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34020. }
  34021. }
  34022. declare module "babylonjs/assetContainer" {
  34023. import { AbstractScene } from "babylonjs/abstractScene";
  34024. import { Scene } from "babylonjs/scene";
  34025. import { Mesh } from "babylonjs/Meshes/mesh";
  34026. /**
  34027. * Set of assets to keep when moving a scene into an asset container.
  34028. */
  34029. export class KeepAssets extends AbstractScene {
  34030. }
  34031. /**
  34032. * Container with a set of assets that can be added or removed from a scene.
  34033. */
  34034. export class AssetContainer extends AbstractScene {
  34035. /**
  34036. * The scene the AssetContainer belongs to.
  34037. */
  34038. scene: Scene;
  34039. /**
  34040. * Instantiates an AssetContainer.
  34041. * @param scene The scene the AssetContainer belongs to.
  34042. */
  34043. constructor(scene: Scene);
  34044. /**
  34045. * Adds all the assets from the container to the scene.
  34046. */
  34047. addAllToScene(): void;
  34048. /**
  34049. * Removes all the assets in the container from the scene
  34050. */
  34051. removeAllFromScene(): void;
  34052. /**
  34053. * Disposes all the assets in the container
  34054. */
  34055. dispose(): void;
  34056. private _moveAssets;
  34057. /**
  34058. * Removes all the assets contained in the scene and adds them to the container.
  34059. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34060. */
  34061. moveAllFromScene(keepAssets?: KeepAssets): void;
  34062. /**
  34063. * 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.
  34064. * @returns the root mesh
  34065. */
  34066. createRootMesh(): Mesh;
  34067. }
  34068. }
  34069. declare module "babylonjs/abstractScene" {
  34070. import { Scene } from "babylonjs/scene";
  34071. import { Nullable } from "babylonjs/types";
  34072. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34073. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34074. import { Geometry } from "babylonjs/Meshes/geometry";
  34075. import { Skeleton } from "babylonjs/Bones/skeleton";
  34076. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34077. import { AssetContainer } from "babylonjs/assetContainer";
  34078. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34079. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34080. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34081. import { Material } from "babylonjs/Materials/material";
  34082. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34083. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34084. import { Camera } from "babylonjs/Cameras/camera";
  34085. import { Light } from "babylonjs/Lights/light";
  34086. import { Node } from "babylonjs/node";
  34087. import { Animation } from "babylonjs/Animations/animation";
  34088. /**
  34089. * Defines how the parser contract is defined.
  34090. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34091. */
  34092. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34093. /**
  34094. * Defines how the individual parser contract is defined.
  34095. * These parser can parse an individual asset
  34096. */
  34097. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34098. /**
  34099. * Base class of the scene acting as a container for the different elements composing a scene.
  34100. * This class is dynamically extended by the different components of the scene increasing
  34101. * flexibility and reducing coupling
  34102. */
  34103. export abstract class AbstractScene {
  34104. /**
  34105. * Stores the list of available parsers in the application.
  34106. */
  34107. private static _BabylonFileParsers;
  34108. /**
  34109. * Stores the list of available individual parsers in the application.
  34110. */
  34111. private static _IndividualBabylonFileParsers;
  34112. /**
  34113. * Adds a parser in the list of available ones
  34114. * @param name Defines the name of the parser
  34115. * @param parser Defines the parser to add
  34116. */
  34117. static AddParser(name: string, parser: BabylonFileParser): void;
  34118. /**
  34119. * Gets a general parser from the list of avaialble ones
  34120. * @param name Defines the name of the parser
  34121. * @returns the requested parser or null
  34122. */
  34123. static GetParser(name: string): Nullable<BabylonFileParser>;
  34124. /**
  34125. * Adds n individual parser in the list of available ones
  34126. * @param name Defines the name of the parser
  34127. * @param parser Defines the parser to add
  34128. */
  34129. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34130. /**
  34131. * Gets an individual parser from the list of avaialble ones
  34132. * @param name Defines the name of the parser
  34133. * @returns the requested parser or null
  34134. */
  34135. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34136. /**
  34137. * Parser json data and populate both a scene and its associated container object
  34138. * @param jsonData Defines the data to parse
  34139. * @param scene Defines the scene to parse the data for
  34140. * @param container Defines the container attached to the parsing sequence
  34141. * @param rootUrl Defines the root url of the data
  34142. */
  34143. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34144. /**
  34145. * Gets the list of root nodes (ie. nodes with no parent)
  34146. */
  34147. rootNodes: Node[];
  34148. /** All of the cameras added to this scene
  34149. * @see http://doc.babylonjs.com/babylon101/cameras
  34150. */
  34151. cameras: Camera[];
  34152. /**
  34153. * All of the lights added to this scene
  34154. * @see http://doc.babylonjs.com/babylon101/lights
  34155. */
  34156. lights: Light[];
  34157. /**
  34158. * All of the (abstract) meshes added to this scene
  34159. */
  34160. meshes: AbstractMesh[];
  34161. /**
  34162. * The list of skeletons added to the scene
  34163. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34164. */
  34165. skeletons: Skeleton[];
  34166. /**
  34167. * All of the particle systems added to this scene
  34168. * @see http://doc.babylonjs.com/babylon101/particles
  34169. */
  34170. particleSystems: IParticleSystem[];
  34171. /**
  34172. * Gets a list of Animations associated with the scene
  34173. */
  34174. animations: Animation[];
  34175. /**
  34176. * All of the animation groups added to this scene
  34177. * @see http://doc.babylonjs.com/how_to/group
  34178. */
  34179. animationGroups: AnimationGroup[];
  34180. /**
  34181. * All of the multi-materials added to this scene
  34182. * @see http://doc.babylonjs.com/how_to/multi_materials
  34183. */
  34184. multiMaterials: MultiMaterial[];
  34185. /**
  34186. * All of the materials added to this scene
  34187. * In the context of a Scene, it is not supposed to be modified manually.
  34188. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34189. * Note also that the order of the Material wihin the array is not significant and might change.
  34190. * @see http://doc.babylonjs.com/babylon101/materials
  34191. */
  34192. materials: Material[];
  34193. /**
  34194. * The list of morph target managers added to the scene
  34195. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34196. */
  34197. morphTargetManagers: MorphTargetManager[];
  34198. /**
  34199. * The list of geometries used in the scene.
  34200. */
  34201. geometries: Geometry[];
  34202. /**
  34203. * All of the tranform nodes added to this scene
  34204. * In the context of a Scene, it is not supposed to be modified manually.
  34205. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34206. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34207. * @see http://doc.babylonjs.com/how_to/transformnode
  34208. */
  34209. transformNodes: TransformNode[];
  34210. /**
  34211. * ActionManagers available on the scene.
  34212. */
  34213. actionManagers: AbstractActionManager[];
  34214. /**
  34215. * Textures to keep.
  34216. */
  34217. textures: BaseTexture[];
  34218. }
  34219. }
  34220. declare module "babylonjs/Audio/sound" {
  34221. import { Observable } from "babylonjs/Misc/observable";
  34222. import { Vector3 } from "babylonjs/Maths/math";
  34223. import { Nullable } from "babylonjs/types";
  34224. import { Scene } from "babylonjs/scene";
  34225. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34226. /**
  34227. * Defines a sound that can be played in the application.
  34228. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34229. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34230. */
  34231. export class Sound {
  34232. /**
  34233. * The name of the sound in the scene.
  34234. */
  34235. name: string;
  34236. /**
  34237. * Does the sound autoplay once loaded.
  34238. */
  34239. autoplay: boolean;
  34240. /**
  34241. * Does the sound loop after it finishes playing once.
  34242. */
  34243. loop: boolean;
  34244. /**
  34245. * Does the sound use a custom attenuation curve to simulate the falloff
  34246. * happening when the source gets further away from the camera.
  34247. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34248. */
  34249. useCustomAttenuation: boolean;
  34250. /**
  34251. * The sound track id this sound belongs to.
  34252. */
  34253. soundTrackId: number;
  34254. /**
  34255. * Is this sound currently played.
  34256. */
  34257. isPlaying: boolean;
  34258. /**
  34259. * Is this sound currently paused.
  34260. */
  34261. isPaused: boolean;
  34262. /**
  34263. * Does this sound enables spatial sound.
  34264. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34265. */
  34266. spatialSound: boolean;
  34267. /**
  34268. * Define the reference distance the sound should be heard perfectly.
  34269. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34270. */
  34271. refDistance: number;
  34272. /**
  34273. * Define the roll off factor of spatial sounds.
  34274. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34275. */
  34276. rolloffFactor: number;
  34277. /**
  34278. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34279. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34280. */
  34281. maxDistance: number;
  34282. /**
  34283. * Define the distance attenuation model the sound will follow.
  34284. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34285. */
  34286. distanceModel: string;
  34287. /**
  34288. * @hidden
  34289. * Back Compat
  34290. **/
  34291. onended: () => any;
  34292. /**
  34293. * Observable event when the current playing sound finishes.
  34294. */
  34295. onEndedObservable: Observable<Sound>;
  34296. private _panningModel;
  34297. private _playbackRate;
  34298. private _streaming;
  34299. private _startTime;
  34300. private _startOffset;
  34301. private _position;
  34302. /** @hidden */
  34303. _positionInEmitterSpace: boolean;
  34304. private _localDirection;
  34305. private _volume;
  34306. private _isReadyToPlay;
  34307. private _isDirectional;
  34308. private _readyToPlayCallback;
  34309. private _audioBuffer;
  34310. private _soundSource;
  34311. private _streamingSource;
  34312. private _soundPanner;
  34313. private _soundGain;
  34314. private _inputAudioNode;
  34315. private _outputAudioNode;
  34316. private _coneInnerAngle;
  34317. private _coneOuterAngle;
  34318. private _coneOuterGain;
  34319. private _scene;
  34320. private _connectedTransformNode;
  34321. private _customAttenuationFunction;
  34322. private _registerFunc;
  34323. private _isOutputConnected;
  34324. private _htmlAudioElement;
  34325. private _urlType;
  34326. /** @hidden */
  34327. static _SceneComponentInitialization: (scene: Scene) => void;
  34328. /**
  34329. * Create a sound and attach it to a scene
  34330. * @param name Name of your sound
  34331. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34332. * @param scene defines the scene the sound belongs to
  34333. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34334. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34335. */
  34336. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  34337. /**
  34338. * Release the sound and its associated resources
  34339. */
  34340. dispose(): void;
  34341. /**
  34342. * Gets if the sounds is ready to be played or not.
  34343. * @returns true if ready, otherwise false
  34344. */
  34345. isReady(): boolean;
  34346. private _soundLoaded;
  34347. /**
  34348. * Sets the data of the sound from an audiobuffer
  34349. * @param audioBuffer The audioBuffer containing the data
  34350. */
  34351. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34352. /**
  34353. * Updates the current sounds options such as maxdistance, loop...
  34354. * @param options A JSON object containing values named as the object properties
  34355. */
  34356. updateOptions(options: any): void;
  34357. private _createSpatialParameters;
  34358. private _updateSpatialParameters;
  34359. /**
  34360. * Switch the panning model to HRTF:
  34361. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34362. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34363. */
  34364. switchPanningModelToHRTF(): void;
  34365. /**
  34366. * Switch the panning model to Equal Power:
  34367. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34368. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34369. */
  34370. switchPanningModelToEqualPower(): void;
  34371. private _switchPanningModel;
  34372. /**
  34373. * Connect this sound to a sound track audio node like gain...
  34374. * @param soundTrackAudioNode the sound track audio node to connect to
  34375. */
  34376. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34377. /**
  34378. * Transform this sound into a directional source
  34379. * @param coneInnerAngle Size of the inner cone in degree
  34380. * @param coneOuterAngle Size of the outer cone in degree
  34381. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34382. */
  34383. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34384. /**
  34385. * Gets or sets the inner angle for the directional cone.
  34386. */
  34387. /**
  34388. * Gets or sets the inner angle for the directional cone.
  34389. */
  34390. directionalConeInnerAngle: number;
  34391. /**
  34392. * Gets or sets the outer angle for the directional cone.
  34393. */
  34394. /**
  34395. * Gets or sets the outer angle for the directional cone.
  34396. */
  34397. directionalConeOuterAngle: number;
  34398. /**
  34399. * Sets the position of the emitter if spatial sound is enabled
  34400. * @param newPosition Defines the new posisiton
  34401. */
  34402. setPosition(newPosition: Vector3): void;
  34403. /**
  34404. * Sets the local direction of the emitter if spatial sound is enabled
  34405. * @param newLocalDirection Defines the new local direction
  34406. */
  34407. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34408. private _updateDirection;
  34409. /** @hidden */
  34410. updateDistanceFromListener(): void;
  34411. /**
  34412. * Sets a new custom attenuation function for the sound.
  34413. * @param callback Defines the function used for the attenuation
  34414. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34415. */
  34416. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34417. /**
  34418. * Play the sound
  34419. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34420. * @param offset (optional) Start the sound setting it at a specific time
  34421. */
  34422. play(time?: number, offset?: number): void;
  34423. private _onended;
  34424. /**
  34425. * Stop the sound
  34426. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34427. */
  34428. stop(time?: number): void;
  34429. /**
  34430. * Put the sound in pause
  34431. */
  34432. pause(): void;
  34433. /**
  34434. * Sets a dedicated volume for this sounds
  34435. * @param newVolume Define the new volume of the sound
  34436. * @param time Define in how long the sound should be at this value
  34437. */
  34438. setVolume(newVolume: number, time?: number): void;
  34439. /**
  34440. * Set the sound play back rate
  34441. * @param newPlaybackRate Define the playback rate the sound should be played at
  34442. */
  34443. setPlaybackRate(newPlaybackRate: number): void;
  34444. /**
  34445. * Gets the volume of the sound.
  34446. * @returns the volume of the sound
  34447. */
  34448. getVolume(): number;
  34449. /**
  34450. * Attach the sound to a dedicated mesh
  34451. * @param transformNode The transform node to connect the sound with
  34452. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34453. */
  34454. attachToMesh(transformNode: TransformNode): void;
  34455. /**
  34456. * Detach the sound from the previously attached mesh
  34457. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34458. */
  34459. detachFromMesh(): void;
  34460. private _onRegisterAfterWorldMatrixUpdate;
  34461. /**
  34462. * Clone the current sound in the scene.
  34463. * @returns the new sound clone
  34464. */
  34465. clone(): Nullable<Sound>;
  34466. /**
  34467. * Gets the current underlying audio buffer containing the data
  34468. * @returns the audio buffer
  34469. */
  34470. getAudioBuffer(): Nullable<AudioBuffer>;
  34471. /**
  34472. * Serializes the Sound in a JSON representation
  34473. * @returns the JSON representation of the sound
  34474. */
  34475. serialize(): any;
  34476. /**
  34477. * Parse a JSON representation of a sound to innstantiate in a given scene
  34478. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34479. * @param scene Define the scene the new parsed sound should be created in
  34480. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34481. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34482. * @returns the newly parsed sound
  34483. */
  34484. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34485. }
  34486. }
  34487. declare module "babylonjs/Actions/directAudioActions" {
  34488. import { Action } from "babylonjs/Actions/action";
  34489. import { Condition } from "babylonjs/Actions/condition";
  34490. import { Sound } from "babylonjs/Audio/sound";
  34491. /**
  34492. * This defines an action helpful to play a defined sound on a triggered action.
  34493. */
  34494. export class PlaySoundAction extends Action {
  34495. private _sound;
  34496. /**
  34497. * Instantiate the action
  34498. * @param triggerOptions defines the trigger options
  34499. * @param sound defines the sound to play
  34500. * @param condition defines the trigger related conditions
  34501. */
  34502. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34503. /** @hidden */
  34504. _prepare(): void;
  34505. /**
  34506. * Execute the action and play the sound.
  34507. */
  34508. execute(): void;
  34509. /**
  34510. * Serializes the actions and its related information.
  34511. * @param parent defines the object to serialize in
  34512. * @returns the serialized object
  34513. */
  34514. serialize(parent: any): any;
  34515. }
  34516. /**
  34517. * This defines an action helpful to stop a defined sound on a triggered action.
  34518. */
  34519. export class StopSoundAction extends Action {
  34520. private _sound;
  34521. /**
  34522. * Instantiate the action
  34523. * @param triggerOptions defines the trigger options
  34524. * @param sound defines the sound to stop
  34525. * @param condition defines the trigger related conditions
  34526. */
  34527. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34528. /** @hidden */
  34529. _prepare(): void;
  34530. /**
  34531. * Execute the action and stop the sound.
  34532. */
  34533. execute(): void;
  34534. /**
  34535. * Serializes the actions and its related information.
  34536. * @param parent defines the object to serialize in
  34537. * @returns the serialized object
  34538. */
  34539. serialize(parent: any): any;
  34540. }
  34541. }
  34542. declare module "babylonjs/Actions/interpolateValueAction" {
  34543. import { Action } from "babylonjs/Actions/action";
  34544. import { Condition } from "babylonjs/Actions/condition";
  34545. import { Observable } from "babylonjs/Misc/observable";
  34546. /**
  34547. * This defines an action responsible to change the value of a property
  34548. * by interpolating between its current value and the newly set one once triggered.
  34549. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34550. */
  34551. export class InterpolateValueAction extends Action {
  34552. /**
  34553. * Defines the path of the property where the value should be interpolated
  34554. */
  34555. propertyPath: string;
  34556. /**
  34557. * Defines the target value at the end of the interpolation.
  34558. */
  34559. value: any;
  34560. /**
  34561. * Defines the time it will take for the property to interpolate to the value.
  34562. */
  34563. duration: number;
  34564. /**
  34565. * Defines if the other scene animations should be stopped when the action has been triggered
  34566. */
  34567. stopOtherAnimations?: boolean;
  34568. /**
  34569. * Defines a callback raised once the interpolation animation has been done.
  34570. */
  34571. onInterpolationDone?: () => void;
  34572. /**
  34573. * Observable triggered once the interpolation animation has been done.
  34574. */
  34575. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34576. private _target;
  34577. private _effectiveTarget;
  34578. private _property;
  34579. /**
  34580. * Instantiate the action
  34581. * @param triggerOptions defines the trigger options
  34582. * @param target defines the object containing the value to interpolate
  34583. * @param propertyPath defines the path to the property in the target object
  34584. * @param value defines the target value at the end of the interpolation
  34585. * @param duration deines the time it will take for the property to interpolate to the value.
  34586. * @param condition defines the trigger related conditions
  34587. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34588. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34589. */
  34590. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34591. /** @hidden */
  34592. _prepare(): void;
  34593. /**
  34594. * Execute the action starts the value interpolation.
  34595. */
  34596. execute(): void;
  34597. /**
  34598. * Serializes the actions and its related information.
  34599. * @param parent defines the object to serialize in
  34600. * @returns the serialized object
  34601. */
  34602. serialize(parent: any): any;
  34603. }
  34604. }
  34605. declare module "babylonjs/Actions/index" {
  34606. export * from "babylonjs/Actions/action";
  34607. export * from "babylonjs/Actions/actionEvent";
  34608. export * from "babylonjs/Actions/actionManager";
  34609. export * from "babylonjs/Actions/condition";
  34610. export * from "babylonjs/Actions/directActions";
  34611. export * from "babylonjs/Actions/directAudioActions";
  34612. export * from "babylonjs/Actions/interpolateValueAction";
  34613. }
  34614. declare module "babylonjs/Animations/index" {
  34615. export * from "babylonjs/Animations/animatable";
  34616. export * from "babylonjs/Animations/animation";
  34617. export * from "babylonjs/Animations/animationGroup";
  34618. export * from "babylonjs/Animations/animationPropertiesOverride";
  34619. export * from "babylonjs/Animations/easing";
  34620. export * from "babylonjs/Animations/runtimeAnimation";
  34621. export * from "babylonjs/Animations/animationEvent";
  34622. export * from "babylonjs/Animations/animationGroup";
  34623. export * from "babylonjs/Animations/animationKey";
  34624. export * from "babylonjs/Animations/animationRange";
  34625. }
  34626. declare module "babylonjs/Audio/soundTrack" {
  34627. import { Sound } from "babylonjs/Audio/sound";
  34628. import { Analyser } from "babylonjs/Audio/analyser";
  34629. import { Scene } from "babylonjs/scene";
  34630. /**
  34631. * Options allowed during the creation of a sound track.
  34632. */
  34633. export interface ISoundTrackOptions {
  34634. /**
  34635. * The volume the sound track should take during creation
  34636. */
  34637. volume?: number;
  34638. /**
  34639. * Define if the sound track is the main sound track of the scene
  34640. */
  34641. mainTrack?: boolean;
  34642. }
  34643. /**
  34644. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34645. * It will be also used in a future release to apply effects on a specific track.
  34646. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34647. */
  34648. export class SoundTrack {
  34649. /**
  34650. * The unique identifier of the sound track in the scene.
  34651. */
  34652. id: number;
  34653. /**
  34654. * The list of sounds included in the sound track.
  34655. */
  34656. soundCollection: Array<Sound>;
  34657. private _outputAudioNode;
  34658. private _scene;
  34659. private _isMainTrack;
  34660. private _connectedAnalyser;
  34661. private _options;
  34662. private _isInitialized;
  34663. /**
  34664. * Creates a new sound track.
  34665. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34666. * @param scene Define the scene the sound track belongs to
  34667. * @param options
  34668. */
  34669. constructor(scene: Scene, options?: ISoundTrackOptions);
  34670. private _initializeSoundTrackAudioGraph;
  34671. /**
  34672. * Release the sound track and its associated resources
  34673. */
  34674. dispose(): void;
  34675. /**
  34676. * Adds a sound to this sound track
  34677. * @param sound define the cound to add
  34678. * @ignoreNaming
  34679. */
  34680. AddSound(sound: Sound): void;
  34681. /**
  34682. * Removes a sound to this sound track
  34683. * @param sound define the cound to remove
  34684. * @ignoreNaming
  34685. */
  34686. RemoveSound(sound: Sound): void;
  34687. /**
  34688. * Set a global volume for the full sound track.
  34689. * @param newVolume Define the new volume of the sound track
  34690. */
  34691. setVolume(newVolume: number): void;
  34692. /**
  34693. * Switch the panning model to HRTF:
  34694. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34695. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34696. */
  34697. switchPanningModelToHRTF(): void;
  34698. /**
  34699. * Switch the panning model to Equal Power:
  34700. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34701. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34702. */
  34703. switchPanningModelToEqualPower(): void;
  34704. /**
  34705. * Connect the sound track to an audio analyser allowing some amazing
  34706. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34707. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34708. * @param analyser The analyser to connect to the engine
  34709. */
  34710. connectToAnalyser(analyser: Analyser): void;
  34711. }
  34712. }
  34713. declare module "babylonjs/Audio/audioSceneComponent" {
  34714. import { Sound } from "babylonjs/Audio/sound";
  34715. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  34716. import { Nullable } from "babylonjs/types";
  34717. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  34718. import { Scene } from "babylonjs/scene";
  34719. import { AbstractScene } from "babylonjs/abstractScene";
  34720. module "babylonjs/abstractScene" {
  34721. interface AbstractScene {
  34722. /**
  34723. * The list of sounds used in the scene.
  34724. */
  34725. sounds: Nullable<Array<Sound>>;
  34726. }
  34727. }
  34728. module "babylonjs/scene" {
  34729. interface Scene {
  34730. /**
  34731. * @hidden
  34732. * Backing field
  34733. */
  34734. _mainSoundTrack: SoundTrack;
  34735. /**
  34736. * The main sound track played by the scene.
  34737. * It cotains your primary collection of sounds.
  34738. */
  34739. mainSoundTrack: SoundTrack;
  34740. /**
  34741. * The list of sound tracks added to the scene
  34742. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34743. */
  34744. soundTracks: Nullable<Array<SoundTrack>>;
  34745. /**
  34746. * Gets a sound using a given name
  34747. * @param name defines the name to search for
  34748. * @return the found sound or null if not found at all.
  34749. */
  34750. getSoundByName(name: string): Nullable<Sound>;
  34751. /**
  34752. * Gets or sets if audio support is enabled
  34753. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34754. */
  34755. audioEnabled: boolean;
  34756. /**
  34757. * Gets or sets if audio will be output to headphones
  34758. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34759. */
  34760. headphone: boolean;
  34761. }
  34762. }
  34763. /**
  34764. * Defines the sound scene component responsible to manage any sounds
  34765. * in a given scene.
  34766. */
  34767. export class AudioSceneComponent implements ISceneSerializableComponent {
  34768. /**
  34769. * The component name helpfull to identify the component in the list of scene components.
  34770. */
  34771. readonly name: string;
  34772. /**
  34773. * The scene the component belongs to.
  34774. */
  34775. scene: Scene;
  34776. private _audioEnabled;
  34777. /**
  34778. * Gets whether audio is enabled or not.
  34779. * Please use related enable/disable method to switch state.
  34780. */
  34781. readonly audioEnabled: boolean;
  34782. private _headphone;
  34783. /**
  34784. * Gets whether audio is outputing to headphone or not.
  34785. * Please use the according Switch methods to change output.
  34786. */
  34787. readonly headphone: boolean;
  34788. /**
  34789. * Creates a new instance of the component for the given scene
  34790. * @param scene Defines the scene to register the component in
  34791. */
  34792. constructor(scene: Scene);
  34793. /**
  34794. * Registers the component in a given scene
  34795. */
  34796. register(): void;
  34797. /**
  34798. * Rebuilds the elements related to this component in case of
  34799. * context lost for instance.
  34800. */
  34801. rebuild(): void;
  34802. /**
  34803. * Serializes the component data to the specified json object
  34804. * @param serializationObject The object to serialize to
  34805. */
  34806. serialize(serializationObject: any): void;
  34807. /**
  34808. * Adds all the element from the container to the scene
  34809. * @param container the container holding the elements
  34810. */
  34811. addFromContainer(container: AbstractScene): void;
  34812. /**
  34813. * Removes all the elements in the container from the scene
  34814. * @param container contains the elements to remove
  34815. */
  34816. removeFromContainer(container: AbstractScene): void;
  34817. /**
  34818. * Disposes the component and the associated ressources.
  34819. */
  34820. dispose(): void;
  34821. /**
  34822. * Disables audio in the associated scene.
  34823. */
  34824. disableAudio(): void;
  34825. /**
  34826. * Enables audio in the associated scene.
  34827. */
  34828. enableAudio(): void;
  34829. /**
  34830. * Switch audio to headphone output.
  34831. */
  34832. switchAudioModeForHeadphones(): void;
  34833. /**
  34834. * Switch audio to normal speakers.
  34835. */
  34836. switchAudioModeForNormalSpeakers(): void;
  34837. private _afterRender;
  34838. }
  34839. }
  34840. declare module "babylonjs/Audio/weightedsound" {
  34841. import { Sound } from "babylonjs/Audio/sound";
  34842. /**
  34843. * Wraps one or more Sound objects and selects one with random weight for playback.
  34844. */
  34845. export class WeightedSound {
  34846. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34847. loop: boolean;
  34848. private _coneInnerAngle;
  34849. private _coneOuterAngle;
  34850. private _volume;
  34851. /** A Sound is currently playing. */
  34852. isPlaying: boolean;
  34853. /** A Sound is currently paused. */
  34854. isPaused: boolean;
  34855. private _sounds;
  34856. private _weights;
  34857. private _currentIndex?;
  34858. /**
  34859. * Creates a new WeightedSound from the list of sounds given.
  34860. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34861. * @param sounds Array of Sounds that will be selected from.
  34862. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34863. */
  34864. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34865. /**
  34866. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34867. */
  34868. /**
  34869. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34870. */
  34871. directionalConeInnerAngle: number;
  34872. /**
  34873. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34874. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34875. */
  34876. /**
  34877. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34878. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34879. */
  34880. directionalConeOuterAngle: number;
  34881. /**
  34882. * Playback volume.
  34883. */
  34884. /**
  34885. * Playback volume.
  34886. */
  34887. volume: number;
  34888. private _onended;
  34889. /**
  34890. * Suspend playback
  34891. */
  34892. pause(): void;
  34893. /**
  34894. * Stop playback
  34895. */
  34896. stop(): void;
  34897. /**
  34898. * Start playback.
  34899. * @param startOffset Position the clip head at a specific time in seconds.
  34900. */
  34901. play(startOffset?: number): void;
  34902. }
  34903. }
  34904. declare module "babylonjs/Audio/index" {
  34905. export * from "babylonjs/Audio/analyser";
  34906. export * from "babylonjs/Audio/audioEngine";
  34907. export * from "babylonjs/Audio/audioSceneComponent";
  34908. export * from "babylonjs/Audio/sound";
  34909. export * from "babylonjs/Audio/soundTrack";
  34910. export * from "babylonjs/Audio/weightedsound";
  34911. }
  34912. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  34913. import { Behavior } from "babylonjs/Behaviors/behavior";
  34914. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34915. import { BackEase } from "babylonjs/Animations/easing";
  34916. /**
  34917. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34918. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34919. */
  34920. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34921. /**
  34922. * Gets the name of the behavior.
  34923. */
  34924. readonly name: string;
  34925. /**
  34926. * The easing function used by animations
  34927. */
  34928. static EasingFunction: BackEase;
  34929. /**
  34930. * The easing mode used by animations
  34931. */
  34932. static EasingMode: number;
  34933. /**
  34934. * The duration of the animation, in milliseconds
  34935. */
  34936. transitionDuration: number;
  34937. /**
  34938. * Length of the distance animated by the transition when lower radius is reached
  34939. */
  34940. lowerRadiusTransitionRange: number;
  34941. /**
  34942. * Length of the distance animated by the transition when upper radius is reached
  34943. */
  34944. upperRadiusTransitionRange: number;
  34945. private _autoTransitionRange;
  34946. /**
  34947. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34948. */
  34949. /**
  34950. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34951. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34952. */
  34953. autoTransitionRange: boolean;
  34954. private _attachedCamera;
  34955. private _onAfterCheckInputsObserver;
  34956. private _onMeshTargetChangedObserver;
  34957. /**
  34958. * Initializes the behavior.
  34959. */
  34960. init(): void;
  34961. /**
  34962. * Attaches the behavior to its arc rotate camera.
  34963. * @param camera Defines the camera to attach the behavior to
  34964. */
  34965. attach(camera: ArcRotateCamera): void;
  34966. /**
  34967. * Detaches the behavior from its current arc rotate camera.
  34968. */
  34969. detach(): void;
  34970. private _radiusIsAnimating;
  34971. private _radiusBounceTransition;
  34972. private _animatables;
  34973. private _cachedWheelPrecision;
  34974. /**
  34975. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34976. * @param radiusLimit The limit to check against.
  34977. * @return Bool to indicate if at limit.
  34978. */
  34979. private _isRadiusAtLimit;
  34980. /**
  34981. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34982. * @param radiusDelta The delta by which to animate to. Can be negative.
  34983. */
  34984. private _applyBoundRadiusAnimation;
  34985. /**
  34986. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34987. */
  34988. protected _clearAnimationLocks(): void;
  34989. /**
  34990. * Stops and removes all animations that have been applied to the camera
  34991. */
  34992. stopAllAnimations(): void;
  34993. }
  34994. }
  34995. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  34996. import { Behavior } from "babylonjs/Behaviors/behavior";
  34997. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34998. import { ExponentialEase } from "babylonjs/Animations/easing";
  34999. import { Nullable } from "babylonjs/types";
  35000. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35001. import { Vector3 } from "babylonjs/Maths/math";
  35002. /**
  35003. * 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.
  35004. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35005. */
  35006. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35007. /**
  35008. * Gets the name of the behavior.
  35009. */
  35010. readonly name: string;
  35011. private _mode;
  35012. private _radiusScale;
  35013. private _positionScale;
  35014. private _defaultElevation;
  35015. private _elevationReturnTime;
  35016. private _elevationReturnWaitTime;
  35017. private _zoomStopsAnimation;
  35018. private _framingTime;
  35019. /**
  35020. * The easing function used by animations
  35021. */
  35022. static EasingFunction: ExponentialEase;
  35023. /**
  35024. * The easing mode used by animations
  35025. */
  35026. static EasingMode: number;
  35027. /**
  35028. * Sets the current mode used by the behavior
  35029. */
  35030. /**
  35031. * Gets current mode used by the behavior.
  35032. */
  35033. mode: number;
  35034. /**
  35035. * Sets the scale applied to the radius (1 by default)
  35036. */
  35037. /**
  35038. * Gets the scale applied to the radius
  35039. */
  35040. radiusScale: number;
  35041. /**
  35042. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35043. */
  35044. /**
  35045. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35046. */
  35047. positionScale: number;
  35048. /**
  35049. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35050. * behaviour is triggered, in radians.
  35051. */
  35052. /**
  35053. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35054. * behaviour is triggered, in radians.
  35055. */
  35056. defaultElevation: number;
  35057. /**
  35058. * Sets the time (in milliseconds) taken to return to the default beta position.
  35059. * Negative value indicates camera should not return to default.
  35060. */
  35061. /**
  35062. * Gets the time (in milliseconds) taken to return to the default beta position.
  35063. * Negative value indicates camera should not return to default.
  35064. */
  35065. elevationReturnTime: number;
  35066. /**
  35067. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35068. */
  35069. /**
  35070. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35071. */
  35072. elevationReturnWaitTime: number;
  35073. /**
  35074. * Sets the flag that indicates if user zooming should stop animation.
  35075. */
  35076. /**
  35077. * Gets the flag that indicates if user zooming should stop animation.
  35078. */
  35079. zoomStopsAnimation: boolean;
  35080. /**
  35081. * Sets the transition time when framing the mesh, in milliseconds
  35082. */
  35083. /**
  35084. * Gets the transition time when framing the mesh, in milliseconds
  35085. */
  35086. framingTime: number;
  35087. /**
  35088. * Define if the behavior should automatically change the configured
  35089. * camera limits and sensibilities.
  35090. */
  35091. autoCorrectCameraLimitsAndSensibility: boolean;
  35092. private _onPrePointerObservableObserver;
  35093. private _onAfterCheckInputsObserver;
  35094. private _onMeshTargetChangedObserver;
  35095. private _attachedCamera;
  35096. private _isPointerDown;
  35097. private _lastInteractionTime;
  35098. /**
  35099. * Initializes the behavior.
  35100. */
  35101. init(): void;
  35102. /**
  35103. * Attaches the behavior to its arc rotate camera.
  35104. * @param camera Defines the camera to attach the behavior to
  35105. */
  35106. attach(camera: ArcRotateCamera): void;
  35107. /**
  35108. * Detaches the behavior from its current arc rotate camera.
  35109. */
  35110. detach(): void;
  35111. private _animatables;
  35112. private _betaIsAnimating;
  35113. private _betaTransition;
  35114. private _radiusTransition;
  35115. private _vectorTransition;
  35116. /**
  35117. * Targets the given mesh and updates zoom level accordingly.
  35118. * @param mesh The mesh to target.
  35119. * @param radius Optional. If a cached radius position already exists, overrides default.
  35120. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35121. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35122. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35123. */
  35124. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35125. /**
  35126. * Targets the given mesh with its children and updates zoom level accordingly.
  35127. * @param mesh The mesh to target.
  35128. * @param radius Optional. If a cached radius position already exists, overrides default.
  35129. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35130. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35131. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35132. */
  35133. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35134. /**
  35135. * Targets the given meshes with their children and updates zoom level accordingly.
  35136. * @param meshes The mesh to target.
  35137. * @param radius Optional. If a cached radius position already exists, overrides default.
  35138. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35139. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35140. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35141. */
  35142. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35143. /**
  35144. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35145. * @param minimumWorld Determines the smaller position of the bounding box extend
  35146. * @param maximumWorld Determines the bigger position of the bounding box extend
  35147. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35148. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35149. */
  35150. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35151. /**
  35152. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35153. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35154. * frustum width.
  35155. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35156. * to fully enclose the mesh in the viewing frustum.
  35157. */
  35158. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35159. /**
  35160. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35161. * is automatically returned to its default position (expected to be above ground plane).
  35162. */
  35163. private _maintainCameraAboveGround;
  35164. /**
  35165. * Returns the frustum slope based on the canvas ratio and camera FOV
  35166. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35167. */
  35168. private _getFrustumSlope;
  35169. /**
  35170. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35171. */
  35172. private _clearAnimationLocks;
  35173. /**
  35174. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35175. */
  35176. private _applyUserInteraction;
  35177. /**
  35178. * Stops and removes all animations that have been applied to the camera
  35179. */
  35180. stopAllAnimations(): void;
  35181. /**
  35182. * Gets a value indicating if the user is moving the camera
  35183. */
  35184. readonly isUserIsMoving: boolean;
  35185. /**
  35186. * The camera can move all the way towards the mesh.
  35187. */
  35188. static IgnoreBoundsSizeMode: number;
  35189. /**
  35190. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35191. */
  35192. static FitFrustumSidesMode: number;
  35193. }
  35194. }
  35195. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  35196. import { Nullable } from "babylonjs/types";
  35197. import { Camera } from "babylonjs/Cameras/camera";
  35198. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35199. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35200. /**
  35201. * Base class for Camera Pointer Inputs.
  35202. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35203. * for example usage.
  35204. */
  35205. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35206. /**
  35207. * Defines the camera the input is attached to.
  35208. */
  35209. abstract camera: Camera;
  35210. /**
  35211. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35212. */
  35213. protected _altKey: boolean;
  35214. protected _ctrlKey: boolean;
  35215. protected _metaKey: boolean;
  35216. protected _shiftKey: boolean;
  35217. /**
  35218. * Which mouse buttons were pressed at time of last mouse event.
  35219. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35220. */
  35221. protected _buttonsPressed: number;
  35222. /**
  35223. * Defines the buttons associated with the input to handle camera move.
  35224. */
  35225. buttons: number[];
  35226. /**
  35227. * Attach the input controls to a specific dom element to get the input from.
  35228. * @param element Defines the element the controls should be listened from
  35229. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35230. */
  35231. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35232. /**
  35233. * Detach the current controls from the specified dom element.
  35234. * @param element Defines the element to stop listening the inputs from
  35235. */
  35236. detachControl(element: Nullable<HTMLElement>): void;
  35237. /**
  35238. * Gets the class name of the current input.
  35239. * @returns the class name
  35240. */
  35241. getClassName(): string;
  35242. /**
  35243. * Get the friendly name associated with the input class.
  35244. * @returns the input friendly name
  35245. */
  35246. getSimpleName(): string;
  35247. /**
  35248. * Called on pointer POINTERDOUBLETAP event.
  35249. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35250. */
  35251. protected onDoubleTap(type: string): void;
  35252. /**
  35253. * Called on pointer POINTERMOVE event if only a single touch is active.
  35254. * Override this method to provide functionality.
  35255. */
  35256. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35257. /**
  35258. * Called on pointer POINTERMOVE event if multiple touches are active.
  35259. * Override this method to provide functionality.
  35260. */
  35261. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35262. /**
  35263. * Called on JS contextmenu event.
  35264. * Override this method to provide functionality.
  35265. */
  35266. protected onContextMenu(evt: PointerEvent): void;
  35267. /**
  35268. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35269. * press.
  35270. * Override this method to provide functionality.
  35271. */
  35272. protected onButtonDown(evt: PointerEvent): void;
  35273. /**
  35274. * Called each time a new POINTERUP event occurs. Ie, for each button
  35275. * release.
  35276. * Override this method to provide functionality.
  35277. */
  35278. protected onButtonUp(evt: PointerEvent): void;
  35279. /**
  35280. * Called when window becomes inactive.
  35281. * Override this method to provide functionality.
  35282. */
  35283. protected onLostFocus(): void;
  35284. private _pointerInput;
  35285. private _observer;
  35286. private _onLostFocus;
  35287. private pointA;
  35288. private pointB;
  35289. }
  35290. }
  35291. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  35292. import { Nullable } from "babylonjs/types";
  35293. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35294. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  35295. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35296. /**
  35297. * Manage the pointers inputs to control an arc rotate camera.
  35298. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35299. */
  35300. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35301. /**
  35302. * Defines the camera the input is attached to.
  35303. */
  35304. camera: ArcRotateCamera;
  35305. /**
  35306. * Gets the class name of the current input.
  35307. * @returns the class name
  35308. */
  35309. getClassName(): string;
  35310. /**
  35311. * Defines the buttons associated with the input to handle camera move.
  35312. */
  35313. buttons: number[];
  35314. /**
  35315. * Defines the pointer angular sensibility along the X axis or how fast is
  35316. * the camera rotating.
  35317. */
  35318. angularSensibilityX: number;
  35319. /**
  35320. * Defines the pointer angular sensibility along the Y axis or how fast is
  35321. * the camera rotating.
  35322. */
  35323. angularSensibilityY: number;
  35324. /**
  35325. * Defines the pointer pinch precision or how fast is the camera zooming.
  35326. */
  35327. pinchPrecision: number;
  35328. /**
  35329. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35330. * from 0.
  35331. * It defines the percentage of current camera.radius to use as delta when
  35332. * pinch zoom is used.
  35333. */
  35334. pinchDeltaPercentage: number;
  35335. /**
  35336. * Defines the pointer panning sensibility or how fast is the camera moving.
  35337. */
  35338. panningSensibility: number;
  35339. /**
  35340. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35341. */
  35342. multiTouchPanning: boolean;
  35343. /**
  35344. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35345. * zoom (pinch) through multitouch.
  35346. */
  35347. multiTouchPanAndZoom: boolean;
  35348. /**
  35349. * Revers pinch action direction.
  35350. */
  35351. pinchInwards: boolean;
  35352. private _isPanClick;
  35353. private _twoFingerActivityCount;
  35354. private _isPinching;
  35355. /**
  35356. * Called on pointer POINTERMOVE event if only a single touch is active.
  35357. */
  35358. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35359. /**
  35360. * Called on pointer POINTERDOUBLETAP event.
  35361. */
  35362. protected onDoubleTap(type: string): void;
  35363. /**
  35364. * Called on pointer POINTERMOVE event if multiple touches are active.
  35365. */
  35366. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35367. /**
  35368. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35369. * press.
  35370. */
  35371. protected onButtonDown(evt: PointerEvent): void;
  35372. /**
  35373. * Called each time a new POINTERUP event occurs. Ie, for each button
  35374. * release.
  35375. */
  35376. protected onButtonUp(evt: PointerEvent): void;
  35377. /**
  35378. * Called when window becomes inactive.
  35379. */
  35380. protected onLostFocus(): void;
  35381. }
  35382. }
  35383. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  35384. import { Nullable } from "babylonjs/types";
  35385. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35386. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35387. /**
  35388. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35389. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35390. */
  35391. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35392. /**
  35393. * Defines the camera the input is attached to.
  35394. */
  35395. camera: ArcRotateCamera;
  35396. /**
  35397. * Defines the list of key codes associated with the up action (increase alpha)
  35398. */
  35399. keysUp: number[];
  35400. /**
  35401. * Defines the list of key codes associated with the down action (decrease alpha)
  35402. */
  35403. keysDown: number[];
  35404. /**
  35405. * Defines the list of key codes associated with the left action (increase beta)
  35406. */
  35407. keysLeft: number[];
  35408. /**
  35409. * Defines the list of key codes associated with the right action (decrease beta)
  35410. */
  35411. keysRight: number[];
  35412. /**
  35413. * Defines the list of key codes associated with the reset action.
  35414. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35415. */
  35416. keysReset: number[];
  35417. /**
  35418. * Defines the panning sensibility of the inputs.
  35419. * (How fast is the camera paning)
  35420. */
  35421. panningSensibility: number;
  35422. /**
  35423. * Defines the zooming sensibility of the inputs.
  35424. * (How fast is the camera zooming)
  35425. */
  35426. zoomingSensibility: number;
  35427. /**
  35428. * Defines wether maintaining the alt key down switch the movement mode from
  35429. * orientation to zoom.
  35430. */
  35431. useAltToZoom: boolean;
  35432. /**
  35433. * Rotation speed of the camera
  35434. */
  35435. angularSpeed: number;
  35436. private _keys;
  35437. private _ctrlPressed;
  35438. private _altPressed;
  35439. private _onCanvasBlurObserver;
  35440. private _onKeyboardObserver;
  35441. private _engine;
  35442. private _scene;
  35443. /**
  35444. * Attach the input controls to a specific dom element to get the input from.
  35445. * @param element Defines the element the controls should be listened from
  35446. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35447. */
  35448. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35449. /**
  35450. * Detach the current controls from the specified dom element.
  35451. * @param element Defines the element to stop listening the inputs from
  35452. */
  35453. detachControl(element: Nullable<HTMLElement>): void;
  35454. /**
  35455. * Update the current camera state depending on the inputs that have been used this frame.
  35456. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35457. */
  35458. checkInputs(): void;
  35459. /**
  35460. * Gets the class name of the current intput.
  35461. * @returns the class name
  35462. */
  35463. getClassName(): string;
  35464. /**
  35465. * Get the friendly name associated with the input class.
  35466. * @returns the input friendly name
  35467. */
  35468. getSimpleName(): string;
  35469. }
  35470. }
  35471. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  35472. import { Nullable } from "babylonjs/types";
  35473. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35474. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35475. /**
  35476. * Manage the mouse wheel inputs to control an arc rotate camera.
  35477. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35478. */
  35479. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35480. /**
  35481. * Defines the camera the input is attached to.
  35482. */
  35483. camera: ArcRotateCamera;
  35484. /**
  35485. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35486. */
  35487. wheelPrecision: number;
  35488. /**
  35489. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35490. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35491. */
  35492. wheelDeltaPercentage: number;
  35493. private _wheel;
  35494. private _observer;
  35495. /**
  35496. * Attach the input controls to a specific dom element to get the input from.
  35497. * @param element Defines the element the controls should be listened from
  35498. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35499. */
  35500. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35501. /**
  35502. * Detach the current controls from the specified dom element.
  35503. * @param element Defines the element to stop listening the inputs from
  35504. */
  35505. detachControl(element: Nullable<HTMLElement>): void;
  35506. /**
  35507. * Gets the class name of the current intput.
  35508. * @returns the class name
  35509. */
  35510. getClassName(): string;
  35511. /**
  35512. * Get the friendly name associated with the input class.
  35513. * @returns the input friendly name
  35514. */
  35515. getSimpleName(): string;
  35516. }
  35517. }
  35518. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  35519. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35520. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  35521. /**
  35522. * Default Inputs manager for the ArcRotateCamera.
  35523. * It groups all the default supported inputs for ease of use.
  35524. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35525. */
  35526. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35527. /**
  35528. * Instantiates a new ArcRotateCameraInputsManager.
  35529. * @param camera Defines the camera the inputs belong to
  35530. */
  35531. constructor(camera: ArcRotateCamera);
  35532. /**
  35533. * Add mouse wheel input support to the input manager.
  35534. * @returns the current input manager
  35535. */
  35536. addMouseWheel(): ArcRotateCameraInputsManager;
  35537. /**
  35538. * Add pointers input support to the input manager.
  35539. * @returns the current input manager
  35540. */
  35541. addPointers(): ArcRotateCameraInputsManager;
  35542. /**
  35543. * Add keyboard input support to the input manager.
  35544. * @returns the current input manager
  35545. */
  35546. addKeyboard(): ArcRotateCameraInputsManager;
  35547. }
  35548. }
  35549. declare module "babylonjs/Cameras/arcRotateCamera" {
  35550. import { Observable } from "babylonjs/Misc/observable";
  35551. import { Nullable } from "babylonjs/types";
  35552. import { Scene } from "babylonjs/scene";
  35553. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  35554. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35555. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35556. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35557. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  35558. import { Camera } from "babylonjs/Cameras/camera";
  35559. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  35560. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  35561. import { Collider } from "babylonjs/Collisions/collider";
  35562. /**
  35563. * This represents an orbital type of camera.
  35564. *
  35565. * 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.
  35566. * 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.
  35567. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35568. */
  35569. export class ArcRotateCamera extends TargetCamera {
  35570. /**
  35571. * Defines the rotation angle of the camera along the longitudinal axis.
  35572. */
  35573. alpha: number;
  35574. /**
  35575. * Defines the rotation angle of the camera along the latitudinal axis.
  35576. */
  35577. beta: number;
  35578. /**
  35579. * Defines the radius of the camera from it s target point.
  35580. */
  35581. radius: number;
  35582. protected _target: Vector3;
  35583. protected _targetHost: Nullable<AbstractMesh>;
  35584. /**
  35585. * Defines the target point of the camera.
  35586. * The camera looks towards it form the radius distance.
  35587. */
  35588. target: Vector3;
  35589. /**
  35590. * Define the current local position of the camera in the scene
  35591. */
  35592. position: Vector3;
  35593. /**
  35594. * Current inertia value on the longitudinal axis.
  35595. * The bigger this number the longer it will take for the camera to stop.
  35596. */
  35597. inertialAlphaOffset: number;
  35598. /**
  35599. * Current inertia value on the latitudinal axis.
  35600. * The bigger this number the longer it will take for the camera to stop.
  35601. */
  35602. inertialBetaOffset: number;
  35603. /**
  35604. * Current inertia value on the radius axis.
  35605. * The bigger this number the longer it will take for the camera to stop.
  35606. */
  35607. inertialRadiusOffset: number;
  35608. /**
  35609. * Minimum allowed angle on the longitudinal axis.
  35610. * This can help limiting how the Camera is able to move in the scene.
  35611. */
  35612. lowerAlphaLimit: Nullable<number>;
  35613. /**
  35614. * Maximum allowed angle on the longitudinal axis.
  35615. * This can help limiting how the Camera is able to move in the scene.
  35616. */
  35617. upperAlphaLimit: Nullable<number>;
  35618. /**
  35619. * Minimum allowed angle on the latitudinal axis.
  35620. * This can help limiting how the Camera is able to move in the scene.
  35621. */
  35622. lowerBetaLimit: number;
  35623. /**
  35624. * Maximum allowed angle on the latitudinal axis.
  35625. * This can help limiting how the Camera is able to move in the scene.
  35626. */
  35627. upperBetaLimit: number;
  35628. /**
  35629. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35630. * This can help limiting how the Camera is able to move in the scene.
  35631. */
  35632. lowerRadiusLimit: Nullable<number>;
  35633. /**
  35634. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35635. * This can help limiting how the Camera is able to move in the scene.
  35636. */
  35637. upperRadiusLimit: Nullable<number>;
  35638. /**
  35639. * Defines the current inertia value used during panning of the camera along the X axis.
  35640. */
  35641. inertialPanningX: number;
  35642. /**
  35643. * Defines the current inertia value used during panning of the camera along the Y axis.
  35644. */
  35645. inertialPanningY: number;
  35646. /**
  35647. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35648. * Basically if your fingers moves away from more than this distance you will be considered
  35649. * in pinch mode.
  35650. */
  35651. pinchToPanMaxDistance: number;
  35652. /**
  35653. * Defines the maximum distance the camera can pan.
  35654. * This could help keeping the cammera always in your scene.
  35655. */
  35656. panningDistanceLimit: Nullable<number>;
  35657. /**
  35658. * Defines the target of the camera before paning.
  35659. */
  35660. panningOriginTarget: Vector3;
  35661. /**
  35662. * Defines the value of the inertia used during panning.
  35663. * 0 would mean stop inertia and one would mean no decelleration at all.
  35664. */
  35665. panningInertia: number;
  35666. /**
  35667. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35668. */
  35669. angularSensibilityX: number;
  35670. /**
  35671. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35672. */
  35673. angularSensibilityY: number;
  35674. /**
  35675. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35676. */
  35677. pinchPrecision: number;
  35678. /**
  35679. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35680. * It will be used instead of pinchDeltaPrecision if different from 0.
  35681. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35682. */
  35683. pinchDeltaPercentage: number;
  35684. /**
  35685. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35686. */
  35687. panningSensibility: number;
  35688. /**
  35689. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35690. */
  35691. keysUp: number[];
  35692. /**
  35693. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35694. */
  35695. keysDown: number[];
  35696. /**
  35697. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35698. */
  35699. keysLeft: number[];
  35700. /**
  35701. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35702. */
  35703. keysRight: number[];
  35704. /**
  35705. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35706. */
  35707. wheelPrecision: number;
  35708. /**
  35709. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35710. * It will be used instead of pinchDeltaPrecision if different from 0.
  35711. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35712. */
  35713. wheelDeltaPercentage: number;
  35714. /**
  35715. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35716. */
  35717. zoomOnFactor: number;
  35718. /**
  35719. * Defines a screen offset for the camera position.
  35720. */
  35721. targetScreenOffset: Vector2;
  35722. /**
  35723. * Allows the camera to be completely reversed.
  35724. * If false the camera can not arrive upside down.
  35725. */
  35726. allowUpsideDown: boolean;
  35727. /**
  35728. * Define if double tap/click is used to restore the previously saved state of the camera.
  35729. */
  35730. useInputToRestoreState: boolean;
  35731. /** @hidden */
  35732. _viewMatrix: Matrix;
  35733. /** @hidden */
  35734. _useCtrlForPanning: boolean;
  35735. /** @hidden */
  35736. _panningMouseButton: number;
  35737. /**
  35738. * Defines the input associated to the camera.
  35739. */
  35740. inputs: ArcRotateCameraInputsManager;
  35741. /** @hidden */
  35742. _reset: () => void;
  35743. /**
  35744. * Defines the allowed panning axis.
  35745. */
  35746. panningAxis: Vector3;
  35747. protected _localDirection: Vector3;
  35748. protected _transformedDirection: Vector3;
  35749. private _bouncingBehavior;
  35750. /**
  35751. * Gets the bouncing behavior of the camera if it has been enabled.
  35752. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35753. */
  35754. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35755. /**
  35756. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35757. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35758. */
  35759. useBouncingBehavior: boolean;
  35760. private _framingBehavior;
  35761. /**
  35762. * Gets the framing behavior of the camera if it has been enabled.
  35763. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35764. */
  35765. readonly framingBehavior: Nullable<FramingBehavior>;
  35766. /**
  35767. * Defines if the framing behavior of the camera is enabled on the camera.
  35768. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35769. */
  35770. useFramingBehavior: boolean;
  35771. private _autoRotationBehavior;
  35772. /**
  35773. * Gets the auto rotation behavior of the camera if it has been enabled.
  35774. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35775. */
  35776. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35777. /**
  35778. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35779. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35780. */
  35781. useAutoRotationBehavior: boolean;
  35782. /**
  35783. * Observable triggered when the mesh target has been changed on the camera.
  35784. */
  35785. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35786. /**
  35787. * Event raised when the camera is colliding with a mesh.
  35788. */
  35789. onCollide: (collidedMesh: AbstractMesh) => void;
  35790. /**
  35791. * Defines whether the camera should check collision with the objects oh the scene.
  35792. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35793. */
  35794. checkCollisions: boolean;
  35795. /**
  35796. * Defines the collision radius of the camera.
  35797. * This simulates a sphere around the camera.
  35798. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35799. */
  35800. collisionRadius: Vector3;
  35801. protected _collider: Collider;
  35802. protected _previousPosition: Vector3;
  35803. protected _collisionVelocity: Vector3;
  35804. protected _newPosition: Vector3;
  35805. protected _previousAlpha: number;
  35806. protected _previousBeta: number;
  35807. protected _previousRadius: number;
  35808. protected _collisionTriggered: boolean;
  35809. protected _targetBoundingCenter: Nullable<Vector3>;
  35810. private _computationVector;
  35811. private _tempAxisVector;
  35812. private _tempAxisRotationMatrix;
  35813. /**
  35814. * Instantiates a new ArcRotateCamera in a given scene
  35815. * @param name Defines the name of the camera
  35816. * @param alpha Defines the camera rotation along the logitudinal axis
  35817. * @param beta Defines the camera rotation along the latitudinal axis
  35818. * @param radius Defines the camera distance from its target
  35819. * @param target Defines the camera target
  35820. * @param scene Defines the scene the camera belongs to
  35821. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35822. */
  35823. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35824. /** @hidden */
  35825. _initCache(): void;
  35826. /** @hidden */
  35827. _updateCache(ignoreParentClass?: boolean): void;
  35828. protected _getTargetPosition(): Vector3;
  35829. private _storedAlpha;
  35830. private _storedBeta;
  35831. private _storedRadius;
  35832. private _storedTarget;
  35833. /**
  35834. * Stores the current state of the camera (alpha, beta, radius and target)
  35835. * @returns the camera itself
  35836. */
  35837. storeState(): Camera;
  35838. /**
  35839. * @hidden
  35840. * Restored camera state. You must call storeState() first
  35841. */
  35842. _restoreStateValues(): boolean;
  35843. /** @hidden */
  35844. _isSynchronizedViewMatrix(): boolean;
  35845. /**
  35846. * Attached controls to the current camera.
  35847. * @param element Defines the element the controls should be listened from
  35848. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35849. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35850. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35851. */
  35852. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35853. /**
  35854. * Detach the current controls from the camera.
  35855. * The camera will stop reacting to inputs.
  35856. * @param element Defines the element to stop listening the inputs from
  35857. */
  35858. detachControl(element: HTMLElement): void;
  35859. /** @hidden */
  35860. _checkInputs(): void;
  35861. protected _checkLimits(): void;
  35862. /**
  35863. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35864. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  35865. */
  35866. rebuildAnglesAndRadius(updateView?: boolean): void;
  35867. /**
  35868. * Use a position to define the current camera related information like aplha, beta and radius
  35869. * @param position Defines the position to set the camera at
  35870. */
  35871. setPosition(position: Vector3): void;
  35872. /**
  35873. * Defines the target the camera should look at.
  35874. * This will automatically adapt alpha beta and radius to fit within the new target.
  35875. * @param target Defines the new target as a Vector or a mesh
  35876. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35877. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35878. */
  35879. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35880. /** @hidden */
  35881. _getViewMatrix(): Matrix;
  35882. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35883. /**
  35884. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35885. * @param meshes Defines the mesh to zoom on
  35886. * @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)
  35887. */
  35888. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35889. /**
  35890. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35891. * The target will be changed but the radius
  35892. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35893. * @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)
  35894. */
  35895. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35896. min: Vector3;
  35897. max: Vector3;
  35898. distance: number;
  35899. }, doNotUpdateMaxZ?: boolean): void;
  35900. /**
  35901. * @override
  35902. * Override Camera.createRigCamera
  35903. */
  35904. createRigCamera(name: string, cameraIndex: number): Camera;
  35905. /**
  35906. * @hidden
  35907. * @override
  35908. * Override Camera._updateRigCameras
  35909. */
  35910. _updateRigCameras(): void;
  35911. /**
  35912. * Destroy the camera and release the current resources hold by it.
  35913. */
  35914. dispose(): void;
  35915. /**
  35916. * Gets the current object class name.
  35917. * @return the class name
  35918. */
  35919. getClassName(): string;
  35920. }
  35921. }
  35922. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  35923. import { Behavior } from "babylonjs/Behaviors/behavior";
  35924. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35925. /**
  35926. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35927. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35928. */
  35929. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35930. /**
  35931. * Gets the name of the behavior.
  35932. */
  35933. readonly name: string;
  35934. private _zoomStopsAnimation;
  35935. private _idleRotationSpeed;
  35936. private _idleRotationWaitTime;
  35937. private _idleRotationSpinupTime;
  35938. /**
  35939. * Sets the flag that indicates if user zooming should stop animation.
  35940. */
  35941. /**
  35942. * Gets the flag that indicates if user zooming should stop animation.
  35943. */
  35944. zoomStopsAnimation: boolean;
  35945. /**
  35946. * Sets the default speed at which the camera rotates around the model.
  35947. */
  35948. /**
  35949. * Gets the default speed at which the camera rotates around the model.
  35950. */
  35951. idleRotationSpeed: number;
  35952. /**
  35953. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35954. */
  35955. /**
  35956. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35957. */
  35958. idleRotationWaitTime: number;
  35959. /**
  35960. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35961. */
  35962. /**
  35963. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35964. */
  35965. idleRotationSpinupTime: number;
  35966. /**
  35967. * Gets a value indicating if the camera is currently rotating because of this behavior
  35968. */
  35969. readonly rotationInProgress: boolean;
  35970. private _onPrePointerObservableObserver;
  35971. private _onAfterCheckInputsObserver;
  35972. private _attachedCamera;
  35973. private _isPointerDown;
  35974. private _lastFrameTime;
  35975. private _lastInteractionTime;
  35976. private _cameraRotationSpeed;
  35977. /**
  35978. * Initializes the behavior.
  35979. */
  35980. init(): void;
  35981. /**
  35982. * Attaches the behavior to its arc rotate camera.
  35983. * @param camera Defines the camera to attach the behavior to
  35984. */
  35985. attach(camera: ArcRotateCamera): void;
  35986. /**
  35987. * Detaches the behavior from its current arc rotate camera.
  35988. */
  35989. detach(): void;
  35990. /**
  35991. * Returns true if user is scrolling.
  35992. * @return true if user is scrolling.
  35993. */
  35994. private _userIsZooming;
  35995. private _lastFrameRadius;
  35996. private _shouldAnimationStopForInteraction;
  35997. /**
  35998. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35999. */
  36000. private _applyUserInteraction;
  36001. private _userIsMoving;
  36002. }
  36003. }
  36004. declare module "babylonjs/Behaviors/Cameras/index" {
  36005. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36006. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36007. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  36008. }
  36009. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  36010. import { Mesh } from "babylonjs/Meshes/mesh";
  36011. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36012. import { Behavior } from "babylonjs/Behaviors/behavior";
  36013. /**
  36014. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36015. */
  36016. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36017. private ui;
  36018. /**
  36019. * The name of the behavior
  36020. */
  36021. name: string;
  36022. /**
  36023. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36024. */
  36025. distanceAwayFromFace: number;
  36026. /**
  36027. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36028. */
  36029. distanceAwayFromBottomOfFace: number;
  36030. private _faceVectors;
  36031. private _target;
  36032. private _scene;
  36033. private _onRenderObserver;
  36034. private _tmpMatrix;
  36035. private _tmpVector;
  36036. /**
  36037. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36038. * @param ui The transform node that should be attched to the mesh
  36039. */
  36040. constructor(ui: TransformNode);
  36041. /**
  36042. * Initializes the behavior
  36043. */
  36044. init(): void;
  36045. private _closestFace;
  36046. private _zeroVector;
  36047. private _lookAtTmpMatrix;
  36048. private _lookAtToRef;
  36049. /**
  36050. * Attaches the AttachToBoxBehavior to the passed in mesh
  36051. * @param target The mesh that the specified node will be attached to
  36052. */
  36053. attach(target: Mesh): void;
  36054. /**
  36055. * Detaches the behavior from the mesh
  36056. */
  36057. detach(): void;
  36058. }
  36059. }
  36060. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  36061. import { Behavior } from "babylonjs/Behaviors/behavior";
  36062. import { Mesh } from "babylonjs/Meshes/mesh";
  36063. /**
  36064. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36065. */
  36066. export class FadeInOutBehavior implements Behavior<Mesh> {
  36067. /**
  36068. * Time in milliseconds to delay before fading in (Default: 0)
  36069. */
  36070. delay: number;
  36071. /**
  36072. * Time in milliseconds for the mesh to fade in (Default: 300)
  36073. */
  36074. fadeInTime: number;
  36075. private _millisecondsPerFrame;
  36076. private _hovered;
  36077. private _hoverValue;
  36078. private _ownerNode;
  36079. /**
  36080. * Instatiates the FadeInOutBehavior
  36081. */
  36082. constructor();
  36083. /**
  36084. * The name of the behavior
  36085. */
  36086. readonly name: string;
  36087. /**
  36088. * Initializes the behavior
  36089. */
  36090. init(): void;
  36091. /**
  36092. * Attaches the fade behavior on the passed in mesh
  36093. * @param ownerNode The mesh that will be faded in/out once attached
  36094. */
  36095. attach(ownerNode: Mesh): void;
  36096. /**
  36097. * Detaches the behavior from the mesh
  36098. */
  36099. detach(): void;
  36100. /**
  36101. * Triggers the mesh to begin fading in or out
  36102. * @param value if the object should fade in or out (true to fade in)
  36103. */
  36104. fadeIn(value: boolean): void;
  36105. private _update;
  36106. private _setAllVisibility;
  36107. }
  36108. }
  36109. declare module "babylonjs/Misc/pivotTools" {
  36110. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36111. /**
  36112. * Class containing a set of static utilities functions for managing Pivots
  36113. * @hidden
  36114. */
  36115. export class PivotTools {
  36116. private static _PivotCached;
  36117. private static _OldPivotPoint;
  36118. private static _PivotTranslation;
  36119. private static _PivotTmpVector;
  36120. /** @hidden */
  36121. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36122. /** @hidden */
  36123. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36124. }
  36125. }
  36126. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  36127. import { Scene } from "babylonjs/scene";
  36128. import { Vector4, Plane } from "babylonjs/Maths/math";
  36129. import { Mesh } from "babylonjs/Meshes/mesh";
  36130. /**
  36131. * Class containing static functions to help procedurally build meshes
  36132. */
  36133. export class PlaneBuilder {
  36134. /**
  36135. * Creates a plane mesh
  36136. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36137. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36138. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36139. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36140. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  36141. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36142. * @param name defines the name of the mesh
  36143. * @param options defines the options used to create the mesh
  36144. * @param scene defines the hosting scene
  36145. * @returns the plane mesh
  36146. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36147. */
  36148. static CreatePlane(name: string, options: {
  36149. size?: number;
  36150. width?: number;
  36151. height?: number;
  36152. sideOrientation?: number;
  36153. frontUVs?: Vector4;
  36154. backUVs?: Vector4;
  36155. updatable?: boolean;
  36156. sourcePlane?: Plane;
  36157. }, scene: Scene): Mesh;
  36158. }
  36159. }
  36160. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  36161. import { Behavior } from "babylonjs/Behaviors/behavior";
  36162. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36163. import { Observable } from "babylonjs/Misc/observable";
  36164. import { Vector3 } from "babylonjs/Maths/math";
  36165. import { Ray } from "babylonjs/Culling/ray";
  36166. import "babylonjs/Meshes/Builders/planeBuilder";
  36167. /**
  36168. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36169. */
  36170. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36171. private static _AnyMouseID;
  36172. private _attachedNode;
  36173. private _dragPlane;
  36174. private _scene;
  36175. private _pointerObserver;
  36176. private _beforeRenderObserver;
  36177. private static _planeScene;
  36178. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36179. /**
  36180. * 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)
  36181. */
  36182. maxDragAngle: number;
  36183. /**
  36184. * @hidden
  36185. */
  36186. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36187. /**
  36188. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36189. */
  36190. currentDraggingPointerID: number;
  36191. /**
  36192. * The last position where the pointer hit the drag plane in world space
  36193. */
  36194. lastDragPosition: Vector3;
  36195. /**
  36196. * If the behavior is currently in a dragging state
  36197. */
  36198. dragging: boolean;
  36199. /**
  36200. * 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)
  36201. */
  36202. dragDeltaRatio: number;
  36203. /**
  36204. * If the drag plane orientation should be updated during the dragging (Default: true)
  36205. */
  36206. updateDragPlane: boolean;
  36207. private _debugMode;
  36208. private _moving;
  36209. /**
  36210. * Fires each time the attached mesh is dragged with the pointer
  36211. * * delta between last drag position and current drag position in world space
  36212. * * dragDistance along the drag axis
  36213. * * dragPlaneNormal normal of the current drag plane used during the drag
  36214. * * dragPlanePoint in world space where the drag intersects the drag plane
  36215. */
  36216. onDragObservable: Observable<{
  36217. delta: Vector3;
  36218. dragPlanePoint: Vector3;
  36219. dragPlaneNormal: Vector3;
  36220. dragDistance: number;
  36221. pointerId: number;
  36222. }>;
  36223. /**
  36224. * Fires each time a drag begins (eg. mouse down on mesh)
  36225. */
  36226. onDragStartObservable: Observable<{
  36227. dragPlanePoint: Vector3;
  36228. pointerId: number;
  36229. }>;
  36230. /**
  36231. * Fires each time a drag ends (eg. mouse release after drag)
  36232. */
  36233. onDragEndObservable: Observable<{
  36234. dragPlanePoint: Vector3;
  36235. pointerId: number;
  36236. }>;
  36237. /**
  36238. * If the attached mesh should be moved when dragged
  36239. */
  36240. moveAttached: boolean;
  36241. /**
  36242. * If the drag behavior will react to drag events (Default: true)
  36243. */
  36244. enabled: boolean;
  36245. /**
  36246. * If camera controls should be detached during the drag
  36247. */
  36248. detachCameraControls: boolean;
  36249. /**
  36250. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36251. */
  36252. useObjectOrienationForDragging: boolean;
  36253. private _options;
  36254. /**
  36255. * Creates a pointer drag behavior that can be attached to a mesh
  36256. * @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)
  36257. */
  36258. constructor(options?: {
  36259. dragAxis?: Vector3;
  36260. dragPlaneNormal?: Vector3;
  36261. });
  36262. /**
  36263. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36264. */
  36265. validateDrag: (targetPosition: Vector3) => boolean;
  36266. /**
  36267. * The name of the behavior
  36268. */
  36269. readonly name: string;
  36270. /**
  36271. * Initializes the behavior
  36272. */
  36273. init(): void;
  36274. private _tmpVector;
  36275. private _alternatePickedPoint;
  36276. private _worldDragAxis;
  36277. private _targetPosition;
  36278. private _attachedElement;
  36279. /**
  36280. * Attaches the drag behavior the passed in mesh
  36281. * @param ownerNode The mesh that will be dragged around once attached
  36282. */
  36283. attach(ownerNode: AbstractMesh): void;
  36284. /**
  36285. * Force relase the drag action by code.
  36286. */
  36287. releaseDrag(): void;
  36288. private _startDragRay;
  36289. private _lastPointerRay;
  36290. /**
  36291. * Simulates the start of a pointer drag event on the behavior
  36292. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36293. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36294. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36295. */
  36296. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36297. private _startDrag;
  36298. private _dragDelta;
  36299. private _moveDrag;
  36300. private _pickWithRayOnDragPlane;
  36301. private _pointA;
  36302. private _pointB;
  36303. private _pointC;
  36304. private _lineA;
  36305. private _lineB;
  36306. private _localAxis;
  36307. private _lookAt;
  36308. private _updateDragPlanePosition;
  36309. /**
  36310. * Detaches the behavior from the mesh
  36311. */
  36312. detach(): void;
  36313. }
  36314. }
  36315. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  36316. import { Mesh } from "babylonjs/Meshes/mesh";
  36317. import { Behavior } from "babylonjs/Behaviors/behavior";
  36318. /**
  36319. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36320. */
  36321. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36322. private _dragBehaviorA;
  36323. private _dragBehaviorB;
  36324. private _startDistance;
  36325. private _initialScale;
  36326. private _targetScale;
  36327. private _ownerNode;
  36328. private _sceneRenderObserver;
  36329. /**
  36330. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36331. */
  36332. constructor();
  36333. /**
  36334. * The name of the behavior
  36335. */
  36336. readonly name: string;
  36337. /**
  36338. * Initializes the behavior
  36339. */
  36340. init(): void;
  36341. private _getCurrentDistance;
  36342. /**
  36343. * Attaches the scale behavior the passed in mesh
  36344. * @param ownerNode The mesh that will be scaled around once attached
  36345. */
  36346. attach(ownerNode: Mesh): void;
  36347. /**
  36348. * Detaches the behavior from the mesh
  36349. */
  36350. detach(): void;
  36351. }
  36352. }
  36353. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  36354. import { Behavior } from "babylonjs/Behaviors/behavior";
  36355. import { Mesh } from "babylonjs/Meshes/mesh";
  36356. import { Observable } from "babylonjs/Misc/observable";
  36357. /**
  36358. * 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
  36359. */
  36360. export class SixDofDragBehavior implements Behavior<Mesh> {
  36361. private static _virtualScene;
  36362. private _ownerNode;
  36363. private _sceneRenderObserver;
  36364. private _scene;
  36365. private _targetPosition;
  36366. private _virtualOriginMesh;
  36367. private _virtualDragMesh;
  36368. private _pointerObserver;
  36369. private _moving;
  36370. private _startingOrientation;
  36371. /**
  36372. * 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)
  36373. */
  36374. private zDragFactor;
  36375. /**
  36376. * If the object should rotate to face the drag origin
  36377. */
  36378. rotateDraggedObject: boolean;
  36379. /**
  36380. * If the behavior is currently in a dragging state
  36381. */
  36382. dragging: boolean;
  36383. /**
  36384. * 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)
  36385. */
  36386. dragDeltaRatio: number;
  36387. /**
  36388. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36389. */
  36390. currentDraggingPointerID: number;
  36391. /**
  36392. * If camera controls should be detached during the drag
  36393. */
  36394. detachCameraControls: boolean;
  36395. /**
  36396. * Fires each time a drag starts
  36397. */
  36398. onDragStartObservable: Observable<{}>;
  36399. /**
  36400. * Fires each time a drag ends (eg. mouse release after drag)
  36401. */
  36402. onDragEndObservable: Observable<{}>;
  36403. /**
  36404. * 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
  36405. */
  36406. constructor();
  36407. /**
  36408. * The name of the behavior
  36409. */
  36410. readonly name: string;
  36411. /**
  36412. * Initializes the behavior
  36413. */
  36414. init(): void;
  36415. /**
  36416. * Attaches the scale behavior the passed in mesh
  36417. * @param ownerNode The mesh that will be scaled around once attached
  36418. */
  36419. attach(ownerNode: Mesh): void;
  36420. /**
  36421. * Detaches the behavior from the mesh
  36422. */
  36423. detach(): void;
  36424. }
  36425. }
  36426. declare module "babylonjs/Behaviors/Meshes/index" {
  36427. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  36428. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  36429. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  36430. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  36431. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  36432. }
  36433. declare module "babylonjs/Behaviors/index" {
  36434. export * from "babylonjs/Behaviors/behavior";
  36435. export * from "babylonjs/Behaviors/Cameras/index";
  36436. export * from "babylonjs/Behaviors/Meshes/index";
  36437. }
  36438. declare module "babylonjs/Bones/boneIKController" {
  36439. import { Bone } from "babylonjs/Bones/bone";
  36440. import { Vector3 } from "babylonjs/Maths/math";
  36441. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36442. import { Nullable } from "babylonjs/types";
  36443. /**
  36444. * Class used to apply inverse kinematics to bones
  36445. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36446. */
  36447. export class BoneIKController {
  36448. private static _tmpVecs;
  36449. private static _tmpQuat;
  36450. private static _tmpMats;
  36451. /**
  36452. * Gets or sets the target mesh
  36453. */
  36454. targetMesh: AbstractMesh;
  36455. /** Gets or sets the mesh used as pole */
  36456. poleTargetMesh: AbstractMesh;
  36457. /**
  36458. * Gets or sets the bone used as pole
  36459. */
  36460. poleTargetBone: Nullable<Bone>;
  36461. /**
  36462. * Gets or sets the target position
  36463. */
  36464. targetPosition: Vector3;
  36465. /**
  36466. * Gets or sets the pole target position
  36467. */
  36468. poleTargetPosition: Vector3;
  36469. /**
  36470. * Gets or sets the pole target local offset
  36471. */
  36472. poleTargetLocalOffset: Vector3;
  36473. /**
  36474. * Gets or sets the pole angle
  36475. */
  36476. poleAngle: number;
  36477. /**
  36478. * Gets or sets the mesh associated with the controller
  36479. */
  36480. mesh: AbstractMesh;
  36481. /**
  36482. * 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)
  36483. */
  36484. slerpAmount: number;
  36485. private _bone1Quat;
  36486. private _bone1Mat;
  36487. private _bone2Ang;
  36488. private _bone1;
  36489. private _bone2;
  36490. private _bone1Length;
  36491. private _bone2Length;
  36492. private _maxAngle;
  36493. private _maxReach;
  36494. private _rightHandedSystem;
  36495. private _bendAxis;
  36496. private _slerping;
  36497. private _adjustRoll;
  36498. /**
  36499. * Gets or sets maximum allowed angle
  36500. */
  36501. maxAngle: number;
  36502. /**
  36503. * Creates a new BoneIKController
  36504. * @param mesh defines the mesh to control
  36505. * @param bone defines the bone to control
  36506. * @param options defines options to set up the controller
  36507. */
  36508. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36509. targetMesh?: AbstractMesh;
  36510. poleTargetMesh?: AbstractMesh;
  36511. poleTargetBone?: Bone;
  36512. poleTargetLocalOffset?: Vector3;
  36513. poleAngle?: number;
  36514. bendAxis?: Vector3;
  36515. maxAngle?: number;
  36516. slerpAmount?: number;
  36517. });
  36518. private _setMaxAngle;
  36519. /**
  36520. * Force the controller to update the bones
  36521. */
  36522. update(): void;
  36523. }
  36524. }
  36525. declare module "babylonjs/Bones/boneLookController" {
  36526. import { Vector3, Space } from "babylonjs/Maths/math";
  36527. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36528. import { Bone } from "babylonjs/Bones/bone";
  36529. /**
  36530. * Class used to make a bone look toward a point in space
  36531. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36532. */
  36533. export class BoneLookController {
  36534. private static _tmpVecs;
  36535. private static _tmpQuat;
  36536. private static _tmpMats;
  36537. /**
  36538. * The target Vector3 that the bone will look at
  36539. */
  36540. target: Vector3;
  36541. /**
  36542. * The mesh that the bone is attached to
  36543. */
  36544. mesh: AbstractMesh;
  36545. /**
  36546. * The bone that will be looking to the target
  36547. */
  36548. bone: Bone;
  36549. /**
  36550. * The up axis of the coordinate system that is used when the bone is rotated
  36551. */
  36552. upAxis: Vector3;
  36553. /**
  36554. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36555. */
  36556. upAxisSpace: Space;
  36557. /**
  36558. * Used to make an adjustment to the yaw of the bone
  36559. */
  36560. adjustYaw: number;
  36561. /**
  36562. * Used to make an adjustment to the pitch of the bone
  36563. */
  36564. adjustPitch: number;
  36565. /**
  36566. * Used to make an adjustment to the roll of the bone
  36567. */
  36568. adjustRoll: number;
  36569. /**
  36570. * 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)
  36571. */
  36572. slerpAmount: number;
  36573. private _minYaw;
  36574. private _maxYaw;
  36575. private _minPitch;
  36576. private _maxPitch;
  36577. private _minYawSin;
  36578. private _minYawCos;
  36579. private _maxYawSin;
  36580. private _maxYawCos;
  36581. private _midYawConstraint;
  36582. private _minPitchTan;
  36583. private _maxPitchTan;
  36584. private _boneQuat;
  36585. private _slerping;
  36586. private _transformYawPitch;
  36587. private _transformYawPitchInv;
  36588. private _firstFrameSkipped;
  36589. private _yawRange;
  36590. private _fowardAxis;
  36591. /**
  36592. * Gets or sets the minimum yaw angle that the bone can look to
  36593. */
  36594. minYaw: number;
  36595. /**
  36596. * Gets or sets the maximum yaw angle that the bone can look to
  36597. */
  36598. maxYaw: number;
  36599. /**
  36600. * Gets or sets the minimum pitch angle that the bone can look to
  36601. */
  36602. minPitch: number;
  36603. /**
  36604. * Gets or sets the maximum pitch angle that the bone can look to
  36605. */
  36606. maxPitch: number;
  36607. /**
  36608. * Create a BoneLookController
  36609. * @param mesh the mesh that the bone belongs to
  36610. * @param bone the bone that will be looking to the target
  36611. * @param target the target Vector3 to look at
  36612. * @param options optional settings:
  36613. * * maxYaw: the maximum angle the bone will yaw to
  36614. * * minYaw: the minimum angle the bone will yaw to
  36615. * * maxPitch: the maximum angle the bone will pitch to
  36616. * * minPitch: the minimum angle the bone will yaw to
  36617. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36618. * * upAxis: the up axis of the coordinate system
  36619. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36620. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36621. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36622. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36623. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36624. * * adjustRoll: used to make an adjustment to the roll of the bone
  36625. **/
  36626. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36627. maxYaw?: number;
  36628. minYaw?: number;
  36629. maxPitch?: number;
  36630. minPitch?: number;
  36631. slerpAmount?: number;
  36632. upAxis?: Vector3;
  36633. upAxisSpace?: Space;
  36634. yawAxis?: Vector3;
  36635. pitchAxis?: Vector3;
  36636. adjustYaw?: number;
  36637. adjustPitch?: number;
  36638. adjustRoll?: number;
  36639. });
  36640. /**
  36641. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36642. */
  36643. update(): void;
  36644. private _getAngleDiff;
  36645. private _getAngleBetween;
  36646. private _isAngleBetween;
  36647. }
  36648. }
  36649. declare module "babylonjs/Bones/index" {
  36650. export * from "babylonjs/Bones/bone";
  36651. export * from "babylonjs/Bones/boneIKController";
  36652. export * from "babylonjs/Bones/boneLookController";
  36653. export * from "babylonjs/Bones/skeleton";
  36654. }
  36655. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  36656. import { Nullable } from "babylonjs/types";
  36657. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36658. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36659. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  36660. /**
  36661. * Manage the gamepad inputs to control an arc rotate camera.
  36662. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36663. */
  36664. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36665. /**
  36666. * Defines the camera the input is attached to.
  36667. */
  36668. camera: ArcRotateCamera;
  36669. /**
  36670. * Defines the gamepad the input is gathering event from.
  36671. */
  36672. gamepad: Nullable<Gamepad>;
  36673. /**
  36674. * Defines the gamepad rotation sensiblity.
  36675. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36676. */
  36677. gamepadRotationSensibility: number;
  36678. /**
  36679. * Defines the gamepad move sensiblity.
  36680. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36681. */
  36682. gamepadMoveSensibility: number;
  36683. private _onGamepadConnectedObserver;
  36684. private _onGamepadDisconnectedObserver;
  36685. /**
  36686. * Attach the input controls to a specific dom element to get the input from.
  36687. * @param element Defines the element the controls should be listened from
  36688. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36689. */
  36690. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36691. /**
  36692. * Detach the current controls from the specified dom element.
  36693. * @param element Defines the element to stop listening the inputs from
  36694. */
  36695. detachControl(element: Nullable<HTMLElement>): void;
  36696. /**
  36697. * Update the current camera state depending on the inputs that have been used this frame.
  36698. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36699. */
  36700. checkInputs(): void;
  36701. /**
  36702. * Gets the class name of the current intput.
  36703. * @returns the class name
  36704. */
  36705. getClassName(): string;
  36706. /**
  36707. * Get the friendly name associated with the input class.
  36708. * @returns the input friendly name
  36709. */
  36710. getSimpleName(): string;
  36711. }
  36712. }
  36713. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  36714. import { Nullable } from "babylonjs/types";
  36715. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36716. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36717. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36718. interface ArcRotateCameraInputsManager {
  36719. /**
  36720. * Add orientation input support to the input manager.
  36721. * @returns the current input manager
  36722. */
  36723. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36724. }
  36725. }
  36726. /**
  36727. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36728. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36729. */
  36730. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36731. /**
  36732. * Defines the camera the input is attached to.
  36733. */
  36734. camera: ArcRotateCamera;
  36735. /**
  36736. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36737. */
  36738. alphaCorrection: number;
  36739. /**
  36740. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36741. */
  36742. gammaCorrection: number;
  36743. private _alpha;
  36744. private _gamma;
  36745. private _dirty;
  36746. private _deviceOrientationHandler;
  36747. /**
  36748. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36749. */
  36750. constructor();
  36751. /**
  36752. * Attach the input controls to a specific dom element to get the input from.
  36753. * @param element Defines the element the controls should be listened from
  36754. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36755. */
  36756. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36757. /** @hidden */
  36758. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36759. /**
  36760. * Update the current camera state depending on the inputs that have been used this frame.
  36761. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36762. */
  36763. checkInputs(): void;
  36764. /**
  36765. * Detach the current controls from the specified dom element.
  36766. * @param element Defines the element to stop listening the inputs from
  36767. */
  36768. detachControl(element: Nullable<HTMLElement>): void;
  36769. /**
  36770. * Gets the class name of the current intput.
  36771. * @returns the class name
  36772. */
  36773. getClassName(): string;
  36774. /**
  36775. * Get the friendly name associated with the input class.
  36776. * @returns the input friendly name
  36777. */
  36778. getSimpleName(): string;
  36779. }
  36780. }
  36781. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  36782. import { Nullable } from "babylonjs/types";
  36783. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36784. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36785. /**
  36786. * Listen to mouse events to control the camera.
  36787. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36788. */
  36789. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36790. /**
  36791. * Defines the camera the input is attached to.
  36792. */
  36793. camera: FlyCamera;
  36794. /**
  36795. * Defines if touch is enabled. (Default is true.)
  36796. */
  36797. touchEnabled: boolean;
  36798. /**
  36799. * Defines the buttons associated with the input to handle camera rotation.
  36800. */
  36801. buttons: number[];
  36802. /**
  36803. * Assign buttons for Yaw control.
  36804. */
  36805. buttonsYaw: number[];
  36806. /**
  36807. * Assign buttons for Pitch control.
  36808. */
  36809. buttonsPitch: number[];
  36810. /**
  36811. * Assign buttons for Roll control.
  36812. */
  36813. buttonsRoll: number[];
  36814. /**
  36815. * Detect if any button is being pressed while mouse is moved.
  36816. * -1 = Mouse locked.
  36817. * 0 = Left button.
  36818. * 1 = Middle Button.
  36819. * 2 = Right Button.
  36820. */
  36821. activeButton: number;
  36822. /**
  36823. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36824. * Higher values reduce its sensitivity.
  36825. */
  36826. angularSensibility: number;
  36827. private _mousemoveCallback;
  36828. private _observer;
  36829. private _rollObserver;
  36830. private previousPosition;
  36831. private noPreventDefault;
  36832. private element;
  36833. /**
  36834. * Listen to mouse events to control the camera.
  36835. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36836. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36837. */
  36838. constructor(touchEnabled?: boolean);
  36839. /**
  36840. * Attach the mouse control to the HTML DOM element.
  36841. * @param element Defines the element that listens to the input events.
  36842. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36843. */
  36844. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36845. /**
  36846. * Detach the current controls from the specified dom element.
  36847. * @param element Defines the element to stop listening the inputs from
  36848. */
  36849. detachControl(element: Nullable<HTMLElement>): void;
  36850. /**
  36851. * Gets the class name of the current input.
  36852. * @returns the class name.
  36853. */
  36854. getClassName(): string;
  36855. /**
  36856. * Get the friendly name associated with the input class.
  36857. * @returns the input's friendly name.
  36858. */
  36859. getSimpleName(): string;
  36860. private _pointerInput;
  36861. private _onMouseMove;
  36862. /**
  36863. * Rotate camera by mouse offset.
  36864. */
  36865. private rotateCamera;
  36866. }
  36867. }
  36868. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  36869. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36870. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36871. /**
  36872. * Default Inputs manager for the FlyCamera.
  36873. * It groups all the default supported inputs for ease of use.
  36874. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36875. */
  36876. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36877. /**
  36878. * Instantiates a new FlyCameraInputsManager.
  36879. * @param camera Defines the camera the inputs belong to.
  36880. */
  36881. constructor(camera: FlyCamera);
  36882. /**
  36883. * Add keyboard input support to the input manager.
  36884. * @returns the new FlyCameraKeyboardMoveInput().
  36885. */
  36886. addKeyboard(): FlyCameraInputsManager;
  36887. /**
  36888. * Add mouse input support to the input manager.
  36889. * @param touchEnabled Enable touch screen support.
  36890. * @returns the new FlyCameraMouseInput().
  36891. */
  36892. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36893. }
  36894. }
  36895. declare module "babylonjs/Cameras/flyCamera" {
  36896. import { Scene } from "babylonjs/scene";
  36897. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  36898. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36899. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36900. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  36901. /**
  36902. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36903. * such as in a 3D Space Shooter or a Flight Simulator.
  36904. */
  36905. export class FlyCamera extends TargetCamera {
  36906. /**
  36907. * Define the collision ellipsoid of the camera.
  36908. * This is helpful for simulating a camera body, like a player's body.
  36909. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36910. */
  36911. ellipsoid: Vector3;
  36912. /**
  36913. * Define an offset for the position of the ellipsoid around the camera.
  36914. * This can be helpful if the camera is attached away from the player's body center,
  36915. * such as at its head.
  36916. */
  36917. ellipsoidOffset: Vector3;
  36918. /**
  36919. * Enable or disable collisions of the camera with the rest of the scene objects.
  36920. */
  36921. checkCollisions: boolean;
  36922. /**
  36923. * Enable or disable gravity on the camera.
  36924. */
  36925. applyGravity: boolean;
  36926. /**
  36927. * Define the current direction the camera is moving to.
  36928. */
  36929. cameraDirection: Vector3;
  36930. /**
  36931. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36932. * This overrides and empties cameraRotation.
  36933. */
  36934. rotationQuaternion: Quaternion;
  36935. /**
  36936. * Track Roll to maintain the wanted Rolling when looking around.
  36937. */
  36938. _trackRoll: number;
  36939. /**
  36940. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36941. */
  36942. rollCorrect: number;
  36943. /**
  36944. * Mimic a banked turn, Rolling the camera when Yawing.
  36945. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36946. */
  36947. bankedTurn: boolean;
  36948. /**
  36949. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36950. */
  36951. bankedTurnLimit: number;
  36952. /**
  36953. * Value of 0 disables the banked Roll.
  36954. * Value of 1 is equal to the Yaw angle in radians.
  36955. */
  36956. bankedTurnMultiplier: number;
  36957. /**
  36958. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36959. */
  36960. inputs: FlyCameraInputsManager;
  36961. /**
  36962. * Gets the input sensibility for mouse input.
  36963. * Higher values reduce sensitivity.
  36964. */
  36965. /**
  36966. * Sets the input sensibility for a mouse input.
  36967. * Higher values reduce sensitivity.
  36968. */
  36969. angularSensibility: number;
  36970. /**
  36971. * Get the keys for camera movement forward.
  36972. */
  36973. /**
  36974. * Set the keys for camera movement forward.
  36975. */
  36976. keysForward: number[];
  36977. /**
  36978. * Get the keys for camera movement backward.
  36979. */
  36980. keysBackward: number[];
  36981. /**
  36982. * Get the keys for camera movement up.
  36983. */
  36984. /**
  36985. * Set the keys for camera movement up.
  36986. */
  36987. keysUp: number[];
  36988. /**
  36989. * Get the keys for camera movement down.
  36990. */
  36991. /**
  36992. * Set the keys for camera movement down.
  36993. */
  36994. keysDown: number[];
  36995. /**
  36996. * Get the keys for camera movement left.
  36997. */
  36998. /**
  36999. * Set the keys for camera movement left.
  37000. */
  37001. keysLeft: number[];
  37002. /**
  37003. * Set the keys for camera movement right.
  37004. */
  37005. /**
  37006. * Set the keys for camera movement right.
  37007. */
  37008. keysRight: number[];
  37009. /**
  37010. * Event raised when the camera collides with a mesh in the scene.
  37011. */
  37012. onCollide: (collidedMesh: AbstractMesh) => void;
  37013. private _collider;
  37014. private _needMoveForGravity;
  37015. private _oldPosition;
  37016. private _diffPosition;
  37017. private _newPosition;
  37018. /** @hidden */
  37019. _localDirection: Vector3;
  37020. /** @hidden */
  37021. _transformedDirection: Vector3;
  37022. /**
  37023. * Instantiates a FlyCamera.
  37024. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37025. * such as in a 3D Space Shooter or a Flight Simulator.
  37026. * @param name Define the name of the camera in the scene.
  37027. * @param position Define the starting position of the camera in the scene.
  37028. * @param scene Define the scene the camera belongs to.
  37029. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37030. */
  37031. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37032. /**
  37033. * Attach a control to the HTML DOM element.
  37034. * @param element Defines the element that listens to the input events.
  37035. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37036. */
  37037. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37038. /**
  37039. * Detach a control from the HTML DOM element.
  37040. * The camera will stop reacting to that input.
  37041. * @param element Defines the element that listens to the input events.
  37042. */
  37043. detachControl(element: HTMLElement): void;
  37044. private _collisionMask;
  37045. /**
  37046. * Get the mask that the camera ignores in collision events.
  37047. */
  37048. /**
  37049. * Set the mask that the camera ignores in collision events.
  37050. */
  37051. collisionMask: number;
  37052. /** @hidden */
  37053. _collideWithWorld(displacement: Vector3): void;
  37054. /** @hidden */
  37055. private _onCollisionPositionChange;
  37056. /** @hidden */
  37057. _checkInputs(): void;
  37058. /** @hidden */
  37059. _decideIfNeedsToMove(): boolean;
  37060. /** @hidden */
  37061. _updatePosition(): void;
  37062. /**
  37063. * Restore the Roll to its target value at the rate specified.
  37064. * @param rate - Higher means slower restoring.
  37065. * @hidden
  37066. */
  37067. restoreRoll(rate: number): void;
  37068. /**
  37069. * Destroy the camera and release the current resources held by it.
  37070. */
  37071. dispose(): void;
  37072. /**
  37073. * Get the current object class name.
  37074. * @returns the class name.
  37075. */
  37076. getClassName(): string;
  37077. }
  37078. }
  37079. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  37080. import { Nullable } from "babylonjs/types";
  37081. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37082. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37083. /**
  37084. * Listen to keyboard events to control the camera.
  37085. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37086. */
  37087. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37088. /**
  37089. * Defines the camera the input is attached to.
  37090. */
  37091. camera: FlyCamera;
  37092. /**
  37093. * The list of keyboard keys used to control the forward move of the camera.
  37094. */
  37095. keysForward: number[];
  37096. /**
  37097. * The list of keyboard keys used to control the backward move of the camera.
  37098. */
  37099. keysBackward: number[];
  37100. /**
  37101. * The list of keyboard keys used to control the forward move of the camera.
  37102. */
  37103. keysUp: number[];
  37104. /**
  37105. * The list of keyboard keys used to control the backward move of the camera.
  37106. */
  37107. keysDown: number[];
  37108. /**
  37109. * The list of keyboard keys used to control the right strafe move of the camera.
  37110. */
  37111. keysRight: number[];
  37112. /**
  37113. * The list of keyboard keys used to control the left strafe move of the camera.
  37114. */
  37115. keysLeft: number[];
  37116. private _keys;
  37117. private _onCanvasBlurObserver;
  37118. private _onKeyboardObserver;
  37119. private _engine;
  37120. private _scene;
  37121. /**
  37122. * Attach the input controls to a specific dom element to get the input from.
  37123. * @param element Defines the element the controls should be listened from
  37124. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37125. */
  37126. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37127. /**
  37128. * Detach the current controls from the specified dom element.
  37129. * @param element Defines the element to stop listening the inputs from
  37130. */
  37131. detachControl(element: Nullable<HTMLElement>): void;
  37132. /**
  37133. * Gets the class name of the current intput.
  37134. * @returns the class name
  37135. */
  37136. getClassName(): string;
  37137. /** @hidden */
  37138. _onLostFocus(e: FocusEvent): void;
  37139. /**
  37140. * Get the friendly name associated with the input class.
  37141. * @returns the input friendly name
  37142. */
  37143. getSimpleName(): string;
  37144. /**
  37145. * Update the current camera state depending on the inputs that have been used this frame.
  37146. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37147. */
  37148. checkInputs(): void;
  37149. }
  37150. }
  37151. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  37152. import { Nullable } from "babylonjs/types";
  37153. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37154. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37155. /**
  37156. * Manage the mouse wheel inputs to control a follow camera.
  37157. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37158. */
  37159. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37160. /**
  37161. * Defines the camera the input is attached to.
  37162. */
  37163. camera: FollowCamera;
  37164. /**
  37165. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37166. */
  37167. axisControlRadius: boolean;
  37168. /**
  37169. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37170. */
  37171. axisControlHeight: boolean;
  37172. /**
  37173. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37174. */
  37175. axisControlRotation: boolean;
  37176. /**
  37177. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37178. * relation to mouseWheel events.
  37179. */
  37180. wheelPrecision: number;
  37181. /**
  37182. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37183. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37184. */
  37185. wheelDeltaPercentage: number;
  37186. private _wheel;
  37187. private _observer;
  37188. /**
  37189. * Attach the input controls to a specific dom element to get the input from.
  37190. * @param element Defines the element the controls should be listened from
  37191. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37192. */
  37193. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37194. /**
  37195. * Detach the current controls from the specified dom element.
  37196. * @param element Defines the element to stop listening the inputs from
  37197. */
  37198. detachControl(element: Nullable<HTMLElement>): void;
  37199. /**
  37200. * Gets the class name of the current intput.
  37201. * @returns the class name
  37202. */
  37203. getClassName(): string;
  37204. /**
  37205. * Get the friendly name associated with the input class.
  37206. * @returns the input friendly name
  37207. */
  37208. getSimpleName(): string;
  37209. }
  37210. }
  37211. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  37212. import { Nullable } from "babylonjs/types";
  37213. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37214. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37215. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37216. /**
  37217. * Manage the pointers inputs to control an follow camera.
  37218. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37219. */
  37220. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37221. /**
  37222. * Defines the camera the input is attached to.
  37223. */
  37224. camera: FollowCamera;
  37225. /**
  37226. * Gets the class name of the current input.
  37227. * @returns the class name
  37228. */
  37229. getClassName(): string;
  37230. /**
  37231. * Defines the pointer angular sensibility along the X axis or how fast is
  37232. * the camera rotating.
  37233. * A negative number will reverse the axis direction.
  37234. */
  37235. angularSensibilityX: number;
  37236. /**
  37237. * Defines the pointer angular sensibility along the Y axis or how fast is
  37238. * the camera rotating.
  37239. * A negative number will reverse the axis direction.
  37240. */
  37241. angularSensibilityY: number;
  37242. /**
  37243. * Defines the pointer pinch precision or how fast is the camera zooming.
  37244. * A negative number will reverse the axis direction.
  37245. */
  37246. pinchPrecision: number;
  37247. /**
  37248. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37249. * from 0.
  37250. * It defines the percentage of current camera.radius to use as delta when
  37251. * pinch zoom is used.
  37252. */
  37253. pinchDeltaPercentage: number;
  37254. /**
  37255. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37256. */
  37257. axisXControlRadius: boolean;
  37258. /**
  37259. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37260. */
  37261. axisXControlHeight: boolean;
  37262. /**
  37263. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37264. */
  37265. axisXControlRotation: boolean;
  37266. /**
  37267. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37268. */
  37269. axisYControlRadius: boolean;
  37270. /**
  37271. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37272. */
  37273. axisYControlHeight: boolean;
  37274. /**
  37275. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37276. */
  37277. axisYControlRotation: boolean;
  37278. /**
  37279. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37280. */
  37281. axisPinchControlRadius: boolean;
  37282. /**
  37283. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37284. */
  37285. axisPinchControlHeight: boolean;
  37286. /**
  37287. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37288. */
  37289. axisPinchControlRotation: boolean;
  37290. /**
  37291. * Log error messages if basic misconfiguration has occurred.
  37292. */
  37293. warningEnable: boolean;
  37294. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37295. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37296. private _warningCounter;
  37297. private _warning;
  37298. }
  37299. }
  37300. declare module "babylonjs/Cameras/followCameraInputsManager" {
  37301. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37302. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37303. /**
  37304. * Default Inputs manager for the FollowCamera.
  37305. * It groups all the default supported inputs for ease of use.
  37306. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37307. */
  37308. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37309. /**
  37310. * Instantiates a new FollowCameraInputsManager.
  37311. * @param camera Defines the camera the inputs belong to
  37312. */
  37313. constructor(camera: FollowCamera);
  37314. /**
  37315. * Add keyboard input support to the input manager.
  37316. * @returns the current input manager
  37317. */
  37318. addKeyboard(): FollowCameraInputsManager;
  37319. /**
  37320. * Add mouse wheel input support to the input manager.
  37321. * @returns the current input manager
  37322. */
  37323. addMouseWheel(): FollowCameraInputsManager;
  37324. /**
  37325. * Add pointers input support to the input manager.
  37326. * @returns the current input manager
  37327. */
  37328. addPointers(): FollowCameraInputsManager;
  37329. /**
  37330. * Add orientation input support to the input manager.
  37331. * @returns the current input manager
  37332. */
  37333. addVRDeviceOrientation(): FollowCameraInputsManager;
  37334. }
  37335. }
  37336. declare module "babylonjs/Cameras/followCamera" {
  37337. import { Nullable } from "babylonjs/types";
  37338. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37339. import { Scene } from "babylonjs/scene";
  37340. import { Vector3 } from "babylonjs/Maths/math";
  37341. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37342. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  37343. /**
  37344. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37345. * an arc rotate version arcFollowCamera are available.
  37346. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37347. */
  37348. export class FollowCamera extends TargetCamera {
  37349. /**
  37350. * Distance the follow camera should follow an object at
  37351. */
  37352. radius: number;
  37353. /**
  37354. * Minimum allowed distance of the camera to the axis of rotation
  37355. * (The camera can not get closer).
  37356. * This can help limiting how the Camera is able to move in the scene.
  37357. */
  37358. lowerRadiusLimit: Nullable<number>;
  37359. /**
  37360. * Maximum allowed distance of the camera to the axis of rotation
  37361. * (The camera can not get further).
  37362. * This can help limiting how the Camera is able to move in the scene.
  37363. */
  37364. upperRadiusLimit: Nullable<number>;
  37365. /**
  37366. * Define a rotation offset between the camera and the object it follows
  37367. */
  37368. rotationOffset: number;
  37369. /**
  37370. * Minimum allowed angle to camera position relative to target object.
  37371. * This can help limiting how the Camera is able to move in the scene.
  37372. */
  37373. lowerRotationOffsetLimit: Nullable<number>;
  37374. /**
  37375. * Maximum allowed angle to camera position relative to target object.
  37376. * This can help limiting how the Camera is able to move in the scene.
  37377. */
  37378. upperRotationOffsetLimit: Nullable<number>;
  37379. /**
  37380. * Define a height offset between the camera and the object it follows.
  37381. * It can help following an object from the top (like a car chaing a plane)
  37382. */
  37383. heightOffset: number;
  37384. /**
  37385. * Minimum allowed height of camera position relative to target object.
  37386. * This can help limiting how the Camera is able to move in the scene.
  37387. */
  37388. lowerHeightOffsetLimit: Nullable<number>;
  37389. /**
  37390. * Maximum allowed height of camera position relative to target object.
  37391. * This can help limiting how the Camera is able to move in the scene.
  37392. */
  37393. upperHeightOffsetLimit: Nullable<number>;
  37394. /**
  37395. * Define how fast the camera can accelerate to follow it s target.
  37396. */
  37397. cameraAcceleration: number;
  37398. /**
  37399. * Define the speed limit of the camera following an object.
  37400. */
  37401. maxCameraSpeed: number;
  37402. /**
  37403. * Define the target of the camera.
  37404. */
  37405. lockedTarget: Nullable<AbstractMesh>;
  37406. /**
  37407. * Defines the input associated with the camera.
  37408. */
  37409. inputs: FollowCameraInputsManager;
  37410. /**
  37411. * Instantiates the follow camera.
  37412. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37413. * @param name Define the name of the camera in the scene
  37414. * @param position Define the position of the camera
  37415. * @param scene Define the scene the camera belong to
  37416. * @param lockedTarget Define the target of the camera
  37417. */
  37418. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37419. private _follow;
  37420. /**
  37421. * Attached controls to the current camera.
  37422. * @param element Defines the element the controls should be listened from
  37423. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37424. */
  37425. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37426. /**
  37427. * Detach the current controls from the camera.
  37428. * The camera will stop reacting to inputs.
  37429. * @param element Defines the element to stop listening the inputs from
  37430. */
  37431. detachControl(element: HTMLElement): void;
  37432. /** @hidden */
  37433. _checkInputs(): void;
  37434. private _checkLimits;
  37435. /**
  37436. * Gets the camera class name.
  37437. * @returns the class name
  37438. */
  37439. getClassName(): string;
  37440. }
  37441. /**
  37442. * Arc Rotate version of the follow camera.
  37443. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37444. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37445. */
  37446. export class ArcFollowCamera extends TargetCamera {
  37447. /** The longitudinal angle of the camera */
  37448. alpha: number;
  37449. /** The latitudinal angle of the camera */
  37450. beta: number;
  37451. /** The radius of the camera from its target */
  37452. radius: number;
  37453. /** Define the camera target (the messh it should follow) */
  37454. target: Nullable<AbstractMesh>;
  37455. private _cartesianCoordinates;
  37456. /**
  37457. * Instantiates a new ArcFollowCamera
  37458. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37459. * @param name Define the name of the camera
  37460. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37461. * @param beta Define the rotation angle of the camera around the elevation axis
  37462. * @param radius Define the radius of the camera from its target point
  37463. * @param target Define the target of the camera
  37464. * @param scene Define the scene the camera belongs to
  37465. */
  37466. constructor(name: string,
  37467. /** The longitudinal angle of the camera */
  37468. alpha: number,
  37469. /** The latitudinal angle of the camera */
  37470. beta: number,
  37471. /** The radius of the camera from its target */
  37472. radius: number,
  37473. /** Define the camera target (the messh it should follow) */
  37474. target: Nullable<AbstractMesh>, scene: Scene);
  37475. private _follow;
  37476. /** @hidden */
  37477. _checkInputs(): void;
  37478. /**
  37479. * Returns the class name of the object.
  37480. * It is mostly used internally for serialization purposes.
  37481. */
  37482. getClassName(): string;
  37483. }
  37484. }
  37485. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  37486. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37487. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37488. import { Nullable } from "babylonjs/types";
  37489. /**
  37490. * Manage the keyboard inputs to control the movement of a follow camera.
  37491. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37492. */
  37493. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37494. /**
  37495. * Defines the camera the input is attached to.
  37496. */
  37497. camera: FollowCamera;
  37498. /**
  37499. * Defines the list of key codes associated with the up action (increase heightOffset)
  37500. */
  37501. keysHeightOffsetIncr: number[];
  37502. /**
  37503. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37504. */
  37505. keysHeightOffsetDecr: number[];
  37506. /**
  37507. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37508. */
  37509. keysHeightOffsetModifierAlt: boolean;
  37510. /**
  37511. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37512. */
  37513. keysHeightOffsetModifierCtrl: boolean;
  37514. /**
  37515. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37516. */
  37517. keysHeightOffsetModifierShift: boolean;
  37518. /**
  37519. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37520. */
  37521. keysRotationOffsetIncr: number[];
  37522. /**
  37523. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37524. */
  37525. keysRotationOffsetDecr: number[];
  37526. /**
  37527. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37528. */
  37529. keysRotationOffsetModifierAlt: boolean;
  37530. /**
  37531. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37532. */
  37533. keysRotationOffsetModifierCtrl: boolean;
  37534. /**
  37535. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37536. */
  37537. keysRotationOffsetModifierShift: boolean;
  37538. /**
  37539. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37540. */
  37541. keysRadiusIncr: number[];
  37542. /**
  37543. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37544. */
  37545. keysRadiusDecr: number[];
  37546. /**
  37547. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37548. */
  37549. keysRadiusModifierAlt: boolean;
  37550. /**
  37551. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37552. */
  37553. keysRadiusModifierCtrl: boolean;
  37554. /**
  37555. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37556. */
  37557. keysRadiusModifierShift: boolean;
  37558. /**
  37559. * Defines the rate of change of heightOffset.
  37560. */
  37561. heightSensibility: number;
  37562. /**
  37563. * Defines the rate of change of rotationOffset.
  37564. */
  37565. rotationSensibility: number;
  37566. /**
  37567. * Defines the rate of change of radius.
  37568. */
  37569. radiusSensibility: number;
  37570. private _keys;
  37571. private _ctrlPressed;
  37572. private _altPressed;
  37573. private _shiftPressed;
  37574. private _onCanvasBlurObserver;
  37575. private _onKeyboardObserver;
  37576. private _engine;
  37577. private _scene;
  37578. /**
  37579. * Attach the input controls to a specific dom element to get the input from.
  37580. * @param element Defines the element the controls should be listened from
  37581. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37582. */
  37583. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37584. /**
  37585. * Detach the current controls from the specified dom element.
  37586. * @param element Defines the element to stop listening the inputs from
  37587. */
  37588. detachControl(element: Nullable<HTMLElement>): void;
  37589. /**
  37590. * Update the current camera state depending on the inputs that have been used this frame.
  37591. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37592. */
  37593. checkInputs(): void;
  37594. /**
  37595. * Gets the class name of the current input.
  37596. * @returns the class name
  37597. */
  37598. getClassName(): string;
  37599. /**
  37600. * Get the friendly name associated with the input class.
  37601. * @returns the input friendly name
  37602. */
  37603. getSimpleName(): string;
  37604. /**
  37605. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37606. * allow modification of the heightOffset value.
  37607. */
  37608. private _modifierHeightOffset;
  37609. /**
  37610. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37611. * allow modification of the rotationOffset value.
  37612. */
  37613. private _modifierRotationOffset;
  37614. /**
  37615. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37616. * allow modification of the radius value.
  37617. */
  37618. private _modifierRadius;
  37619. }
  37620. }
  37621. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  37622. import { Nullable } from "babylonjs/types";
  37623. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37624. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37625. module "babylonjs/Cameras/freeCameraInputsManager" {
  37626. interface FreeCameraInputsManager {
  37627. /**
  37628. * Add orientation input support to the input manager.
  37629. * @returns the current input manager
  37630. */
  37631. addDeviceOrientation(): FreeCameraInputsManager;
  37632. }
  37633. }
  37634. /**
  37635. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37636. * Screen rotation is taken into account.
  37637. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37638. */
  37639. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37640. private _camera;
  37641. private _screenOrientationAngle;
  37642. private _constantTranform;
  37643. private _screenQuaternion;
  37644. private _alpha;
  37645. private _beta;
  37646. private _gamma;
  37647. /**
  37648. * Instantiates a new input
  37649. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37650. */
  37651. constructor();
  37652. /**
  37653. * Define the camera controlled by the input.
  37654. */
  37655. camera: FreeCamera;
  37656. /**
  37657. * Attach the input controls to a specific dom element to get the input from.
  37658. * @param element Defines the element the controls should be listened from
  37659. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37660. */
  37661. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37662. private _orientationChanged;
  37663. private _deviceOrientation;
  37664. /**
  37665. * Detach the current controls from the specified dom element.
  37666. * @param element Defines the element to stop listening the inputs from
  37667. */
  37668. detachControl(element: Nullable<HTMLElement>): void;
  37669. /**
  37670. * Update the current camera state depending on the inputs that have been used this frame.
  37671. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37672. */
  37673. checkInputs(): void;
  37674. /**
  37675. * Gets the class name of the current intput.
  37676. * @returns the class name
  37677. */
  37678. getClassName(): string;
  37679. /**
  37680. * Get the friendly name associated with the input class.
  37681. * @returns the input friendly name
  37682. */
  37683. getSimpleName(): string;
  37684. }
  37685. }
  37686. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  37687. import { Nullable } from "babylonjs/types";
  37688. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37689. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37690. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37691. /**
  37692. * Manage the gamepad inputs to control a free camera.
  37693. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37694. */
  37695. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37696. /**
  37697. * Define the camera the input is attached to.
  37698. */
  37699. camera: FreeCamera;
  37700. /**
  37701. * Define the Gamepad controlling the input
  37702. */
  37703. gamepad: Nullable<Gamepad>;
  37704. /**
  37705. * Defines the gamepad rotation sensiblity.
  37706. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37707. */
  37708. gamepadAngularSensibility: number;
  37709. /**
  37710. * Defines the gamepad move sensiblity.
  37711. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37712. */
  37713. gamepadMoveSensibility: number;
  37714. private _onGamepadConnectedObserver;
  37715. private _onGamepadDisconnectedObserver;
  37716. private _cameraTransform;
  37717. private _deltaTransform;
  37718. private _vector3;
  37719. private _vector2;
  37720. /**
  37721. * Attach the input controls to a specific dom element to get the input from.
  37722. * @param element Defines the element the controls should be listened from
  37723. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37724. */
  37725. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37726. /**
  37727. * Detach the current controls from the specified dom element.
  37728. * @param element Defines the element to stop listening the inputs from
  37729. */
  37730. detachControl(element: Nullable<HTMLElement>): void;
  37731. /**
  37732. * Update the current camera state depending on the inputs that have been used this frame.
  37733. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37734. */
  37735. checkInputs(): void;
  37736. /**
  37737. * Gets the class name of the current intput.
  37738. * @returns the class name
  37739. */
  37740. getClassName(): string;
  37741. /**
  37742. * Get the friendly name associated with the input class.
  37743. * @returns the input friendly name
  37744. */
  37745. getSimpleName(): string;
  37746. }
  37747. }
  37748. declare module "babylonjs/Misc/virtualJoystick" {
  37749. import { Nullable } from "babylonjs/types";
  37750. import { Vector3 } from "babylonjs/Maths/math";
  37751. /**
  37752. * Defines the potential axis of a Joystick
  37753. */
  37754. export enum JoystickAxis {
  37755. /** X axis */
  37756. X = 0,
  37757. /** Y axis */
  37758. Y = 1,
  37759. /** Z axis */
  37760. Z = 2
  37761. }
  37762. /**
  37763. * Class used to define virtual joystick (used in touch mode)
  37764. */
  37765. export class VirtualJoystick {
  37766. /**
  37767. * Gets or sets a boolean indicating that left and right values must be inverted
  37768. */
  37769. reverseLeftRight: boolean;
  37770. /**
  37771. * Gets or sets a boolean indicating that up and down values must be inverted
  37772. */
  37773. reverseUpDown: boolean;
  37774. /**
  37775. * Gets the offset value for the position (ie. the change of the position value)
  37776. */
  37777. deltaPosition: Vector3;
  37778. /**
  37779. * Gets a boolean indicating if the virtual joystick was pressed
  37780. */
  37781. pressed: boolean;
  37782. /**
  37783. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37784. */
  37785. static Canvas: Nullable<HTMLCanvasElement>;
  37786. private static _globalJoystickIndex;
  37787. private static vjCanvasContext;
  37788. private static vjCanvasWidth;
  37789. private static vjCanvasHeight;
  37790. private static halfWidth;
  37791. private _action;
  37792. private _axisTargetedByLeftAndRight;
  37793. private _axisTargetedByUpAndDown;
  37794. private _joystickSensibility;
  37795. private _inversedSensibility;
  37796. private _joystickPointerID;
  37797. private _joystickColor;
  37798. private _joystickPointerPos;
  37799. private _joystickPreviousPointerPos;
  37800. private _joystickPointerStartPos;
  37801. private _deltaJoystickVector;
  37802. private _leftJoystick;
  37803. private _touches;
  37804. private _onPointerDownHandlerRef;
  37805. private _onPointerMoveHandlerRef;
  37806. private _onPointerUpHandlerRef;
  37807. private _onResize;
  37808. /**
  37809. * Creates a new virtual joystick
  37810. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37811. */
  37812. constructor(leftJoystick?: boolean);
  37813. /**
  37814. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37815. * @param newJoystickSensibility defines the new sensibility
  37816. */
  37817. setJoystickSensibility(newJoystickSensibility: number): void;
  37818. private _onPointerDown;
  37819. private _onPointerMove;
  37820. private _onPointerUp;
  37821. /**
  37822. * Change the color of the virtual joystick
  37823. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37824. */
  37825. setJoystickColor(newColor: string): void;
  37826. /**
  37827. * Defines a callback to call when the joystick is touched
  37828. * @param action defines the callback
  37829. */
  37830. setActionOnTouch(action: () => any): void;
  37831. /**
  37832. * Defines which axis you'd like to control for left & right
  37833. * @param axis defines the axis to use
  37834. */
  37835. setAxisForLeftRight(axis: JoystickAxis): void;
  37836. /**
  37837. * Defines which axis you'd like to control for up & down
  37838. * @param axis defines the axis to use
  37839. */
  37840. setAxisForUpDown(axis: JoystickAxis): void;
  37841. private _drawVirtualJoystick;
  37842. /**
  37843. * Release internal HTML canvas
  37844. */
  37845. releaseCanvas(): void;
  37846. }
  37847. }
  37848. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  37849. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  37850. import { Nullable } from "babylonjs/types";
  37851. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37852. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37853. module "babylonjs/Cameras/freeCameraInputsManager" {
  37854. interface FreeCameraInputsManager {
  37855. /**
  37856. * Add virtual joystick input support to the input manager.
  37857. * @returns the current input manager
  37858. */
  37859. addVirtualJoystick(): FreeCameraInputsManager;
  37860. }
  37861. }
  37862. /**
  37863. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37864. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37865. */
  37866. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37867. /**
  37868. * Defines the camera the input is attached to.
  37869. */
  37870. camera: FreeCamera;
  37871. private _leftjoystick;
  37872. private _rightjoystick;
  37873. /**
  37874. * Gets the left stick of the virtual joystick.
  37875. * @returns The virtual Joystick
  37876. */
  37877. getLeftJoystick(): VirtualJoystick;
  37878. /**
  37879. * Gets the right stick of the virtual joystick.
  37880. * @returns The virtual Joystick
  37881. */
  37882. getRightJoystick(): VirtualJoystick;
  37883. /**
  37884. * Update the current camera state depending on the inputs that have been used this frame.
  37885. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37886. */
  37887. checkInputs(): void;
  37888. /**
  37889. * Attach the input controls to a specific dom element to get the input from.
  37890. * @param element Defines the element the controls should be listened from
  37891. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37892. */
  37893. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37894. /**
  37895. * Detach the current controls from the specified dom element.
  37896. * @param element Defines the element to stop listening the inputs from
  37897. */
  37898. detachControl(element: Nullable<HTMLElement>): void;
  37899. /**
  37900. * Gets the class name of the current intput.
  37901. * @returns the class name
  37902. */
  37903. getClassName(): string;
  37904. /**
  37905. * Get the friendly name associated with the input class.
  37906. * @returns the input friendly name
  37907. */
  37908. getSimpleName(): string;
  37909. }
  37910. }
  37911. declare module "babylonjs/Cameras/Inputs/index" {
  37912. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  37913. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  37914. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  37915. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  37916. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  37917. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  37918. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  37919. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  37920. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  37921. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  37922. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  37923. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  37924. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  37925. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  37926. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  37927. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  37928. }
  37929. declare module "babylonjs/Cameras/touchCamera" {
  37930. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37931. import { Scene } from "babylonjs/scene";
  37932. import { Vector3 } from "babylonjs/Maths/math";
  37933. /**
  37934. * This represents a FPS type of camera controlled by touch.
  37935. * This is like a universal camera minus the Gamepad controls.
  37936. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37937. */
  37938. export class TouchCamera extends FreeCamera {
  37939. /**
  37940. * Defines the touch sensibility for rotation.
  37941. * The higher the faster.
  37942. */
  37943. touchAngularSensibility: number;
  37944. /**
  37945. * Defines the touch sensibility for move.
  37946. * The higher the faster.
  37947. */
  37948. touchMoveSensibility: number;
  37949. /**
  37950. * Instantiates a new touch camera.
  37951. * This represents a FPS type of camera controlled by touch.
  37952. * This is like a universal camera minus the Gamepad controls.
  37953. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37954. * @param name Define the name of the camera in the scene
  37955. * @param position Define the start position of the camera in the scene
  37956. * @param scene Define the scene the camera belongs to
  37957. */
  37958. constructor(name: string, position: Vector3, scene: Scene);
  37959. /**
  37960. * Gets the current object class name.
  37961. * @return the class name
  37962. */
  37963. getClassName(): string;
  37964. /** @hidden */
  37965. _setupInputs(): void;
  37966. }
  37967. }
  37968. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  37969. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37970. import { Scene } from "babylonjs/scene";
  37971. import { Vector3, Axis } from "babylonjs/Maths/math";
  37972. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  37973. /**
  37974. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37975. * being tilted forward or back and left or right.
  37976. */
  37977. export class DeviceOrientationCamera extends FreeCamera {
  37978. private _initialQuaternion;
  37979. private _quaternionCache;
  37980. /**
  37981. * Creates a new device orientation camera
  37982. * @param name The name of the camera
  37983. * @param position The start position camera
  37984. * @param scene The scene the camera belongs to
  37985. */
  37986. constructor(name: string, position: Vector3, scene: Scene);
  37987. /**
  37988. * Gets the current instance class name ("DeviceOrientationCamera").
  37989. * This helps avoiding instanceof at run time.
  37990. * @returns the class name
  37991. */
  37992. getClassName(): string;
  37993. /**
  37994. * @hidden
  37995. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37996. */
  37997. _checkInputs(): void;
  37998. /**
  37999. * Reset the camera to its default orientation on the specified axis only.
  38000. * @param axis The axis to reset
  38001. */
  38002. resetToCurrentRotation(axis?: Axis): void;
  38003. }
  38004. }
  38005. declare module "babylonjs/Cameras/universalCamera" {
  38006. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  38007. import { Scene } from "babylonjs/scene";
  38008. import { Vector3 } from "babylonjs/Maths/math";
  38009. /**
  38010. * 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,
  38011. * which still works and will still be found in many Playgrounds.
  38012. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38013. */
  38014. export class UniversalCamera extends TouchCamera {
  38015. /**
  38016. * Defines the gamepad rotation sensiblity.
  38017. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38018. */
  38019. gamepadAngularSensibility: number;
  38020. /**
  38021. * Defines the gamepad move sensiblity.
  38022. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38023. */
  38024. gamepadMoveSensibility: number;
  38025. /**
  38026. * 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,
  38027. * which still works and will still be found in many Playgrounds.
  38028. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38029. * @param name Define the name of the camera in the scene
  38030. * @param position Define the start position of the camera in the scene
  38031. * @param scene Define the scene the camera belongs to
  38032. */
  38033. constructor(name: string, position: Vector3, scene: Scene);
  38034. /**
  38035. * Gets the current object class name.
  38036. * @return the class name
  38037. */
  38038. getClassName(): string;
  38039. }
  38040. }
  38041. declare module "babylonjs/Cameras/gamepadCamera" {
  38042. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38043. import { Scene } from "babylonjs/scene";
  38044. import { Vector3 } from "babylonjs/Maths/math";
  38045. /**
  38046. * This represents a FPS type of camera. This is only here for back compat purpose.
  38047. * Please use the UniversalCamera instead as both are identical.
  38048. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38049. */
  38050. export class GamepadCamera extends UniversalCamera {
  38051. /**
  38052. * Instantiates a new Gamepad Camera
  38053. * This represents a FPS type of camera. This is only here for back compat purpose.
  38054. * Please use the UniversalCamera instead as both are identical.
  38055. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38056. * @param name Define the name of the camera in the scene
  38057. * @param position Define the start position of the camera in the scene
  38058. * @param scene Define the scene the camera belongs to
  38059. */
  38060. constructor(name: string, position: Vector3, scene: Scene);
  38061. /**
  38062. * Gets the current object class name.
  38063. * @return the class name
  38064. */
  38065. getClassName(): string;
  38066. }
  38067. }
  38068. declare module "babylonjs/Shaders/pass.fragment" {
  38069. /** @hidden */
  38070. export var passPixelShader: {
  38071. name: string;
  38072. shader: string;
  38073. };
  38074. }
  38075. declare module "babylonjs/Shaders/passCube.fragment" {
  38076. /** @hidden */
  38077. export var passCubePixelShader: {
  38078. name: string;
  38079. shader: string;
  38080. };
  38081. }
  38082. declare module "babylonjs/PostProcesses/passPostProcess" {
  38083. import { Nullable } from "babylonjs/types";
  38084. import { Camera } from "babylonjs/Cameras/camera";
  38085. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38086. import { Engine } from "babylonjs/Engines/engine";
  38087. import "babylonjs/Shaders/pass.fragment";
  38088. import "babylonjs/Shaders/passCube.fragment";
  38089. /**
  38090. * PassPostProcess which produces an output the same as it's input
  38091. */
  38092. export class PassPostProcess extends PostProcess {
  38093. /**
  38094. * Creates the PassPostProcess
  38095. * @param name The name of the effect.
  38096. * @param options The required width/height ratio to downsize to before computing the render pass.
  38097. * @param camera The camera to apply the render pass to.
  38098. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38099. * @param engine The engine which the post process will be applied. (default: current engine)
  38100. * @param reusable If the post process can be reused on the same frame. (default: false)
  38101. * @param textureType The type of texture to be used when performing the post processing.
  38102. * @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)
  38103. */
  38104. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38105. }
  38106. /**
  38107. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38108. */
  38109. export class PassCubePostProcess extends PostProcess {
  38110. private _face;
  38111. /**
  38112. * Gets or sets the cube face to display.
  38113. * * 0 is +X
  38114. * * 1 is -X
  38115. * * 2 is +Y
  38116. * * 3 is -Y
  38117. * * 4 is +Z
  38118. * * 5 is -Z
  38119. */
  38120. face: number;
  38121. /**
  38122. * Creates the PassCubePostProcess
  38123. * @param name The name of the effect.
  38124. * @param options The required width/height ratio to downsize to before computing the render pass.
  38125. * @param camera The camera to apply the render pass to.
  38126. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38127. * @param engine The engine which the post process will be applied. (default: current engine)
  38128. * @param reusable If the post process can be reused on the same frame. (default: false)
  38129. * @param textureType The type of texture to be used when performing the post processing.
  38130. * @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)
  38131. */
  38132. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38133. }
  38134. }
  38135. declare module "babylonjs/Shaders/anaglyph.fragment" {
  38136. /** @hidden */
  38137. export var anaglyphPixelShader: {
  38138. name: string;
  38139. shader: string;
  38140. };
  38141. }
  38142. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  38143. import { Engine } from "babylonjs/Engines/engine";
  38144. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38145. import { Camera } from "babylonjs/Cameras/camera";
  38146. import "babylonjs/Shaders/anaglyph.fragment";
  38147. /**
  38148. * Postprocess used to generate anaglyphic rendering
  38149. */
  38150. export class AnaglyphPostProcess extends PostProcess {
  38151. private _passedProcess;
  38152. /**
  38153. * Creates a new AnaglyphPostProcess
  38154. * @param name defines postprocess name
  38155. * @param options defines creation options or target ratio scale
  38156. * @param rigCameras defines cameras using this postprocess
  38157. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38158. * @param engine defines hosting engine
  38159. * @param reusable defines if the postprocess will be reused multiple times per frame
  38160. */
  38161. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38162. }
  38163. }
  38164. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  38165. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  38166. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38167. import { Scene } from "babylonjs/scene";
  38168. import { Vector3 } from "babylonjs/Maths/math";
  38169. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38170. /**
  38171. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38172. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38173. */
  38174. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38175. /**
  38176. * Creates a new AnaglyphArcRotateCamera
  38177. * @param name defines camera name
  38178. * @param alpha defines alpha angle (in radians)
  38179. * @param beta defines beta angle (in radians)
  38180. * @param radius defines radius
  38181. * @param target defines camera target
  38182. * @param interaxialDistance defines distance between each color axis
  38183. * @param scene defines the hosting scene
  38184. */
  38185. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38186. /**
  38187. * Gets camera class name
  38188. * @returns AnaglyphArcRotateCamera
  38189. */
  38190. getClassName(): string;
  38191. }
  38192. }
  38193. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  38194. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38195. import { Scene } from "babylonjs/scene";
  38196. import { Vector3 } from "babylonjs/Maths/math";
  38197. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38198. /**
  38199. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38200. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38201. */
  38202. export class AnaglyphFreeCamera extends FreeCamera {
  38203. /**
  38204. * Creates a new AnaglyphFreeCamera
  38205. * @param name defines camera name
  38206. * @param position defines initial position
  38207. * @param interaxialDistance defines distance between each color axis
  38208. * @param scene defines the hosting scene
  38209. */
  38210. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38211. /**
  38212. * Gets camera class name
  38213. * @returns AnaglyphFreeCamera
  38214. */
  38215. getClassName(): string;
  38216. }
  38217. }
  38218. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  38219. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38220. import { Scene } from "babylonjs/scene";
  38221. import { Vector3 } from "babylonjs/Maths/math";
  38222. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38223. /**
  38224. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38225. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38226. */
  38227. export class AnaglyphGamepadCamera extends GamepadCamera {
  38228. /**
  38229. * Creates a new AnaglyphGamepadCamera
  38230. * @param name defines camera name
  38231. * @param position defines initial position
  38232. * @param interaxialDistance defines distance between each color axis
  38233. * @param scene defines the hosting scene
  38234. */
  38235. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38236. /**
  38237. * Gets camera class name
  38238. * @returns AnaglyphGamepadCamera
  38239. */
  38240. getClassName(): string;
  38241. }
  38242. }
  38243. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  38244. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38245. import { Scene } from "babylonjs/scene";
  38246. import { Vector3 } from "babylonjs/Maths/math";
  38247. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38248. /**
  38249. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38250. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38251. */
  38252. export class AnaglyphUniversalCamera extends UniversalCamera {
  38253. /**
  38254. * Creates a new AnaglyphUniversalCamera
  38255. * @param name defines camera name
  38256. * @param position defines initial position
  38257. * @param interaxialDistance defines distance between each color axis
  38258. * @param scene defines the hosting scene
  38259. */
  38260. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38261. /**
  38262. * Gets camera class name
  38263. * @returns AnaglyphUniversalCamera
  38264. */
  38265. getClassName(): string;
  38266. }
  38267. }
  38268. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  38269. /** @hidden */
  38270. export var stereoscopicInterlacePixelShader: {
  38271. name: string;
  38272. shader: string;
  38273. };
  38274. }
  38275. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  38276. import { Camera } from "babylonjs/Cameras/camera";
  38277. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38278. import { Engine } from "babylonjs/Engines/engine";
  38279. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  38280. /**
  38281. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38282. */
  38283. export class StereoscopicInterlacePostProcess extends PostProcess {
  38284. private _stepSize;
  38285. private _passedProcess;
  38286. /**
  38287. * Initializes a StereoscopicInterlacePostProcess
  38288. * @param name The name of the effect.
  38289. * @param rigCameras The rig cameras to be appled to the post process
  38290. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38291. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38292. * @param engine The engine which the post process will be applied. (default: current engine)
  38293. * @param reusable If the post process can be reused on the same frame. (default: false)
  38294. */
  38295. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38296. }
  38297. }
  38298. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  38299. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  38300. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38301. import { Scene } from "babylonjs/scene";
  38302. import { Vector3 } from "babylonjs/Maths/math";
  38303. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38304. /**
  38305. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38306. * @see http://doc.babylonjs.com/features/cameras
  38307. */
  38308. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38309. /**
  38310. * Creates a new StereoscopicArcRotateCamera
  38311. * @param name defines camera name
  38312. * @param alpha defines alpha angle (in radians)
  38313. * @param beta defines beta angle (in radians)
  38314. * @param radius defines radius
  38315. * @param target defines camera target
  38316. * @param interaxialDistance defines distance between each color axis
  38317. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38318. * @param scene defines the hosting scene
  38319. */
  38320. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38321. /**
  38322. * Gets camera class name
  38323. * @returns StereoscopicArcRotateCamera
  38324. */
  38325. getClassName(): string;
  38326. }
  38327. }
  38328. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  38329. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38330. import { Scene } from "babylonjs/scene";
  38331. import { Vector3 } from "babylonjs/Maths/math";
  38332. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38333. /**
  38334. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38335. * @see http://doc.babylonjs.com/features/cameras
  38336. */
  38337. export class StereoscopicFreeCamera extends FreeCamera {
  38338. /**
  38339. * Creates a new StereoscopicFreeCamera
  38340. * @param name defines camera name
  38341. * @param position defines initial position
  38342. * @param interaxialDistance defines distance between each color axis
  38343. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38344. * @param scene defines the hosting scene
  38345. */
  38346. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38347. /**
  38348. * Gets camera class name
  38349. * @returns StereoscopicFreeCamera
  38350. */
  38351. getClassName(): string;
  38352. }
  38353. }
  38354. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  38355. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38356. import { Scene } from "babylonjs/scene";
  38357. import { Vector3 } from "babylonjs/Maths/math";
  38358. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38359. /**
  38360. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38361. * @see http://doc.babylonjs.com/features/cameras
  38362. */
  38363. export class StereoscopicGamepadCamera extends GamepadCamera {
  38364. /**
  38365. * Creates a new StereoscopicGamepadCamera
  38366. * @param name defines camera name
  38367. * @param position defines initial position
  38368. * @param interaxialDistance defines distance between each color axis
  38369. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38370. * @param scene defines the hosting scene
  38371. */
  38372. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38373. /**
  38374. * Gets camera class name
  38375. * @returns StereoscopicGamepadCamera
  38376. */
  38377. getClassName(): string;
  38378. }
  38379. }
  38380. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  38381. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38382. import { Scene } from "babylonjs/scene";
  38383. import { Vector3 } from "babylonjs/Maths/math";
  38384. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38385. /**
  38386. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38387. * @see http://doc.babylonjs.com/features/cameras
  38388. */
  38389. export class StereoscopicUniversalCamera extends UniversalCamera {
  38390. /**
  38391. * Creates a new StereoscopicUniversalCamera
  38392. * @param name defines camera name
  38393. * @param position defines initial position
  38394. * @param interaxialDistance defines distance between each color axis
  38395. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38396. * @param scene defines the hosting scene
  38397. */
  38398. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38399. /**
  38400. * Gets camera class name
  38401. * @returns StereoscopicUniversalCamera
  38402. */
  38403. getClassName(): string;
  38404. }
  38405. }
  38406. declare module "babylonjs/Cameras/Stereoscopic/index" {
  38407. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  38408. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  38409. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  38410. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  38411. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  38412. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  38413. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  38414. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  38415. }
  38416. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  38417. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38418. import { Scene } from "babylonjs/scene";
  38419. import { Vector3 } from "babylonjs/Maths/math";
  38420. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38421. /**
  38422. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38423. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38424. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38425. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38426. */
  38427. export class VirtualJoysticksCamera extends FreeCamera {
  38428. /**
  38429. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38430. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38431. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38432. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38433. * @param name Define the name of the camera in the scene
  38434. * @param position Define the start position of the camera in the scene
  38435. * @param scene Define the scene the camera belongs to
  38436. */
  38437. constructor(name: string, position: Vector3, scene: Scene);
  38438. /**
  38439. * Gets the current object class name.
  38440. * @return the class name
  38441. */
  38442. getClassName(): string;
  38443. }
  38444. }
  38445. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  38446. import { Matrix } from "babylonjs/Maths/math";
  38447. /**
  38448. * This represents all the required metrics to create a VR camera.
  38449. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38450. */
  38451. export class VRCameraMetrics {
  38452. /**
  38453. * Define the horizontal resolution off the screen.
  38454. */
  38455. hResolution: number;
  38456. /**
  38457. * Define the vertical resolution off the screen.
  38458. */
  38459. vResolution: number;
  38460. /**
  38461. * Define the horizontal screen size.
  38462. */
  38463. hScreenSize: number;
  38464. /**
  38465. * Define the vertical screen size.
  38466. */
  38467. vScreenSize: number;
  38468. /**
  38469. * Define the vertical screen center position.
  38470. */
  38471. vScreenCenter: number;
  38472. /**
  38473. * Define the distance of the eyes to the screen.
  38474. */
  38475. eyeToScreenDistance: number;
  38476. /**
  38477. * Define the distance between both lenses
  38478. */
  38479. lensSeparationDistance: number;
  38480. /**
  38481. * Define the distance between both viewer's eyes.
  38482. */
  38483. interpupillaryDistance: number;
  38484. /**
  38485. * Define the distortion factor of the VR postprocess.
  38486. * Please, touch with care.
  38487. */
  38488. distortionK: number[];
  38489. /**
  38490. * Define the chromatic aberration correction factors for the VR post process.
  38491. */
  38492. chromaAbCorrection: number[];
  38493. /**
  38494. * Define the scale factor of the post process.
  38495. * The smaller the better but the slower.
  38496. */
  38497. postProcessScaleFactor: number;
  38498. /**
  38499. * Define an offset for the lens center.
  38500. */
  38501. lensCenterOffset: number;
  38502. /**
  38503. * Define if the current vr camera should compensate the distortion of the lense or not.
  38504. */
  38505. compensateDistortion: boolean;
  38506. /**
  38507. * Gets the rendering aspect ratio based on the provided resolutions.
  38508. */
  38509. readonly aspectRatio: number;
  38510. /**
  38511. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38512. */
  38513. readonly aspectRatioFov: number;
  38514. /**
  38515. * @hidden
  38516. */
  38517. readonly leftHMatrix: Matrix;
  38518. /**
  38519. * @hidden
  38520. */
  38521. readonly rightHMatrix: Matrix;
  38522. /**
  38523. * @hidden
  38524. */
  38525. readonly leftPreViewMatrix: Matrix;
  38526. /**
  38527. * @hidden
  38528. */
  38529. readonly rightPreViewMatrix: Matrix;
  38530. /**
  38531. * Get the default VRMetrics based on the most generic setup.
  38532. * @returns the default vr metrics
  38533. */
  38534. static GetDefault(): VRCameraMetrics;
  38535. }
  38536. }
  38537. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  38538. /** @hidden */
  38539. export var vrDistortionCorrectionPixelShader: {
  38540. name: string;
  38541. shader: string;
  38542. };
  38543. }
  38544. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  38545. import { Camera } from "babylonjs/Cameras/camera";
  38546. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38547. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38548. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  38549. /**
  38550. * VRDistortionCorrectionPostProcess used for mobile VR
  38551. */
  38552. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38553. private _isRightEye;
  38554. private _distortionFactors;
  38555. private _postProcessScaleFactor;
  38556. private _lensCenterOffset;
  38557. private _scaleIn;
  38558. private _scaleFactor;
  38559. private _lensCenter;
  38560. /**
  38561. * Initializes the VRDistortionCorrectionPostProcess
  38562. * @param name The name of the effect.
  38563. * @param camera The camera to apply the render pass to.
  38564. * @param isRightEye If this is for the right eye distortion
  38565. * @param vrMetrics All the required metrics for the VR camera
  38566. */
  38567. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38568. }
  38569. }
  38570. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  38571. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  38572. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38573. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38574. import { Scene } from "babylonjs/scene";
  38575. import { Vector3 } from "babylonjs/Maths/math";
  38576. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38577. import "babylonjs/Cameras/RigModes/vrRigMode";
  38578. /**
  38579. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38580. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38581. */
  38582. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38583. /**
  38584. * Creates a new VRDeviceOrientationArcRotateCamera
  38585. * @param name defines camera name
  38586. * @param alpha defines the camera rotation along the logitudinal axis
  38587. * @param beta defines the camera rotation along the latitudinal axis
  38588. * @param radius defines the camera distance from its target
  38589. * @param target defines the camera target
  38590. * @param scene defines the scene the camera belongs to
  38591. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38592. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38593. */
  38594. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38595. /**
  38596. * Gets camera class name
  38597. * @returns VRDeviceOrientationArcRotateCamera
  38598. */
  38599. getClassName(): string;
  38600. }
  38601. }
  38602. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  38603. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  38604. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38605. import { Scene } from "babylonjs/scene";
  38606. import { Vector3 } from "babylonjs/Maths/math";
  38607. import "babylonjs/Cameras/RigModes/vrRigMode";
  38608. /**
  38609. * Camera used to simulate VR rendering (based on FreeCamera)
  38610. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38611. */
  38612. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38613. /**
  38614. * Creates a new VRDeviceOrientationFreeCamera
  38615. * @param name defines camera name
  38616. * @param position defines the start position of the camera
  38617. * @param scene defines the scene the camera belongs to
  38618. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38619. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38620. */
  38621. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38622. /**
  38623. * Gets camera class name
  38624. * @returns VRDeviceOrientationFreeCamera
  38625. */
  38626. getClassName(): string;
  38627. }
  38628. }
  38629. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  38630. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  38631. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38632. import { Scene } from "babylonjs/scene";
  38633. import { Vector3 } from "babylonjs/Maths/math";
  38634. /**
  38635. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38636. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38637. */
  38638. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38639. /**
  38640. * Creates a new VRDeviceOrientationGamepadCamera
  38641. * @param name defines camera name
  38642. * @param position defines the start position of the camera
  38643. * @param scene defines the scene the camera belongs to
  38644. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38645. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38646. */
  38647. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38648. /**
  38649. * Gets camera class name
  38650. * @returns VRDeviceOrientationGamepadCamera
  38651. */
  38652. getClassName(): string;
  38653. }
  38654. }
  38655. declare module "babylonjs/Gamepads/xboxGamepad" {
  38656. import { Observable } from "babylonjs/Misc/observable";
  38657. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38658. /**
  38659. * Defines supported buttons for XBox360 compatible gamepads
  38660. */
  38661. export enum Xbox360Button {
  38662. /** A */
  38663. A = 0,
  38664. /** B */
  38665. B = 1,
  38666. /** X */
  38667. X = 2,
  38668. /** Y */
  38669. Y = 3,
  38670. /** Start */
  38671. Start = 4,
  38672. /** Back */
  38673. Back = 5,
  38674. /** Left button */
  38675. LB = 6,
  38676. /** Right button */
  38677. RB = 7,
  38678. /** Left stick */
  38679. LeftStick = 8,
  38680. /** Right stick */
  38681. RightStick = 9
  38682. }
  38683. /** Defines values for XBox360 DPad */
  38684. export enum Xbox360Dpad {
  38685. /** Up */
  38686. Up = 0,
  38687. /** Down */
  38688. Down = 1,
  38689. /** Left */
  38690. Left = 2,
  38691. /** Right */
  38692. Right = 3
  38693. }
  38694. /**
  38695. * Defines a XBox360 gamepad
  38696. */
  38697. export class Xbox360Pad extends Gamepad {
  38698. private _leftTrigger;
  38699. private _rightTrigger;
  38700. private _onlefttriggerchanged;
  38701. private _onrighttriggerchanged;
  38702. private _onbuttondown;
  38703. private _onbuttonup;
  38704. private _ondpaddown;
  38705. private _ondpadup;
  38706. /** Observable raised when a button is pressed */
  38707. onButtonDownObservable: Observable<Xbox360Button>;
  38708. /** Observable raised when a button is released */
  38709. onButtonUpObservable: Observable<Xbox360Button>;
  38710. /** Observable raised when a pad is pressed */
  38711. onPadDownObservable: Observable<Xbox360Dpad>;
  38712. /** Observable raised when a pad is released */
  38713. onPadUpObservable: Observable<Xbox360Dpad>;
  38714. private _buttonA;
  38715. private _buttonB;
  38716. private _buttonX;
  38717. private _buttonY;
  38718. private _buttonBack;
  38719. private _buttonStart;
  38720. private _buttonLB;
  38721. private _buttonRB;
  38722. private _buttonLeftStick;
  38723. private _buttonRightStick;
  38724. private _dPadUp;
  38725. private _dPadDown;
  38726. private _dPadLeft;
  38727. private _dPadRight;
  38728. private _isXboxOnePad;
  38729. /**
  38730. * Creates a new XBox360 gamepad object
  38731. * @param id defines the id of this gamepad
  38732. * @param index defines its index
  38733. * @param gamepad defines the internal HTML gamepad object
  38734. * @param xboxOne defines if it is a XBox One gamepad
  38735. */
  38736. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38737. /**
  38738. * Defines the callback to call when left trigger is pressed
  38739. * @param callback defines the callback to use
  38740. */
  38741. onlefttriggerchanged(callback: (value: number) => void): void;
  38742. /**
  38743. * Defines the callback to call when right trigger is pressed
  38744. * @param callback defines the callback to use
  38745. */
  38746. onrighttriggerchanged(callback: (value: number) => void): void;
  38747. /**
  38748. * Gets the left trigger value
  38749. */
  38750. /**
  38751. * Sets the left trigger value
  38752. */
  38753. leftTrigger: number;
  38754. /**
  38755. * Gets the right trigger value
  38756. */
  38757. /**
  38758. * Sets the right trigger value
  38759. */
  38760. rightTrigger: number;
  38761. /**
  38762. * Defines the callback to call when a button is pressed
  38763. * @param callback defines the callback to use
  38764. */
  38765. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38766. /**
  38767. * Defines the callback to call when a button is released
  38768. * @param callback defines the callback to use
  38769. */
  38770. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38771. /**
  38772. * Defines the callback to call when a pad is pressed
  38773. * @param callback defines the callback to use
  38774. */
  38775. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38776. /**
  38777. * Defines the callback to call when a pad is released
  38778. * @param callback defines the callback to use
  38779. */
  38780. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38781. private _setButtonValue;
  38782. private _setDPadValue;
  38783. /**
  38784. * Gets the value of the `A` button
  38785. */
  38786. /**
  38787. * Sets the value of the `A` button
  38788. */
  38789. buttonA: number;
  38790. /**
  38791. * Gets the value of the `B` button
  38792. */
  38793. /**
  38794. * Sets the value of the `B` button
  38795. */
  38796. buttonB: number;
  38797. /**
  38798. * Gets the value of the `X` button
  38799. */
  38800. /**
  38801. * Sets the value of the `X` button
  38802. */
  38803. buttonX: number;
  38804. /**
  38805. * Gets the value of the `Y` button
  38806. */
  38807. /**
  38808. * Sets the value of the `Y` button
  38809. */
  38810. buttonY: number;
  38811. /**
  38812. * Gets the value of the `Start` button
  38813. */
  38814. /**
  38815. * Sets the value of the `Start` button
  38816. */
  38817. buttonStart: number;
  38818. /**
  38819. * Gets the value of the `Back` button
  38820. */
  38821. /**
  38822. * Sets the value of the `Back` button
  38823. */
  38824. buttonBack: number;
  38825. /**
  38826. * Gets the value of the `Left` button
  38827. */
  38828. /**
  38829. * Sets the value of the `Left` button
  38830. */
  38831. buttonLB: number;
  38832. /**
  38833. * Gets the value of the `Right` button
  38834. */
  38835. /**
  38836. * Sets the value of the `Right` button
  38837. */
  38838. buttonRB: number;
  38839. /**
  38840. * Gets the value of the Left joystick
  38841. */
  38842. /**
  38843. * Sets the value of the Left joystick
  38844. */
  38845. buttonLeftStick: number;
  38846. /**
  38847. * Gets the value of the Right joystick
  38848. */
  38849. /**
  38850. * Sets the value of the Right joystick
  38851. */
  38852. buttonRightStick: number;
  38853. /**
  38854. * Gets the value of D-pad up
  38855. */
  38856. /**
  38857. * Sets the value of D-pad up
  38858. */
  38859. dPadUp: number;
  38860. /**
  38861. * Gets the value of D-pad down
  38862. */
  38863. /**
  38864. * Sets the value of D-pad down
  38865. */
  38866. dPadDown: number;
  38867. /**
  38868. * Gets the value of D-pad left
  38869. */
  38870. /**
  38871. * Sets the value of D-pad left
  38872. */
  38873. dPadLeft: number;
  38874. /**
  38875. * Gets the value of D-pad right
  38876. */
  38877. /**
  38878. * Sets the value of D-pad right
  38879. */
  38880. dPadRight: number;
  38881. /**
  38882. * Force the gamepad to synchronize with device values
  38883. */
  38884. update(): void;
  38885. /**
  38886. * Disposes the gamepad
  38887. */
  38888. dispose(): void;
  38889. }
  38890. }
  38891. declare module "babylonjs/Materials/pushMaterial" {
  38892. import { Nullable } from "babylonjs/types";
  38893. import { Scene } from "babylonjs/scene";
  38894. import { Matrix } from "babylonjs/Maths/math";
  38895. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38896. import { Mesh } from "babylonjs/Meshes/mesh";
  38897. import { Material } from "babylonjs/Materials/material";
  38898. import { Effect } from "babylonjs/Materials/effect";
  38899. /**
  38900. * Base class of materials working in push mode in babylon JS
  38901. * @hidden
  38902. */
  38903. export class PushMaterial extends Material {
  38904. protected _activeEffect: Effect;
  38905. protected _normalMatrix: Matrix;
  38906. /**
  38907. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38908. * This means that the material can keep using a previous shader while a new one is being compiled.
  38909. * This is mostly used when shader parallel compilation is supported (true by default)
  38910. */
  38911. allowShaderHotSwapping: boolean;
  38912. constructor(name: string, scene: Scene);
  38913. getEffect(): Effect;
  38914. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38915. /**
  38916. * Binds the given world matrix to the active effect
  38917. *
  38918. * @param world the matrix to bind
  38919. */
  38920. bindOnlyWorldMatrix(world: Matrix): void;
  38921. /**
  38922. * Binds the given normal matrix to the active effect
  38923. *
  38924. * @param normalMatrix the matrix to bind
  38925. */
  38926. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38927. bind(world: Matrix, mesh?: Mesh): void;
  38928. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38929. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38930. }
  38931. }
  38932. declare module "babylonjs/Materials/materialFlags" {
  38933. /**
  38934. * This groups all the flags used to control the materials channel.
  38935. */
  38936. export class MaterialFlags {
  38937. private static _DiffuseTextureEnabled;
  38938. /**
  38939. * Are diffuse textures enabled in the application.
  38940. */
  38941. static DiffuseTextureEnabled: boolean;
  38942. private static _AmbientTextureEnabled;
  38943. /**
  38944. * Are ambient textures enabled in the application.
  38945. */
  38946. static AmbientTextureEnabled: boolean;
  38947. private static _OpacityTextureEnabled;
  38948. /**
  38949. * Are opacity textures enabled in the application.
  38950. */
  38951. static OpacityTextureEnabled: boolean;
  38952. private static _ReflectionTextureEnabled;
  38953. /**
  38954. * Are reflection textures enabled in the application.
  38955. */
  38956. static ReflectionTextureEnabled: boolean;
  38957. private static _EmissiveTextureEnabled;
  38958. /**
  38959. * Are emissive textures enabled in the application.
  38960. */
  38961. static EmissiveTextureEnabled: boolean;
  38962. private static _SpecularTextureEnabled;
  38963. /**
  38964. * Are specular textures enabled in the application.
  38965. */
  38966. static SpecularTextureEnabled: boolean;
  38967. private static _BumpTextureEnabled;
  38968. /**
  38969. * Are bump textures enabled in the application.
  38970. */
  38971. static BumpTextureEnabled: boolean;
  38972. private static _LightmapTextureEnabled;
  38973. /**
  38974. * Are lightmap textures enabled in the application.
  38975. */
  38976. static LightmapTextureEnabled: boolean;
  38977. private static _RefractionTextureEnabled;
  38978. /**
  38979. * Are refraction textures enabled in the application.
  38980. */
  38981. static RefractionTextureEnabled: boolean;
  38982. private static _ColorGradingTextureEnabled;
  38983. /**
  38984. * Are color grading textures enabled in the application.
  38985. */
  38986. static ColorGradingTextureEnabled: boolean;
  38987. private static _FresnelEnabled;
  38988. /**
  38989. * Are fresnels enabled in the application.
  38990. */
  38991. static FresnelEnabled: boolean;
  38992. private static _ClearCoatTextureEnabled;
  38993. /**
  38994. * Are clear coat textures enabled in the application.
  38995. */
  38996. static ClearCoatTextureEnabled: boolean;
  38997. private static _ClearCoatBumpTextureEnabled;
  38998. /**
  38999. * Are clear coat bump textures enabled in the application.
  39000. */
  39001. static ClearCoatBumpTextureEnabled: boolean;
  39002. private static _ClearCoatTintTextureEnabled;
  39003. /**
  39004. * Are clear coat tint textures enabled in the application.
  39005. */
  39006. static ClearCoatTintTextureEnabled: boolean;
  39007. private static _SheenTextureEnabled;
  39008. /**
  39009. * Are sheen textures enabled in the application.
  39010. */
  39011. static SheenTextureEnabled: boolean;
  39012. private static _AnisotropicTextureEnabled;
  39013. /**
  39014. * Are anisotropic textures enabled in the application.
  39015. */
  39016. static AnisotropicTextureEnabled: boolean;
  39017. }
  39018. }
  39019. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  39020. /** @hidden */
  39021. export var defaultFragmentDeclaration: {
  39022. name: string;
  39023. shader: string;
  39024. };
  39025. }
  39026. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  39027. /** @hidden */
  39028. export var defaultUboDeclaration: {
  39029. name: string;
  39030. shader: string;
  39031. };
  39032. }
  39033. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  39034. /** @hidden */
  39035. export var lightFragmentDeclaration: {
  39036. name: string;
  39037. shader: string;
  39038. };
  39039. }
  39040. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  39041. /** @hidden */
  39042. export var lightUboDeclaration: {
  39043. name: string;
  39044. shader: string;
  39045. };
  39046. }
  39047. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  39048. /** @hidden */
  39049. export var lightsFragmentFunctions: {
  39050. name: string;
  39051. shader: string;
  39052. };
  39053. }
  39054. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  39055. /** @hidden */
  39056. export var shadowsFragmentFunctions: {
  39057. name: string;
  39058. shader: string;
  39059. };
  39060. }
  39061. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  39062. /** @hidden */
  39063. export var fresnelFunction: {
  39064. name: string;
  39065. shader: string;
  39066. };
  39067. }
  39068. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  39069. /** @hidden */
  39070. export var reflectionFunction: {
  39071. name: string;
  39072. shader: string;
  39073. };
  39074. }
  39075. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  39076. /** @hidden */
  39077. export var bumpFragmentFunctions: {
  39078. name: string;
  39079. shader: string;
  39080. };
  39081. }
  39082. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  39083. /** @hidden */
  39084. export var logDepthDeclaration: {
  39085. name: string;
  39086. shader: string;
  39087. };
  39088. }
  39089. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  39090. /** @hidden */
  39091. export var bumpFragment: {
  39092. name: string;
  39093. shader: string;
  39094. };
  39095. }
  39096. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  39097. /** @hidden */
  39098. export var depthPrePass: {
  39099. name: string;
  39100. shader: string;
  39101. };
  39102. }
  39103. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  39104. /** @hidden */
  39105. export var lightFragment: {
  39106. name: string;
  39107. shader: string;
  39108. };
  39109. }
  39110. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  39111. /** @hidden */
  39112. export var logDepthFragment: {
  39113. name: string;
  39114. shader: string;
  39115. };
  39116. }
  39117. declare module "babylonjs/Shaders/default.fragment" {
  39118. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  39119. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39120. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39121. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39122. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39123. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  39124. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  39125. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  39126. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  39127. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39128. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39129. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  39130. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  39131. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39132. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  39133. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  39134. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  39135. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  39136. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  39137. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  39138. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  39139. /** @hidden */
  39140. export var defaultPixelShader: {
  39141. name: string;
  39142. shader: string;
  39143. };
  39144. }
  39145. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  39146. /** @hidden */
  39147. export var defaultVertexDeclaration: {
  39148. name: string;
  39149. shader: string;
  39150. };
  39151. }
  39152. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  39153. /** @hidden */
  39154. export var bumpVertexDeclaration: {
  39155. name: string;
  39156. shader: string;
  39157. };
  39158. }
  39159. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  39160. /** @hidden */
  39161. export var bumpVertex: {
  39162. name: string;
  39163. shader: string;
  39164. };
  39165. }
  39166. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  39167. /** @hidden */
  39168. export var fogVertex: {
  39169. name: string;
  39170. shader: string;
  39171. };
  39172. }
  39173. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  39174. /** @hidden */
  39175. export var shadowsVertex: {
  39176. name: string;
  39177. shader: string;
  39178. };
  39179. }
  39180. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  39181. /** @hidden */
  39182. export var pointCloudVertex: {
  39183. name: string;
  39184. shader: string;
  39185. };
  39186. }
  39187. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  39188. /** @hidden */
  39189. export var logDepthVertex: {
  39190. name: string;
  39191. shader: string;
  39192. };
  39193. }
  39194. declare module "babylonjs/Shaders/default.vertex" {
  39195. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  39196. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39197. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39198. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  39199. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  39200. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  39201. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  39202. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  39203. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39204. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39205. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  39206. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  39207. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39208. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  39209. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  39210. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  39211. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  39212. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  39213. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  39214. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  39215. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  39216. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  39217. /** @hidden */
  39218. export var defaultVertexShader: {
  39219. name: string;
  39220. shader: string;
  39221. };
  39222. }
  39223. declare module "babylonjs/Materials/standardMaterial" {
  39224. import { SmartArray } from "babylonjs/Misc/smartArray";
  39225. import { IAnimatable } from "babylonjs/Misc/tools";
  39226. import { Nullable } from "babylonjs/types";
  39227. import { Scene } from "babylonjs/scene";
  39228. import { Matrix, Color3 } from "babylonjs/Maths/math";
  39229. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39230. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39231. import { Mesh } from "babylonjs/Meshes/mesh";
  39232. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  39233. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39234. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  39235. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  39236. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  39237. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39238. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39239. import "babylonjs/Shaders/default.fragment";
  39240. import "babylonjs/Shaders/default.vertex";
  39241. /** @hidden */
  39242. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39243. MAINUV1: boolean;
  39244. MAINUV2: boolean;
  39245. DIFFUSE: boolean;
  39246. DIFFUSEDIRECTUV: number;
  39247. AMBIENT: boolean;
  39248. AMBIENTDIRECTUV: number;
  39249. OPACITY: boolean;
  39250. OPACITYDIRECTUV: number;
  39251. OPACITYRGB: boolean;
  39252. REFLECTION: boolean;
  39253. EMISSIVE: boolean;
  39254. EMISSIVEDIRECTUV: number;
  39255. SPECULAR: boolean;
  39256. SPECULARDIRECTUV: number;
  39257. BUMP: boolean;
  39258. BUMPDIRECTUV: number;
  39259. PARALLAX: boolean;
  39260. PARALLAXOCCLUSION: boolean;
  39261. SPECULAROVERALPHA: boolean;
  39262. CLIPPLANE: boolean;
  39263. CLIPPLANE2: boolean;
  39264. CLIPPLANE3: boolean;
  39265. CLIPPLANE4: boolean;
  39266. ALPHATEST: boolean;
  39267. DEPTHPREPASS: boolean;
  39268. ALPHAFROMDIFFUSE: boolean;
  39269. POINTSIZE: boolean;
  39270. FOG: boolean;
  39271. SPECULARTERM: boolean;
  39272. DIFFUSEFRESNEL: boolean;
  39273. OPACITYFRESNEL: boolean;
  39274. REFLECTIONFRESNEL: boolean;
  39275. REFRACTIONFRESNEL: boolean;
  39276. EMISSIVEFRESNEL: boolean;
  39277. FRESNEL: boolean;
  39278. NORMAL: boolean;
  39279. UV1: boolean;
  39280. UV2: boolean;
  39281. VERTEXCOLOR: boolean;
  39282. VERTEXALPHA: boolean;
  39283. NUM_BONE_INFLUENCERS: number;
  39284. BonesPerMesh: number;
  39285. BONETEXTURE: boolean;
  39286. INSTANCES: boolean;
  39287. GLOSSINESS: boolean;
  39288. ROUGHNESS: boolean;
  39289. EMISSIVEASILLUMINATION: boolean;
  39290. LINKEMISSIVEWITHDIFFUSE: boolean;
  39291. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39292. LIGHTMAP: boolean;
  39293. LIGHTMAPDIRECTUV: number;
  39294. OBJECTSPACE_NORMALMAP: boolean;
  39295. USELIGHTMAPASSHADOWMAP: boolean;
  39296. REFLECTIONMAP_3D: boolean;
  39297. REFLECTIONMAP_SPHERICAL: boolean;
  39298. REFLECTIONMAP_PLANAR: boolean;
  39299. REFLECTIONMAP_CUBIC: boolean;
  39300. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39301. REFLECTIONMAP_PROJECTION: boolean;
  39302. REFLECTIONMAP_SKYBOX: boolean;
  39303. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39304. REFLECTIONMAP_EXPLICIT: boolean;
  39305. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39306. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39307. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39308. INVERTCUBICMAP: boolean;
  39309. LOGARITHMICDEPTH: boolean;
  39310. REFRACTION: boolean;
  39311. REFRACTIONMAP_3D: boolean;
  39312. REFLECTIONOVERALPHA: boolean;
  39313. TWOSIDEDLIGHTING: boolean;
  39314. SHADOWFLOAT: boolean;
  39315. MORPHTARGETS: boolean;
  39316. MORPHTARGETS_NORMAL: boolean;
  39317. MORPHTARGETS_TANGENT: boolean;
  39318. NUM_MORPH_INFLUENCERS: number;
  39319. NONUNIFORMSCALING: boolean;
  39320. PREMULTIPLYALPHA: boolean;
  39321. IMAGEPROCESSING: boolean;
  39322. VIGNETTE: boolean;
  39323. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39324. VIGNETTEBLENDMODEOPAQUE: boolean;
  39325. TONEMAPPING: boolean;
  39326. TONEMAPPING_ACES: boolean;
  39327. CONTRAST: boolean;
  39328. COLORCURVES: boolean;
  39329. COLORGRADING: boolean;
  39330. COLORGRADING3D: boolean;
  39331. SAMPLER3DGREENDEPTH: boolean;
  39332. SAMPLER3DBGRMAP: boolean;
  39333. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39334. /**
  39335. * If the reflection texture on this material is in linear color space
  39336. * @hidden
  39337. */
  39338. IS_REFLECTION_LINEAR: boolean;
  39339. /**
  39340. * If the refraction texture on this material is in linear color space
  39341. * @hidden
  39342. */
  39343. IS_REFRACTION_LINEAR: boolean;
  39344. EXPOSURE: boolean;
  39345. constructor();
  39346. setReflectionMode(modeToEnable: string): void;
  39347. }
  39348. /**
  39349. * This is the default material used in Babylon. It is the best trade off between quality
  39350. * and performances.
  39351. * @see http://doc.babylonjs.com/babylon101/materials
  39352. */
  39353. export class StandardMaterial extends PushMaterial {
  39354. private _diffuseTexture;
  39355. /**
  39356. * The basic texture of the material as viewed under a light.
  39357. */
  39358. diffuseTexture: Nullable<BaseTexture>;
  39359. private _ambientTexture;
  39360. /**
  39361. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39362. */
  39363. ambientTexture: Nullable<BaseTexture>;
  39364. private _opacityTexture;
  39365. /**
  39366. * Define the transparency of the material from a texture.
  39367. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39368. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39369. */
  39370. opacityTexture: Nullable<BaseTexture>;
  39371. private _reflectionTexture;
  39372. /**
  39373. * Define the texture used to display the reflection.
  39374. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39375. */
  39376. reflectionTexture: Nullable<BaseTexture>;
  39377. private _emissiveTexture;
  39378. /**
  39379. * Define texture of the material as if self lit.
  39380. * This will be mixed in the final result even in the absence of light.
  39381. */
  39382. emissiveTexture: Nullable<BaseTexture>;
  39383. private _specularTexture;
  39384. /**
  39385. * Define how the color and intensity of the highlight given by the light in the material.
  39386. */
  39387. specularTexture: Nullable<BaseTexture>;
  39388. private _bumpTexture;
  39389. /**
  39390. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39391. * 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.
  39392. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39393. */
  39394. bumpTexture: Nullable<BaseTexture>;
  39395. private _lightmapTexture;
  39396. /**
  39397. * Complex lighting can be computationally expensive to compute at runtime.
  39398. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39399. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39400. */
  39401. lightmapTexture: Nullable<BaseTexture>;
  39402. private _refractionTexture;
  39403. /**
  39404. * Define the texture used to display the refraction.
  39405. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39406. */
  39407. refractionTexture: Nullable<BaseTexture>;
  39408. /**
  39409. * The color of the material lit by the environmental background lighting.
  39410. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39411. */
  39412. ambientColor: Color3;
  39413. /**
  39414. * The basic color of the material as viewed under a light.
  39415. */
  39416. diffuseColor: Color3;
  39417. /**
  39418. * Define how the color and intensity of the highlight given by the light in the material.
  39419. */
  39420. specularColor: Color3;
  39421. /**
  39422. * Define the color of the material as if self lit.
  39423. * This will be mixed in the final result even in the absence of light.
  39424. */
  39425. emissiveColor: Color3;
  39426. /**
  39427. * Defines how sharp are the highlights in the material.
  39428. * The bigger the value the sharper giving a more glossy feeling to the result.
  39429. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39430. */
  39431. specularPower: number;
  39432. private _useAlphaFromDiffuseTexture;
  39433. /**
  39434. * Does the transparency come from the diffuse texture alpha channel.
  39435. */
  39436. useAlphaFromDiffuseTexture: boolean;
  39437. private _useEmissiveAsIllumination;
  39438. /**
  39439. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39440. */
  39441. useEmissiveAsIllumination: boolean;
  39442. private _linkEmissiveWithDiffuse;
  39443. /**
  39444. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39445. * the emissive level when the final color is close to one.
  39446. */
  39447. linkEmissiveWithDiffuse: boolean;
  39448. private _useSpecularOverAlpha;
  39449. /**
  39450. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39451. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39452. */
  39453. useSpecularOverAlpha: boolean;
  39454. private _useReflectionOverAlpha;
  39455. /**
  39456. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39457. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39458. */
  39459. useReflectionOverAlpha: boolean;
  39460. private _disableLighting;
  39461. /**
  39462. * Does lights from the scene impacts this material.
  39463. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39464. */
  39465. disableLighting: boolean;
  39466. private _useObjectSpaceNormalMap;
  39467. /**
  39468. * Allows using an object space normal map (instead of tangent space).
  39469. */
  39470. useObjectSpaceNormalMap: boolean;
  39471. private _useParallax;
  39472. /**
  39473. * Is parallax enabled or not.
  39474. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39475. */
  39476. useParallax: boolean;
  39477. private _useParallaxOcclusion;
  39478. /**
  39479. * Is parallax occlusion enabled or not.
  39480. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39481. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39482. */
  39483. useParallaxOcclusion: boolean;
  39484. /**
  39485. * 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.
  39486. */
  39487. parallaxScaleBias: number;
  39488. private _roughness;
  39489. /**
  39490. * Helps to define how blurry the reflections should appears in the material.
  39491. */
  39492. roughness: number;
  39493. /**
  39494. * In case of refraction, define the value of the indice of refraction.
  39495. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39496. */
  39497. indexOfRefraction: number;
  39498. /**
  39499. * Invert the refraction texture alongside the y axis.
  39500. * It can be useful with procedural textures or probe for instance.
  39501. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39502. */
  39503. invertRefractionY: boolean;
  39504. /**
  39505. * Defines the alpha limits in alpha test mode.
  39506. */
  39507. alphaCutOff: number;
  39508. private _useLightmapAsShadowmap;
  39509. /**
  39510. * In case of light mapping, define whether the map contains light or shadow informations.
  39511. */
  39512. useLightmapAsShadowmap: boolean;
  39513. private _diffuseFresnelParameters;
  39514. /**
  39515. * Define the diffuse fresnel parameters of the material.
  39516. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39517. */
  39518. diffuseFresnelParameters: FresnelParameters;
  39519. private _opacityFresnelParameters;
  39520. /**
  39521. * Define the opacity fresnel parameters of the material.
  39522. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39523. */
  39524. opacityFresnelParameters: FresnelParameters;
  39525. private _reflectionFresnelParameters;
  39526. /**
  39527. * Define the reflection fresnel parameters of the material.
  39528. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39529. */
  39530. reflectionFresnelParameters: FresnelParameters;
  39531. private _refractionFresnelParameters;
  39532. /**
  39533. * Define the refraction fresnel parameters of the material.
  39534. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39535. */
  39536. refractionFresnelParameters: FresnelParameters;
  39537. private _emissiveFresnelParameters;
  39538. /**
  39539. * Define the emissive fresnel parameters of the material.
  39540. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39541. */
  39542. emissiveFresnelParameters: FresnelParameters;
  39543. private _useReflectionFresnelFromSpecular;
  39544. /**
  39545. * If true automatically deducts the fresnels values from the material specularity.
  39546. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39547. */
  39548. useReflectionFresnelFromSpecular: boolean;
  39549. private _useGlossinessFromSpecularMapAlpha;
  39550. /**
  39551. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39552. */
  39553. useGlossinessFromSpecularMapAlpha: boolean;
  39554. private _maxSimultaneousLights;
  39555. /**
  39556. * Defines the maximum number of lights that can be used in the material
  39557. */
  39558. maxSimultaneousLights: number;
  39559. private _invertNormalMapX;
  39560. /**
  39561. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39562. */
  39563. invertNormalMapX: boolean;
  39564. private _invertNormalMapY;
  39565. /**
  39566. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39567. */
  39568. invertNormalMapY: boolean;
  39569. private _twoSidedLighting;
  39570. /**
  39571. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39572. */
  39573. twoSidedLighting: boolean;
  39574. /**
  39575. * Default configuration related to image processing available in the standard Material.
  39576. */
  39577. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39578. /**
  39579. * Gets the image processing configuration used either in this material.
  39580. */
  39581. /**
  39582. * Sets the Default image processing configuration used either in the this material.
  39583. *
  39584. * If sets to null, the scene one is in use.
  39585. */
  39586. imageProcessingConfiguration: ImageProcessingConfiguration;
  39587. /**
  39588. * Keep track of the image processing observer to allow dispose and replace.
  39589. */
  39590. private _imageProcessingObserver;
  39591. /**
  39592. * Attaches a new image processing configuration to the Standard Material.
  39593. * @param configuration
  39594. */
  39595. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39596. /**
  39597. * Gets wether the color curves effect is enabled.
  39598. */
  39599. /**
  39600. * Sets wether the color curves effect is enabled.
  39601. */
  39602. cameraColorCurvesEnabled: boolean;
  39603. /**
  39604. * Gets wether the color grading effect is enabled.
  39605. */
  39606. /**
  39607. * Gets wether the color grading effect is enabled.
  39608. */
  39609. cameraColorGradingEnabled: boolean;
  39610. /**
  39611. * Gets wether tonemapping is enabled or not.
  39612. */
  39613. /**
  39614. * Sets wether tonemapping is enabled or not
  39615. */
  39616. cameraToneMappingEnabled: boolean;
  39617. /**
  39618. * The camera exposure used on this material.
  39619. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39620. * This corresponds to a photographic exposure.
  39621. */
  39622. /**
  39623. * The camera exposure used on this material.
  39624. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39625. * This corresponds to a photographic exposure.
  39626. */
  39627. cameraExposure: number;
  39628. /**
  39629. * Gets The camera contrast used on this material.
  39630. */
  39631. /**
  39632. * Sets The camera contrast used on this material.
  39633. */
  39634. cameraContrast: number;
  39635. /**
  39636. * Gets the Color Grading 2D Lookup Texture.
  39637. */
  39638. /**
  39639. * Sets the Color Grading 2D Lookup Texture.
  39640. */
  39641. cameraColorGradingTexture: Nullable<BaseTexture>;
  39642. /**
  39643. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39644. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39645. * 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;
  39646. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39647. */
  39648. /**
  39649. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39650. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39651. * 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;
  39652. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39653. */
  39654. cameraColorCurves: Nullable<ColorCurves>;
  39655. /**
  39656. * Custom callback helping to override the default shader used in the material.
  39657. */
  39658. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39659. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39660. protected _worldViewProjectionMatrix: Matrix;
  39661. protected _globalAmbientColor: Color3;
  39662. protected _useLogarithmicDepth: boolean;
  39663. /**
  39664. * Instantiates a new standard material.
  39665. * This is the default material used in Babylon. It is the best trade off between quality
  39666. * and performances.
  39667. * @see http://doc.babylonjs.com/babylon101/materials
  39668. * @param name Define the name of the material in the scene
  39669. * @param scene Define the scene the material belong to
  39670. */
  39671. constructor(name: string, scene: Scene);
  39672. /**
  39673. * Gets a boolean indicating that current material needs to register RTT
  39674. */
  39675. readonly hasRenderTargetTextures: boolean;
  39676. /**
  39677. * Gets the current class name of the material e.g. "StandardMaterial"
  39678. * Mainly use in serialization.
  39679. * @returns the class name
  39680. */
  39681. getClassName(): string;
  39682. /**
  39683. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39684. * You can try switching to logarithmic depth.
  39685. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39686. */
  39687. useLogarithmicDepth: boolean;
  39688. /**
  39689. * Specifies if the material will require alpha blending
  39690. * @returns a boolean specifying if alpha blending is needed
  39691. */
  39692. needAlphaBlending(): boolean;
  39693. /**
  39694. * Specifies if this material should be rendered in alpha test mode
  39695. * @returns a boolean specifying if an alpha test is needed.
  39696. */
  39697. needAlphaTesting(): boolean;
  39698. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39699. /**
  39700. * Get the texture used for alpha test purpose.
  39701. * @returns the diffuse texture in case of the standard material.
  39702. */
  39703. getAlphaTestTexture(): Nullable<BaseTexture>;
  39704. /**
  39705. * Get if the submesh is ready to be used and all its information available.
  39706. * Child classes can use it to update shaders
  39707. * @param mesh defines the mesh to check
  39708. * @param subMesh defines which submesh to check
  39709. * @param useInstances specifies that instances should be used
  39710. * @returns a boolean indicating that the submesh is ready or not
  39711. */
  39712. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39713. /**
  39714. * Builds the material UBO layouts.
  39715. * Used internally during the effect preparation.
  39716. */
  39717. buildUniformLayout(): void;
  39718. /**
  39719. * Unbinds the material from the mesh
  39720. */
  39721. unbind(): void;
  39722. /**
  39723. * Binds the submesh to this material by preparing the effect and shader to draw
  39724. * @param world defines the world transformation matrix
  39725. * @param mesh defines the mesh containing the submesh
  39726. * @param subMesh defines the submesh to bind the material to
  39727. */
  39728. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39729. /**
  39730. * Get the list of animatables in the material.
  39731. * @returns the list of animatables object used in the material
  39732. */
  39733. getAnimatables(): IAnimatable[];
  39734. /**
  39735. * Gets the active textures from the material
  39736. * @returns an array of textures
  39737. */
  39738. getActiveTextures(): BaseTexture[];
  39739. /**
  39740. * Specifies if the material uses a texture
  39741. * @param texture defines the texture to check against the material
  39742. * @returns a boolean specifying if the material uses the texture
  39743. */
  39744. hasTexture(texture: BaseTexture): boolean;
  39745. /**
  39746. * Disposes the material
  39747. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39748. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39749. */
  39750. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39751. /**
  39752. * Makes a duplicate of the material, and gives it a new name
  39753. * @param name defines the new name for the duplicated material
  39754. * @returns the cloned material
  39755. */
  39756. clone(name: string): StandardMaterial;
  39757. /**
  39758. * Serializes this material in a JSON representation
  39759. * @returns the serialized material object
  39760. */
  39761. serialize(): any;
  39762. /**
  39763. * Creates a standard material from parsed material data
  39764. * @param source defines the JSON representation of the material
  39765. * @param scene defines the hosting scene
  39766. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39767. * @returns a new standard material
  39768. */
  39769. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39770. /**
  39771. * Are diffuse textures enabled in the application.
  39772. */
  39773. static DiffuseTextureEnabled: boolean;
  39774. /**
  39775. * Are ambient textures enabled in the application.
  39776. */
  39777. static AmbientTextureEnabled: boolean;
  39778. /**
  39779. * Are opacity textures enabled in the application.
  39780. */
  39781. static OpacityTextureEnabled: boolean;
  39782. /**
  39783. * Are reflection textures enabled in the application.
  39784. */
  39785. static ReflectionTextureEnabled: boolean;
  39786. /**
  39787. * Are emissive textures enabled in the application.
  39788. */
  39789. static EmissiveTextureEnabled: boolean;
  39790. /**
  39791. * Are specular textures enabled in the application.
  39792. */
  39793. static SpecularTextureEnabled: boolean;
  39794. /**
  39795. * Are bump textures enabled in the application.
  39796. */
  39797. static BumpTextureEnabled: boolean;
  39798. /**
  39799. * Are lightmap textures enabled in the application.
  39800. */
  39801. static LightmapTextureEnabled: boolean;
  39802. /**
  39803. * Are refraction textures enabled in the application.
  39804. */
  39805. static RefractionTextureEnabled: boolean;
  39806. /**
  39807. * Are color grading textures enabled in the application.
  39808. */
  39809. static ColorGradingTextureEnabled: boolean;
  39810. /**
  39811. * Are fresnels enabled in the application.
  39812. */
  39813. static FresnelEnabled: boolean;
  39814. }
  39815. }
  39816. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  39817. import { Scene } from "babylonjs/scene";
  39818. import { Texture } from "babylonjs/Materials/Textures/texture";
  39819. /**
  39820. * A class extending Texture allowing drawing on a texture
  39821. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39822. */
  39823. export class DynamicTexture extends Texture {
  39824. private _generateMipMaps;
  39825. private _canvas;
  39826. private _context;
  39827. private _engine;
  39828. /**
  39829. * Creates a DynamicTexture
  39830. * @param name defines the name of the texture
  39831. * @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
  39832. * @param scene defines the scene where you want the texture
  39833. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39834. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39835. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39836. */
  39837. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39838. /**
  39839. * Get the current class name of the texture useful for serialization or dynamic coding.
  39840. * @returns "DynamicTexture"
  39841. */
  39842. getClassName(): string;
  39843. /**
  39844. * Gets the current state of canRescale
  39845. */
  39846. readonly canRescale: boolean;
  39847. private _recreate;
  39848. /**
  39849. * Scales the texture
  39850. * @param ratio the scale factor to apply to both width and height
  39851. */
  39852. scale(ratio: number): void;
  39853. /**
  39854. * Resizes the texture
  39855. * @param width the new width
  39856. * @param height the new height
  39857. */
  39858. scaleTo(width: number, height: number): void;
  39859. /**
  39860. * Gets the context of the canvas used by the texture
  39861. * @returns the canvas context of the dynamic texture
  39862. */
  39863. getContext(): CanvasRenderingContext2D;
  39864. /**
  39865. * Clears the texture
  39866. */
  39867. clear(): void;
  39868. /**
  39869. * Updates the texture
  39870. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39871. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39872. */
  39873. update(invertY?: boolean, premulAlpha?: boolean): void;
  39874. /**
  39875. * Draws text onto the texture
  39876. * @param text defines the text to be drawn
  39877. * @param x defines the placement of the text from the left
  39878. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39879. * @param font defines the font to be used with font-style, font-size, font-name
  39880. * @param color defines the color used for the text
  39881. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39882. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39883. * @param update defines whether texture is immediately update (default is true)
  39884. */
  39885. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39886. /**
  39887. * Clones the texture
  39888. * @returns the clone of the texture.
  39889. */
  39890. clone(): DynamicTexture;
  39891. /**
  39892. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39893. * @returns a serialized dynamic texture object
  39894. */
  39895. serialize(): any;
  39896. /** @hidden */
  39897. _rebuild(): void;
  39898. }
  39899. }
  39900. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  39901. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39902. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39903. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39904. /** @hidden */
  39905. export var imageProcessingPixelShader: {
  39906. name: string;
  39907. shader: string;
  39908. };
  39909. }
  39910. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  39911. import { Nullable } from "babylonjs/types";
  39912. import { Color4 } from "babylonjs/Maths/math";
  39913. import { Camera } from "babylonjs/Cameras/camera";
  39914. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39915. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39916. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39917. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39918. import { Engine } from "babylonjs/Engines/engine";
  39919. import "babylonjs/Shaders/imageProcessing.fragment";
  39920. import "babylonjs/Shaders/postprocess.vertex";
  39921. /**
  39922. * ImageProcessingPostProcess
  39923. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39924. */
  39925. export class ImageProcessingPostProcess extends PostProcess {
  39926. /**
  39927. * Default configuration related to image processing available in the PBR Material.
  39928. */
  39929. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39930. /**
  39931. * Gets the image processing configuration used either in this material.
  39932. */
  39933. /**
  39934. * Sets the Default image processing configuration used either in the this material.
  39935. *
  39936. * If sets to null, the scene one is in use.
  39937. */
  39938. imageProcessingConfiguration: ImageProcessingConfiguration;
  39939. /**
  39940. * Keep track of the image processing observer to allow dispose and replace.
  39941. */
  39942. private _imageProcessingObserver;
  39943. /**
  39944. * Attaches a new image processing configuration to the PBR Material.
  39945. * @param configuration
  39946. */
  39947. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39948. /**
  39949. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39950. */
  39951. /**
  39952. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39953. */
  39954. colorCurves: Nullable<ColorCurves>;
  39955. /**
  39956. * Gets wether the color curves effect is enabled.
  39957. */
  39958. /**
  39959. * Sets wether the color curves effect is enabled.
  39960. */
  39961. colorCurvesEnabled: boolean;
  39962. /**
  39963. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39964. */
  39965. /**
  39966. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39967. */
  39968. colorGradingTexture: Nullable<BaseTexture>;
  39969. /**
  39970. * Gets wether the color grading effect is enabled.
  39971. */
  39972. /**
  39973. * Gets wether the color grading effect is enabled.
  39974. */
  39975. colorGradingEnabled: boolean;
  39976. /**
  39977. * Gets exposure used in the effect.
  39978. */
  39979. /**
  39980. * Sets exposure used in the effect.
  39981. */
  39982. exposure: number;
  39983. /**
  39984. * Gets wether tonemapping is enabled or not.
  39985. */
  39986. /**
  39987. * Sets wether tonemapping is enabled or not
  39988. */
  39989. toneMappingEnabled: boolean;
  39990. /**
  39991. * Gets the type of tone mapping effect.
  39992. */
  39993. /**
  39994. * Sets the type of tone mapping effect.
  39995. */
  39996. toneMappingType: number;
  39997. /**
  39998. * Gets contrast used in the effect.
  39999. */
  40000. /**
  40001. * Sets contrast used in the effect.
  40002. */
  40003. contrast: number;
  40004. /**
  40005. * Gets Vignette stretch size.
  40006. */
  40007. /**
  40008. * Sets Vignette stretch size.
  40009. */
  40010. vignetteStretch: number;
  40011. /**
  40012. * Gets Vignette centre X Offset.
  40013. */
  40014. /**
  40015. * Sets Vignette centre X Offset.
  40016. */
  40017. vignetteCentreX: number;
  40018. /**
  40019. * Gets Vignette centre Y Offset.
  40020. */
  40021. /**
  40022. * Sets Vignette centre Y Offset.
  40023. */
  40024. vignetteCentreY: number;
  40025. /**
  40026. * Gets Vignette weight or intensity of the vignette effect.
  40027. */
  40028. /**
  40029. * Sets Vignette weight or intensity of the vignette effect.
  40030. */
  40031. vignetteWeight: number;
  40032. /**
  40033. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40034. * if vignetteEnabled is set to true.
  40035. */
  40036. /**
  40037. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40038. * if vignetteEnabled is set to true.
  40039. */
  40040. vignetteColor: Color4;
  40041. /**
  40042. * Gets Camera field of view used by the Vignette effect.
  40043. */
  40044. /**
  40045. * Sets Camera field of view used by the Vignette effect.
  40046. */
  40047. vignetteCameraFov: number;
  40048. /**
  40049. * Gets the vignette blend mode allowing different kind of effect.
  40050. */
  40051. /**
  40052. * Sets the vignette blend mode allowing different kind of effect.
  40053. */
  40054. vignetteBlendMode: number;
  40055. /**
  40056. * Gets wether the vignette effect is enabled.
  40057. */
  40058. /**
  40059. * Sets wether the vignette effect is enabled.
  40060. */
  40061. vignetteEnabled: boolean;
  40062. private _fromLinearSpace;
  40063. /**
  40064. * Gets wether the input of the processing is in Gamma or Linear Space.
  40065. */
  40066. /**
  40067. * Sets wether the input of the processing is in Gamma or Linear Space.
  40068. */
  40069. fromLinearSpace: boolean;
  40070. /**
  40071. * Defines cache preventing GC.
  40072. */
  40073. private _defines;
  40074. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40075. /**
  40076. * "ImageProcessingPostProcess"
  40077. * @returns "ImageProcessingPostProcess"
  40078. */
  40079. getClassName(): string;
  40080. protected _updateParameters(): void;
  40081. dispose(camera?: Camera): void;
  40082. }
  40083. }
  40084. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  40085. import { Scene } from "babylonjs/scene";
  40086. import { Color3 } from "babylonjs/Maths/math";
  40087. import { Mesh } from "babylonjs/Meshes/mesh";
  40088. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  40089. /**
  40090. * Class containing static functions to help procedurally build meshes
  40091. */
  40092. export class GroundBuilder {
  40093. /**
  40094. * Creates a ground mesh
  40095. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40096. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40097. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40098. * @param name defines the name of the mesh
  40099. * @param options defines the options used to create the mesh
  40100. * @param scene defines the hosting scene
  40101. * @returns the ground mesh
  40102. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40103. */
  40104. static CreateGround(name: string, options: {
  40105. width?: number;
  40106. height?: number;
  40107. subdivisions?: number;
  40108. subdivisionsX?: number;
  40109. subdivisionsY?: number;
  40110. updatable?: boolean;
  40111. }, scene: any): Mesh;
  40112. /**
  40113. * Creates a tiled ground mesh
  40114. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40115. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40116. * * 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
  40117. * * 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
  40118. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40119. * @param name defines the name of the mesh
  40120. * @param options defines the options used to create the mesh
  40121. * @param scene defines the hosting scene
  40122. * @returns the tiled ground mesh
  40123. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40124. */
  40125. static CreateTiledGround(name: string, options: {
  40126. xmin: number;
  40127. zmin: number;
  40128. xmax: number;
  40129. zmax: number;
  40130. subdivisions?: {
  40131. w: number;
  40132. h: number;
  40133. };
  40134. precision?: {
  40135. w: number;
  40136. h: number;
  40137. };
  40138. updatable?: boolean;
  40139. }, scene: Scene): Mesh;
  40140. /**
  40141. * Creates a ground mesh from a height map
  40142. * * The parameter `url` sets the URL of the height map image resource.
  40143. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40144. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40145. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40146. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40147. * * 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.
  40148. * * 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).
  40149. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40150. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40151. * @param name defines the name of the mesh
  40152. * @param url defines the url to the height map
  40153. * @param options defines the options used to create the mesh
  40154. * @param scene defines the hosting scene
  40155. * @returns the ground mesh
  40156. * @see https://doc.babylonjs.com/babylon101/height_map
  40157. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40158. */
  40159. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40160. width?: number;
  40161. height?: number;
  40162. subdivisions?: number;
  40163. minHeight?: number;
  40164. maxHeight?: number;
  40165. colorFilter?: Color3;
  40166. alphaFilter?: number;
  40167. updatable?: boolean;
  40168. onReady?: (mesh: GroundMesh) => void;
  40169. }, scene: Scene): GroundMesh;
  40170. }
  40171. }
  40172. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  40173. import { Vector4 } from "babylonjs/Maths/math";
  40174. import { Mesh } from "babylonjs/Meshes/mesh";
  40175. /**
  40176. * Class containing static functions to help procedurally build meshes
  40177. */
  40178. export class TorusBuilder {
  40179. /**
  40180. * Creates a torus mesh
  40181. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40182. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40183. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40184. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40185. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40186. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40187. * @param name defines the name of the mesh
  40188. * @param options defines the options used to create the mesh
  40189. * @param scene defines the hosting scene
  40190. * @returns the torus mesh
  40191. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40192. */
  40193. static CreateTorus(name: string, options: {
  40194. diameter?: number;
  40195. thickness?: number;
  40196. tessellation?: number;
  40197. updatable?: boolean;
  40198. sideOrientation?: number;
  40199. frontUVs?: Vector4;
  40200. backUVs?: Vector4;
  40201. }, scene: any): Mesh;
  40202. }
  40203. }
  40204. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  40205. import { Color4, Vector4 } from "babylonjs/Maths/math";
  40206. import { Mesh } from "babylonjs/Meshes/mesh";
  40207. /**
  40208. * Class containing static functions to help procedurally build meshes
  40209. */
  40210. export class CylinderBuilder {
  40211. /**
  40212. * Creates a cylinder or a cone mesh
  40213. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40214. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40215. * * 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.
  40216. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40217. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40218. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40219. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40220. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40221. * * 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).
  40222. * * 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
  40223. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40224. * * 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
  40225. * * 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.
  40226. * * If `enclose` is false, a ring surface is one element.
  40227. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40228. * * 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
  40229. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40230. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40231. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40232. * @param name defines the name of the mesh
  40233. * @param options defines the options used to create the mesh
  40234. * @param scene defines the hosting scene
  40235. * @returns the cylinder mesh
  40236. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40237. */
  40238. static CreateCylinder(name: string, options: {
  40239. height?: number;
  40240. diameterTop?: number;
  40241. diameterBottom?: number;
  40242. diameter?: number;
  40243. tessellation?: number;
  40244. subdivisions?: number;
  40245. arc?: number;
  40246. faceColors?: Color4[];
  40247. faceUV?: Vector4[];
  40248. updatable?: boolean;
  40249. hasRings?: boolean;
  40250. enclose?: boolean;
  40251. sideOrientation?: number;
  40252. frontUVs?: Vector4;
  40253. backUVs?: Vector4;
  40254. }, scene: any): Mesh;
  40255. }
  40256. }
  40257. declare module "babylonjs/Gamepads/gamepadManager" {
  40258. import { Observable } from "babylonjs/Misc/observable";
  40259. import { Nullable } from "babylonjs/types";
  40260. import { Scene } from "babylonjs/scene";
  40261. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40262. /**
  40263. * Manager for handling gamepads
  40264. */
  40265. export class GamepadManager {
  40266. private _scene?;
  40267. private _babylonGamepads;
  40268. private _oneGamepadConnected;
  40269. /** @hidden */
  40270. _isMonitoring: boolean;
  40271. private _gamepadEventSupported;
  40272. private _gamepadSupport;
  40273. /**
  40274. * observable to be triggered when the gamepad controller has been connected
  40275. */
  40276. onGamepadConnectedObservable: Observable<Gamepad>;
  40277. /**
  40278. * observable to be triggered when the gamepad controller has been disconnected
  40279. */
  40280. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40281. private _onGamepadConnectedEvent;
  40282. private _onGamepadDisconnectedEvent;
  40283. /**
  40284. * Initializes the gamepad manager
  40285. * @param _scene BabylonJS scene
  40286. */
  40287. constructor(_scene?: Scene | undefined);
  40288. /**
  40289. * The gamepads in the game pad manager
  40290. */
  40291. readonly gamepads: Gamepad[];
  40292. /**
  40293. * Get the gamepad controllers based on type
  40294. * @param type The type of gamepad controller
  40295. * @returns Nullable gamepad
  40296. */
  40297. getGamepadByType(type?: number): Nullable<Gamepad>;
  40298. /**
  40299. * Disposes the gamepad manager
  40300. */
  40301. dispose(): void;
  40302. private _addNewGamepad;
  40303. private _startMonitoringGamepads;
  40304. private _stopMonitoringGamepads;
  40305. /** @hidden */
  40306. _checkGamepadsStatus(): void;
  40307. private _updateGamepadObjects;
  40308. }
  40309. }
  40310. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40311. import { Nullable } from "babylonjs/types";
  40312. import { Scene } from "babylonjs/scene";
  40313. import { ISceneComponent } from "babylonjs/sceneComponent";
  40314. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40315. module "babylonjs/scene" {
  40316. interface Scene {
  40317. /** @hidden */
  40318. _gamepadManager: Nullable<GamepadManager>;
  40319. /**
  40320. * Gets the gamepad manager associated with the scene
  40321. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40322. */
  40323. gamepadManager: GamepadManager;
  40324. }
  40325. }
  40326. module "babylonjs/Cameras/freeCameraInputsManager" {
  40327. /**
  40328. * Interface representing a free camera inputs manager
  40329. */
  40330. interface FreeCameraInputsManager {
  40331. /**
  40332. * Adds gamepad input support to the FreeCameraInputsManager.
  40333. * @returns the FreeCameraInputsManager
  40334. */
  40335. addGamepad(): FreeCameraInputsManager;
  40336. }
  40337. }
  40338. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40339. /**
  40340. * Interface representing an arc rotate camera inputs manager
  40341. */
  40342. interface ArcRotateCameraInputsManager {
  40343. /**
  40344. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40345. * @returns the camera inputs manager
  40346. */
  40347. addGamepad(): ArcRotateCameraInputsManager;
  40348. }
  40349. }
  40350. /**
  40351. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40352. */
  40353. export class GamepadSystemSceneComponent implements ISceneComponent {
  40354. /**
  40355. * The component name helpfull to identify the component in the list of scene components.
  40356. */
  40357. readonly name: string;
  40358. /**
  40359. * The scene the component belongs to.
  40360. */
  40361. scene: Scene;
  40362. /**
  40363. * Creates a new instance of the component for the given scene
  40364. * @param scene Defines the scene to register the component in
  40365. */
  40366. constructor(scene: Scene);
  40367. /**
  40368. * Registers the component in a given scene
  40369. */
  40370. register(): void;
  40371. /**
  40372. * Rebuilds the elements related to this component in case of
  40373. * context lost for instance.
  40374. */
  40375. rebuild(): void;
  40376. /**
  40377. * Disposes the component and the associated ressources
  40378. */
  40379. dispose(): void;
  40380. private _beforeCameraUpdate;
  40381. }
  40382. }
  40383. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  40384. import { Observable } from "babylonjs/Misc/observable";
  40385. import { Nullable } from "babylonjs/types";
  40386. import { Camera } from "babylonjs/Cameras/camera";
  40387. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40388. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40389. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  40390. import { Scene } from "babylonjs/scene";
  40391. import { Vector3, Color3 } from "babylonjs/Maths/math";
  40392. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  40393. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40394. import { Mesh } from "babylonjs/Meshes/mesh";
  40395. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40396. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40397. import "babylonjs/Meshes/Builders/groundBuilder";
  40398. import "babylonjs/Meshes/Builders/torusBuilder";
  40399. import "babylonjs/Meshes/Builders/cylinderBuilder";
  40400. import "babylonjs/Gamepads/gamepadSceneComponent";
  40401. import "babylonjs/Animations/animatable";
  40402. /**
  40403. * Options to modify the vr teleportation behavior.
  40404. */
  40405. export interface VRTeleportationOptions {
  40406. /**
  40407. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40408. */
  40409. floorMeshName?: string;
  40410. /**
  40411. * A list of meshes to be used as the teleportation floor. (default: empty)
  40412. */
  40413. floorMeshes?: Mesh[];
  40414. }
  40415. /**
  40416. * Options to modify the vr experience helper's behavior.
  40417. */
  40418. export interface VRExperienceHelperOptions extends WebVROptions {
  40419. /**
  40420. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40421. */
  40422. createDeviceOrientationCamera?: boolean;
  40423. /**
  40424. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40425. */
  40426. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40427. /**
  40428. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40429. */
  40430. laserToggle?: boolean;
  40431. /**
  40432. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40433. */
  40434. floorMeshes?: Mesh[];
  40435. /**
  40436. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40437. */
  40438. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40439. }
  40440. /**
  40441. * Event containing information after VR has been entered
  40442. */
  40443. export class OnAfterEnteringVRObservableEvent {
  40444. /**
  40445. * If entering vr was successful
  40446. */
  40447. success: boolean;
  40448. }
  40449. /**
  40450. * Helps to quickly add VR support to an existing scene.
  40451. * See http://doc.babylonjs.com/how_to/webvr_helper
  40452. */
  40453. export class VRExperienceHelper {
  40454. /** Options to modify the vr experience helper's behavior. */
  40455. webVROptions: VRExperienceHelperOptions;
  40456. private _scene;
  40457. private _position;
  40458. private _btnVR;
  40459. private _btnVRDisplayed;
  40460. private _webVRsupported;
  40461. private _webVRready;
  40462. private _webVRrequesting;
  40463. private _webVRpresenting;
  40464. private _hasEnteredVR;
  40465. private _fullscreenVRpresenting;
  40466. private _canvas;
  40467. private _webVRCamera;
  40468. private _vrDeviceOrientationCamera;
  40469. private _deviceOrientationCamera;
  40470. private _existingCamera;
  40471. private _onKeyDown;
  40472. private _onVrDisplayPresentChange;
  40473. private _onVRDisplayChanged;
  40474. private _onVRRequestPresentStart;
  40475. private _onVRRequestPresentComplete;
  40476. /**
  40477. * Observable raised right before entering VR.
  40478. */
  40479. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40480. /**
  40481. * Observable raised when entering VR has completed.
  40482. */
  40483. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40484. /**
  40485. * Observable raised when exiting VR.
  40486. */
  40487. onExitingVRObservable: Observable<VRExperienceHelper>;
  40488. /**
  40489. * Observable raised when controller mesh is loaded.
  40490. */
  40491. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40492. /** Return this.onEnteringVRObservable
  40493. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40494. */
  40495. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40496. /** Return this.onExitingVRObservable
  40497. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40498. */
  40499. readonly onExitingVR: Observable<VRExperienceHelper>;
  40500. /** Return this.onControllerMeshLoadedObservable
  40501. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40502. */
  40503. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40504. private _rayLength;
  40505. private _useCustomVRButton;
  40506. private _teleportationRequested;
  40507. private _teleportActive;
  40508. private _floorMeshName;
  40509. private _floorMeshesCollection;
  40510. private _rotationAllowed;
  40511. private _teleportBackwardsVector;
  40512. private _teleportationTarget;
  40513. private _isDefaultTeleportationTarget;
  40514. private _postProcessMove;
  40515. private _teleportationFillColor;
  40516. private _teleportationBorderColor;
  40517. private _rotationAngle;
  40518. private _haloCenter;
  40519. private _cameraGazer;
  40520. private _padSensibilityUp;
  40521. private _padSensibilityDown;
  40522. private _leftController;
  40523. private _rightController;
  40524. /**
  40525. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40526. */
  40527. onNewMeshSelected: Observable<AbstractMesh>;
  40528. /**
  40529. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40530. */
  40531. onNewMeshPicked: Observable<PickingInfo>;
  40532. private _circleEase;
  40533. /**
  40534. * Observable raised before camera teleportation
  40535. */
  40536. onBeforeCameraTeleport: Observable<Vector3>;
  40537. /**
  40538. * Observable raised after camera teleportation
  40539. */
  40540. onAfterCameraTeleport: Observable<Vector3>;
  40541. /**
  40542. * Observable raised when current selected mesh gets unselected
  40543. */
  40544. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40545. private _raySelectionPredicate;
  40546. /**
  40547. * To be optionaly changed by user to define custom ray selection
  40548. */
  40549. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40550. /**
  40551. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40552. */
  40553. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40554. /**
  40555. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40556. */
  40557. teleportationEnabled: boolean;
  40558. private _defaultHeight;
  40559. private _teleportationInitialized;
  40560. private _interactionsEnabled;
  40561. private _interactionsRequested;
  40562. private _displayGaze;
  40563. private _displayLaserPointer;
  40564. /**
  40565. * The mesh used to display where the user is going to teleport.
  40566. */
  40567. /**
  40568. * Sets the mesh to be used to display where the user is going to teleport.
  40569. */
  40570. teleportationTarget: Mesh;
  40571. /**
  40572. * 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
  40573. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40574. * See http://doc.babylonjs.com/resources/baking_transformations
  40575. */
  40576. gazeTrackerMesh: Mesh;
  40577. /**
  40578. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40579. */
  40580. updateGazeTrackerScale: boolean;
  40581. /**
  40582. * If the gaze trackers color should be updated when selecting meshes
  40583. */
  40584. updateGazeTrackerColor: boolean;
  40585. /**
  40586. * The gaze tracking mesh corresponding to the left controller
  40587. */
  40588. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40589. /**
  40590. * The gaze tracking mesh corresponding to the right controller
  40591. */
  40592. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40593. /**
  40594. * If the ray of the gaze should be displayed.
  40595. */
  40596. /**
  40597. * Sets if the ray of the gaze should be displayed.
  40598. */
  40599. displayGaze: boolean;
  40600. /**
  40601. * If the ray of the LaserPointer should be displayed.
  40602. */
  40603. /**
  40604. * Sets if the ray of the LaserPointer should be displayed.
  40605. */
  40606. displayLaserPointer: boolean;
  40607. /**
  40608. * The deviceOrientationCamera used as the camera when not in VR.
  40609. */
  40610. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40611. /**
  40612. * Based on the current WebVR support, returns the current VR camera used.
  40613. */
  40614. readonly currentVRCamera: Nullable<Camera>;
  40615. /**
  40616. * The webVRCamera which is used when in VR.
  40617. */
  40618. readonly webVRCamera: WebVRFreeCamera;
  40619. /**
  40620. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40621. */
  40622. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40623. private readonly _teleportationRequestInitiated;
  40624. /**
  40625. * Defines wether or not Pointer lock should be requested when switching to
  40626. * full screen.
  40627. */
  40628. requestPointerLockOnFullScreen: boolean;
  40629. /**
  40630. * Instantiates a VRExperienceHelper.
  40631. * Helps to quickly add VR support to an existing scene.
  40632. * @param scene The scene the VRExperienceHelper belongs to.
  40633. * @param webVROptions Options to modify the vr experience helper's behavior.
  40634. */
  40635. constructor(scene: Scene,
  40636. /** Options to modify the vr experience helper's behavior. */
  40637. webVROptions?: VRExperienceHelperOptions);
  40638. private _onDefaultMeshLoaded;
  40639. private _onResize;
  40640. private _onFullscreenChange;
  40641. /**
  40642. * Gets a value indicating if we are currently in VR mode.
  40643. */
  40644. readonly isInVRMode: boolean;
  40645. private onVrDisplayPresentChange;
  40646. private onVRDisplayChanged;
  40647. private moveButtonToBottomRight;
  40648. private displayVRButton;
  40649. private updateButtonVisibility;
  40650. private _cachedAngularSensibility;
  40651. /**
  40652. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40653. * Otherwise, will use the fullscreen API.
  40654. */
  40655. enterVR(): void;
  40656. /**
  40657. * Attempt to exit VR, or fullscreen.
  40658. */
  40659. exitVR(): void;
  40660. /**
  40661. * The position of the vr experience helper.
  40662. */
  40663. /**
  40664. * Sets the position of the vr experience helper.
  40665. */
  40666. position: Vector3;
  40667. /**
  40668. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40669. */
  40670. enableInteractions(): void;
  40671. private readonly _noControllerIsActive;
  40672. private beforeRender;
  40673. private _isTeleportationFloor;
  40674. /**
  40675. * Adds a floor mesh to be used for teleportation.
  40676. * @param floorMesh the mesh to be used for teleportation.
  40677. */
  40678. addFloorMesh(floorMesh: Mesh): void;
  40679. /**
  40680. * Removes a floor mesh from being used for teleportation.
  40681. * @param floorMesh the mesh to be removed.
  40682. */
  40683. removeFloorMesh(floorMesh: Mesh): void;
  40684. /**
  40685. * Enables interactions and teleportation using the VR controllers and gaze.
  40686. * @param vrTeleportationOptions options to modify teleportation behavior.
  40687. */
  40688. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40689. private _onNewGamepadConnected;
  40690. private _tryEnableInteractionOnController;
  40691. private _onNewGamepadDisconnected;
  40692. private _enableInteractionOnController;
  40693. private _checkTeleportWithRay;
  40694. private _checkRotate;
  40695. private _checkTeleportBackwards;
  40696. private _enableTeleportationOnController;
  40697. private _createTeleportationCircles;
  40698. private _displayTeleportationTarget;
  40699. private _hideTeleportationTarget;
  40700. private _rotateCamera;
  40701. private _moveTeleportationSelectorTo;
  40702. private _workingVector;
  40703. private _workingQuaternion;
  40704. private _workingMatrix;
  40705. /**
  40706. * Teleports the users feet to the desired location
  40707. * @param location The location where the user's feet should be placed
  40708. */
  40709. teleportCamera(location: Vector3): void;
  40710. private _convertNormalToDirectionOfRay;
  40711. private _castRayAndSelectObject;
  40712. private _notifySelectedMeshUnselected;
  40713. /**
  40714. * Sets the color of the laser ray from the vr controllers.
  40715. * @param color new color for the ray.
  40716. */
  40717. changeLaserColor(color: Color3): void;
  40718. /**
  40719. * Sets the color of the ray from the vr headsets gaze.
  40720. * @param color new color for the ray.
  40721. */
  40722. changeGazeColor(color: Color3): void;
  40723. /**
  40724. * Exits VR and disposes of the vr experience helper
  40725. */
  40726. dispose(): void;
  40727. /**
  40728. * Gets the name of the VRExperienceHelper class
  40729. * @returns "VRExperienceHelper"
  40730. */
  40731. getClassName(): string;
  40732. }
  40733. }
  40734. declare module "babylonjs/Cameras/VR/index" {
  40735. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  40736. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  40737. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40738. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  40739. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  40740. export * from "babylonjs/Cameras/VR/webVRCamera";
  40741. }
  40742. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  40743. import { Observable } from "babylonjs/Misc/observable";
  40744. import { Nullable } from "babylonjs/types";
  40745. import { IDisposable, Scene } from "babylonjs/scene";
  40746. import { Vector3 } from "babylonjs/Maths/math";
  40747. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40748. import { Ray } from "babylonjs/Culling/ray";
  40749. /**
  40750. * Manages an XRSession
  40751. * @see https://doc.babylonjs.com/how_to/webxr
  40752. */
  40753. export class WebXRSessionManager implements IDisposable {
  40754. private scene;
  40755. /**
  40756. * Fires every time a new xrFrame arrives which can be used to update the camera
  40757. */
  40758. onXRFrameObservable: Observable<any>;
  40759. /**
  40760. * Fires when the xr session is ended either by the device or manually done
  40761. */
  40762. onXRSessionEnded: Observable<any>;
  40763. /** @hidden */
  40764. _xrSession: XRSession;
  40765. /** @hidden */
  40766. _frameOfReference: XRFrameOfReference;
  40767. /** @hidden */
  40768. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40769. /** @hidden */
  40770. _currentXRFrame: Nullable<XRFrame>;
  40771. private _xrNavigator;
  40772. private _xrDevice;
  40773. private _tmpMatrix;
  40774. /**
  40775. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40776. * @param scene The scene which the session should be created for
  40777. */
  40778. constructor(scene: Scene);
  40779. /**
  40780. * Initializes the manager
  40781. * After initialization enterXR can be called to start an XR session
  40782. * @returns Promise which resolves after it is initialized
  40783. */
  40784. initializeAsync(): Promise<void>;
  40785. /**
  40786. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  40787. * @param sessionCreationOptions xr options to create the session with
  40788. * @param frameOfReferenceType option to configure how the xr pose is expressed
  40789. * @returns Promise which resolves after it enters XR
  40790. */
  40791. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  40792. /**
  40793. * Stops the xrSession and restores the renderloop
  40794. * @returns Promise which resolves after it exits XR
  40795. */
  40796. exitXRAsync(): Promise<void>;
  40797. /**
  40798. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40799. * @param ray ray to cast into the environment
  40800. * @returns Promise which resolves with a collision point in the environment if it exists
  40801. */
  40802. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40803. /**
  40804. * Checks if a session would be supported for the creation options specified
  40805. * @param options creation options to check if they are supported
  40806. * @returns true if supported
  40807. */
  40808. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40809. /**
  40810. * @hidden
  40811. * Converts the render layer of xrSession to a render target
  40812. * @param session session to create render target for
  40813. * @param scene scene the new render target should be created for
  40814. */
  40815. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  40816. /**
  40817. * Disposes of the session manager
  40818. */
  40819. dispose(): void;
  40820. }
  40821. }
  40822. declare module "babylonjs/Cameras/XR/webXRCamera" {
  40823. import { Scene } from "babylonjs/scene";
  40824. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40825. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40826. /**
  40827. * WebXR Camera which holds the views for the xrSession
  40828. * @see https://doc.babylonjs.com/how_to/webxr
  40829. */
  40830. export class WebXRCamera extends FreeCamera {
  40831. private static _TmpMatrix;
  40832. /**
  40833. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40834. * @param name the name of the camera
  40835. * @param scene the scene to add the camera to
  40836. */
  40837. constructor(name: string, scene: Scene);
  40838. private _updateNumberOfRigCameras;
  40839. /** @hidden */
  40840. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40841. /**
  40842. * Updates the cameras position from the current pose information of the XR session
  40843. * @param xrSessionManager the session containing pose information
  40844. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40845. */
  40846. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40847. }
  40848. }
  40849. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  40850. import { Nullable } from "babylonjs/types";
  40851. import { Observable } from "babylonjs/Misc/observable";
  40852. import { IDisposable, Scene } from "babylonjs/scene";
  40853. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  40854. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40855. import { Ray } from "babylonjs/Culling/ray";
  40856. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40857. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  40858. /**
  40859. * States of the webXR experience
  40860. */
  40861. export enum WebXRState {
  40862. /**
  40863. * Transitioning to being in XR mode
  40864. */
  40865. ENTERING_XR = 0,
  40866. /**
  40867. * Transitioning to non XR mode
  40868. */
  40869. EXITING_XR = 1,
  40870. /**
  40871. * In XR mode and presenting
  40872. */
  40873. IN_XR = 2,
  40874. /**
  40875. * Not entered XR mode
  40876. */
  40877. NOT_IN_XR = 3
  40878. }
  40879. /**
  40880. * Helper class used to enable XR
  40881. * @see https://doc.babylonjs.com/how_to/webxr
  40882. */
  40883. export class WebXRExperienceHelper implements IDisposable {
  40884. private scene;
  40885. /**
  40886. * 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
  40887. */
  40888. container: AbstractMesh;
  40889. /**
  40890. * Camera used to render xr content
  40891. */
  40892. camera: WebXRCamera;
  40893. /**
  40894. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40895. */
  40896. state: WebXRState;
  40897. private _setState;
  40898. private static _TmpVector;
  40899. /**
  40900. * Fires when the state of the experience helper has changed
  40901. */
  40902. onStateChangedObservable: Observable<WebXRState>;
  40903. /** @hidden */
  40904. _sessionManager: WebXRSessionManager;
  40905. private _nonVRCamera;
  40906. private _originalSceneAutoClear;
  40907. private _supported;
  40908. /**
  40909. * Creates the experience helper
  40910. * @param scene the scene to attach the experience helper to
  40911. * @returns a promise for the experience helper
  40912. */
  40913. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40914. /**
  40915. * Creates a WebXRExperienceHelper
  40916. * @param scene The scene the helper should be created in
  40917. */
  40918. private constructor();
  40919. /**
  40920. * Exits XR mode and returns the scene to its original state
  40921. * @returns promise that resolves after xr mode has exited
  40922. */
  40923. exitXRAsync(): Promise<void>;
  40924. /**
  40925. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40926. * @param sessionCreationOptions options for the XR session
  40927. * @param frameOfReference frame of reference of the XR session
  40928. * @returns promise that resolves after xr mode has entered
  40929. */
  40930. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40931. /**
  40932. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40933. * @param ray ray to cast into the environment
  40934. * @returns Promise which resolves with a collision point in the environment if it exists
  40935. */
  40936. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40937. /**
  40938. * Updates the global position of the camera by moving the camera's container
  40939. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40940. * @param position The desired global position of the camera
  40941. */
  40942. setPositionOfCameraUsingContainer(position: Vector3): void;
  40943. /**
  40944. * Rotates the xr camera by rotating the camera's container around the camera's position
  40945. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40946. * @param rotation the desired quaternion rotation to apply to the camera
  40947. */
  40948. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40949. /**
  40950. * Checks if the creation options are supported by the xr session
  40951. * @param options creation options
  40952. * @returns true if supported
  40953. */
  40954. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40955. /**
  40956. * Disposes of the experience helper
  40957. */
  40958. dispose(): void;
  40959. }
  40960. }
  40961. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  40962. import { Nullable } from "babylonjs/types";
  40963. import { Observable } from "babylonjs/Misc/observable";
  40964. import { IDisposable, Scene } from "babylonjs/scene";
  40965. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40966. /**
  40967. * Button which can be used to enter a different mode of XR
  40968. */
  40969. export class WebXREnterExitUIButton {
  40970. /** button element */
  40971. element: HTMLElement;
  40972. /** XR initialization options for the button */
  40973. initializationOptions: XRSessionCreationOptions;
  40974. /**
  40975. * Creates a WebXREnterExitUIButton
  40976. * @param element button element
  40977. * @param initializationOptions XR initialization options for the button
  40978. */
  40979. constructor(
  40980. /** button element */
  40981. element: HTMLElement,
  40982. /** XR initialization options for the button */
  40983. initializationOptions: XRSessionCreationOptions);
  40984. /**
  40985. * Overwritable function which can be used to update the button's visuals when the state changes
  40986. * @param activeButton the current active button in the UI
  40987. */
  40988. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40989. }
  40990. /**
  40991. * Options to create the webXR UI
  40992. */
  40993. export class WebXREnterExitUIOptions {
  40994. /**
  40995. * Context to enter xr with
  40996. */
  40997. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40998. /**
  40999. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41000. */
  41001. customButtons?: Array<WebXREnterExitUIButton>;
  41002. }
  41003. /**
  41004. * UI to allow the user to enter/exit XR mode
  41005. */
  41006. export class WebXREnterExitUI implements IDisposable {
  41007. private scene;
  41008. private _overlay;
  41009. private _buttons;
  41010. private _activeButton;
  41011. /**
  41012. * Fired every time the active button is changed.
  41013. *
  41014. * When xr is entered via a button that launches xr that button will be the callback parameter
  41015. *
  41016. * When exiting xr the callback parameter will be null)
  41017. */
  41018. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41019. /**
  41020. * Creates UI to allow the user to enter/exit XR mode
  41021. * @param scene the scene to add the ui to
  41022. * @param helper the xr experience helper to enter/exit xr with
  41023. * @param options options to configure the UI
  41024. * @returns the created ui
  41025. */
  41026. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41027. private constructor();
  41028. private _updateButtons;
  41029. /**
  41030. * Disposes of the object
  41031. */
  41032. dispose(): void;
  41033. }
  41034. }
  41035. declare module "babylonjs/Cameras/XR/webXRInput" {
  41036. import { IDisposable, Scene } from "babylonjs/scene";
  41037. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41038. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41039. /**
  41040. * Represents an XR input
  41041. */
  41042. export class WebXRController {
  41043. /**
  41044. * 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
  41045. */
  41046. grip?: AbstractMesh;
  41047. /**
  41048. * Pointer which can be used to select objects or attach a visible laser to
  41049. */
  41050. pointer: AbstractMesh;
  41051. /**
  41052. * Creates the controller
  41053. * @see https://doc.babylonjs.com/how_to/webxr
  41054. * @param scene the scene which the controller should be associated to
  41055. */
  41056. constructor(scene: Scene);
  41057. /**
  41058. * Disposes of the object
  41059. */
  41060. dispose(): void;
  41061. }
  41062. /**
  41063. * XR input used to track XR inputs such as controllers/rays
  41064. */
  41065. export class WebXRInput implements IDisposable {
  41066. private helper;
  41067. /**
  41068. * XR controllers being tracked
  41069. */
  41070. controllers: Array<WebXRController>;
  41071. private _tmpMatrix;
  41072. private _frameObserver;
  41073. /**
  41074. * Initializes the WebXRInput
  41075. * @param helper experience helper which the input should be created for
  41076. */
  41077. constructor(helper: WebXRExperienceHelper);
  41078. /**
  41079. * Disposes of the object
  41080. */
  41081. dispose(): void;
  41082. }
  41083. }
  41084. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  41085. import { Nullable } from "babylonjs/types";
  41086. import { IDisposable } from "babylonjs/scene";
  41087. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41088. /**
  41089. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41090. */
  41091. export class WebXRManagedOutputCanvas implements IDisposable {
  41092. private _canvas;
  41093. /**
  41094. * xrpresent context of the canvas which can be used to display/mirror xr content
  41095. */
  41096. canvasContext: Nullable<WebGLRenderingContext>;
  41097. /**
  41098. * Initializes the canvas to be added/removed upon entering/exiting xr
  41099. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41100. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41101. */
  41102. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41103. /**
  41104. * Disposes of the object
  41105. */
  41106. dispose(): void;
  41107. private _setManagedOutputCanvas;
  41108. private _addCanvas;
  41109. private _removeCanvas;
  41110. }
  41111. }
  41112. declare module "babylonjs/Cameras/XR/index" {
  41113. export * from "babylonjs/Cameras/XR/webXRCamera";
  41114. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  41115. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41116. export * from "babylonjs/Cameras/XR/webXRInput";
  41117. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  41118. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  41119. }
  41120. declare module "babylonjs/Cameras/RigModes/index" {
  41121. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41122. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41123. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  41124. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  41125. }
  41126. declare module "babylonjs/Cameras/index" {
  41127. export * from "babylonjs/Cameras/Inputs/index";
  41128. export * from "babylonjs/Cameras/cameraInputsManager";
  41129. export * from "babylonjs/Cameras/camera";
  41130. export * from "babylonjs/Cameras/targetCamera";
  41131. export * from "babylonjs/Cameras/freeCamera";
  41132. export * from "babylonjs/Cameras/freeCameraInputsManager";
  41133. export * from "babylonjs/Cameras/touchCamera";
  41134. export * from "babylonjs/Cameras/arcRotateCamera";
  41135. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  41136. export * from "babylonjs/Cameras/deviceOrientationCamera";
  41137. export * from "babylonjs/Cameras/flyCamera";
  41138. export * from "babylonjs/Cameras/flyCameraInputsManager";
  41139. export * from "babylonjs/Cameras/followCamera";
  41140. export * from "babylonjs/Cameras/gamepadCamera";
  41141. export * from "babylonjs/Cameras/Stereoscopic/index";
  41142. export * from "babylonjs/Cameras/universalCamera";
  41143. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  41144. export * from "babylonjs/Cameras/VR/index";
  41145. export * from "babylonjs/Cameras/XR/index";
  41146. export * from "babylonjs/Cameras/RigModes/index";
  41147. }
  41148. declare module "babylonjs/Collisions/index" {
  41149. export * from "babylonjs/Collisions/collider";
  41150. export * from "babylonjs/Collisions/collisionCoordinator";
  41151. export * from "babylonjs/Collisions/pickingInfo";
  41152. export * from "babylonjs/Collisions/intersectionInfo";
  41153. }
  41154. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  41155. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  41156. import { Vector3, Plane } from "babylonjs/Maths/math";
  41157. import { Ray } from "babylonjs/Culling/ray";
  41158. /**
  41159. * Contains an array of blocks representing the octree
  41160. */
  41161. export interface IOctreeContainer<T> {
  41162. /**
  41163. * Blocks within the octree
  41164. */
  41165. blocks: Array<OctreeBlock<T>>;
  41166. }
  41167. /**
  41168. * Class used to store a cell in an octree
  41169. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41170. */
  41171. export class OctreeBlock<T> {
  41172. /**
  41173. * Gets the content of the current block
  41174. */
  41175. entries: T[];
  41176. /**
  41177. * Gets the list of block children
  41178. */
  41179. blocks: Array<OctreeBlock<T>>;
  41180. private _depth;
  41181. private _maxDepth;
  41182. private _capacity;
  41183. private _minPoint;
  41184. private _maxPoint;
  41185. private _boundingVectors;
  41186. private _creationFunc;
  41187. /**
  41188. * Creates a new block
  41189. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41190. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41191. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41192. * @param depth defines the current depth of this block in the octree
  41193. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41194. * @param creationFunc defines a callback to call when an element is added to the block
  41195. */
  41196. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41197. /**
  41198. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41199. */
  41200. readonly capacity: number;
  41201. /**
  41202. * Gets the minimum vector (in world space) of the block's bounding box
  41203. */
  41204. readonly minPoint: Vector3;
  41205. /**
  41206. * Gets the maximum vector (in world space) of the block's bounding box
  41207. */
  41208. readonly maxPoint: Vector3;
  41209. /**
  41210. * Add a new element to this block
  41211. * @param entry defines the element to add
  41212. */
  41213. addEntry(entry: T): void;
  41214. /**
  41215. * Remove an element from this block
  41216. * @param entry defines the element to remove
  41217. */
  41218. removeEntry(entry: T): void;
  41219. /**
  41220. * Add an array of elements to this block
  41221. * @param entries defines the array of elements to add
  41222. */
  41223. addEntries(entries: T[]): void;
  41224. /**
  41225. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41226. * @param frustumPlanes defines the frustum planes to test
  41227. * @param selection defines the array to store current content if selection is positive
  41228. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41229. */
  41230. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41231. /**
  41232. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41233. * @param sphereCenter defines the bounding sphere center
  41234. * @param sphereRadius defines the bounding sphere radius
  41235. * @param selection defines the array to store current content if selection is positive
  41236. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41237. */
  41238. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41239. /**
  41240. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41241. * @param ray defines the ray to test with
  41242. * @param selection defines the array to store current content if selection is positive
  41243. */
  41244. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41245. /**
  41246. * Subdivide the content into child blocks (this block will then be empty)
  41247. */
  41248. createInnerBlocks(): void;
  41249. /**
  41250. * @hidden
  41251. */
  41252. 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;
  41253. }
  41254. }
  41255. declare module "babylonjs/Culling/Octrees/octree" {
  41256. import { SmartArray } from "babylonjs/Misc/smartArray";
  41257. import { Vector3, Plane } from "babylonjs/Maths/math";
  41258. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41259. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41260. import { Ray } from "babylonjs/Culling/ray";
  41261. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  41262. /**
  41263. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41264. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41265. */
  41266. export class Octree<T> {
  41267. /** 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.) */
  41268. maxDepth: number;
  41269. /**
  41270. * Blocks within the octree containing objects
  41271. */
  41272. blocks: Array<OctreeBlock<T>>;
  41273. /**
  41274. * Content stored in the octree
  41275. */
  41276. dynamicContent: T[];
  41277. private _maxBlockCapacity;
  41278. private _selectionContent;
  41279. private _creationFunc;
  41280. /**
  41281. * Creates a octree
  41282. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41283. * @param creationFunc function to be used to instatiate the octree
  41284. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41285. * @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.)
  41286. */
  41287. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41288. /** 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.) */
  41289. maxDepth?: number);
  41290. /**
  41291. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41292. * @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);
  41293. * @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);
  41294. * @param entries meshes to be added to the octree blocks
  41295. */
  41296. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41297. /**
  41298. * Adds a mesh to the octree
  41299. * @param entry Mesh to add to the octree
  41300. */
  41301. addMesh(entry: T): void;
  41302. /**
  41303. * Remove an element from the octree
  41304. * @param entry defines the element to remove
  41305. */
  41306. removeMesh(entry: T): void;
  41307. /**
  41308. * Selects an array of meshes within the frustum
  41309. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41310. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41311. * @returns array of meshes within the frustum
  41312. */
  41313. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41314. /**
  41315. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41316. * @param sphereCenter defines the bounding sphere center
  41317. * @param sphereRadius defines the bounding sphere radius
  41318. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41319. * @returns an array of objects that intersect the sphere
  41320. */
  41321. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41322. /**
  41323. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41324. * @param ray defines the ray to test with
  41325. * @returns array of intersected objects
  41326. */
  41327. intersectsRay(ray: Ray): SmartArray<T>;
  41328. /**
  41329. * Adds a mesh into the octree block if it intersects the block
  41330. */
  41331. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41332. /**
  41333. * Adds a submesh into the octree block if it intersects the block
  41334. */
  41335. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41336. }
  41337. }
  41338. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  41339. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  41340. import { Scene } from "babylonjs/scene";
  41341. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41342. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41343. import { Ray } from "babylonjs/Culling/ray";
  41344. import { Octree } from "babylonjs/Culling/Octrees/octree";
  41345. import { Collider } from "babylonjs/Collisions/collider";
  41346. module "babylonjs/scene" {
  41347. interface Scene {
  41348. /**
  41349. * @hidden
  41350. * Backing Filed
  41351. */
  41352. _selectionOctree: Octree<AbstractMesh>;
  41353. /**
  41354. * Gets the octree used to boost mesh selection (picking)
  41355. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41356. */
  41357. selectionOctree: Octree<AbstractMesh>;
  41358. /**
  41359. * Creates or updates the octree used to boost selection (picking)
  41360. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41361. * @param maxCapacity defines the maximum capacity per leaf
  41362. * @param maxDepth defines the maximum depth of the octree
  41363. * @returns an octree of AbstractMesh
  41364. */
  41365. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41366. }
  41367. }
  41368. module "babylonjs/Meshes/abstractMesh" {
  41369. interface AbstractMesh {
  41370. /**
  41371. * @hidden
  41372. * Backing Field
  41373. */
  41374. _submeshesOctree: Octree<SubMesh>;
  41375. /**
  41376. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41377. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41378. * @param maxCapacity defines the maximum size of each block (64 by default)
  41379. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41380. * @returns the new octree
  41381. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41382. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41383. */
  41384. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41385. }
  41386. }
  41387. /**
  41388. * Defines the octree scene component responsible to manage any octrees
  41389. * in a given scene.
  41390. */
  41391. export class OctreeSceneComponent {
  41392. /**
  41393. * The component name helpfull to identify the component in the list of scene components.
  41394. */
  41395. readonly name: string;
  41396. /**
  41397. * The scene the component belongs to.
  41398. */
  41399. scene: Scene;
  41400. /**
  41401. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41402. */
  41403. readonly checksIsEnabled: boolean;
  41404. /**
  41405. * Creates a new instance of the component for the given scene
  41406. * @param scene Defines the scene to register the component in
  41407. */
  41408. constructor(scene: Scene);
  41409. /**
  41410. * Registers the component in a given scene
  41411. */
  41412. register(): void;
  41413. /**
  41414. * Return the list of active meshes
  41415. * @returns the list of active meshes
  41416. */
  41417. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41418. /**
  41419. * Return the list of active sub meshes
  41420. * @param mesh The mesh to get the candidates sub meshes from
  41421. * @returns the list of active sub meshes
  41422. */
  41423. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41424. private _tempRay;
  41425. /**
  41426. * Return the list of sub meshes intersecting with a given local ray
  41427. * @param mesh defines the mesh to find the submesh for
  41428. * @param localRay defines the ray in local space
  41429. * @returns the list of intersecting sub meshes
  41430. */
  41431. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41432. /**
  41433. * Return the list of sub meshes colliding with a collider
  41434. * @param mesh defines the mesh to find the submesh for
  41435. * @param collider defines the collider to evaluate the collision against
  41436. * @returns the list of colliding sub meshes
  41437. */
  41438. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41439. /**
  41440. * Rebuilds the elements related to this component in case of
  41441. * context lost for instance.
  41442. */
  41443. rebuild(): void;
  41444. /**
  41445. * Disposes the component and the associated ressources.
  41446. */
  41447. dispose(): void;
  41448. }
  41449. }
  41450. declare module "babylonjs/Culling/Octrees/index" {
  41451. export * from "babylonjs/Culling/Octrees/octree";
  41452. export * from "babylonjs/Culling/Octrees/octreeBlock";
  41453. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  41454. }
  41455. declare module "babylonjs/Culling/index" {
  41456. export * from "babylonjs/Culling/boundingBox";
  41457. export * from "babylonjs/Culling/boundingInfo";
  41458. export * from "babylonjs/Culling/boundingSphere";
  41459. export * from "babylonjs/Culling/Octrees/index";
  41460. export * from "babylonjs/Culling/ray";
  41461. }
  41462. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  41463. import { Vector3, Color4 } from "babylonjs/Maths/math";
  41464. import { Nullable } from "babylonjs/types";
  41465. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  41466. import { Scene } from "babylonjs/scene";
  41467. /**
  41468. * Class containing static functions to help procedurally build meshes
  41469. */
  41470. export class LinesBuilder {
  41471. /**
  41472. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  41473. * * 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
  41474. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  41475. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  41476. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  41477. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  41478. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  41479. * * 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
  41480. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  41481. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41482. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  41483. * @param name defines the name of the new line system
  41484. * @param options defines the options used to create the line system
  41485. * @param scene defines the hosting scene
  41486. * @returns a new line system mesh
  41487. */
  41488. static CreateLineSystem(name: string, options: {
  41489. lines: Vector3[][];
  41490. updatable?: boolean;
  41491. instance?: Nullable<LinesMesh>;
  41492. colors?: Nullable<Color4[][]>;
  41493. useVertexAlpha?: boolean;
  41494. }, scene: Nullable<Scene>): LinesMesh;
  41495. /**
  41496. * Creates a line mesh
  41497. * 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
  41498. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41499. * * The parameter `points` is an array successive Vector3
  41500. * * 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
  41501. * * The optional parameter `colors` is an array of successive Color4, one per line point
  41502. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  41503. * * When updating an instance, remember that only point positions can change, not the number of points
  41504. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41505. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  41506. * @param name defines the name of the new line system
  41507. * @param options defines the options used to create the line system
  41508. * @param scene defines the hosting scene
  41509. * @returns a new line mesh
  41510. */
  41511. static CreateLines(name: string, options: {
  41512. points: Vector3[];
  41513. updatable?: boolean;
  41514. instance?: Nullable<LinesMesh>;
  41515. colors?: Color4[];
  41516. useVertexAlpha?: boolean;
  41517. }, scene?: Nullable<Scene>): LinesMesh;
  41518. /**
  41519. * Creates a dashed line mesh
  41520. * * 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
  41521. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41522. * * The parameter `points` is an array successive Vector3
  41523. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  41524. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  41525. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  41526. * * 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
  41527. * * When updating an instance, remember that only point positions can change, not the number of points
  41528. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41529. * @param name defines the name of the mesh
  41530. * @param options defines the options used to create the mesh
  41531. * @param scene defines the hosting scene
  41532. * @returns the dashed line mesh
  41533. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  41534. */
  41535. static CreateDashedLines(name: string, options: {
  41536. points: Vector3[];
  41537. dashSize?: number;
  41538. gapSize?: number;
  41539. dashNb?: number;
  41540. updatable?: boolean;
  41541. instance?: LinesMesh;
  41542. }, scene?: Nullable<Scene>): LinesMesh;
  41543. }
  41544. }
  41545. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  41546. import { IDisposable, Scene } from "babylonjs/scene";
  41547. import { Nullable } from "babylonjs/types";
  41548. import { Observable } from "babylonjs/Misc/observable";
  41549. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41550. /**
  41551. * Renders a layer on top of an existing scene
  41552. */
  41553. export class UtilityLayerRenderer implements IDisposable {
  41554. /** the original scene that will be rendered on top of */
  41555. originalScene: Scene;
  41556. private _pointerCaptures;
  41557. private _lastPointerEvents;
  41558. private static _DefaultUtilityLayer;
  41559. private static _DefaultKeepDepthUtilityLayer;
  41560. /**
  41561. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41562. */
  41563. pickUtilitySceneFirst: boolean;
  41564. /**
  41565. * 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)
  41566. */
  41567. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41568. /**
  41569. * 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)
  41570. */
  41571. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41572. /**
  41573. * The scene that is rendered on top of the original scene
  41574. */
  41575. utilityLayerScene: Scene;
  41576. /**
  41577. * If the utility layer should automatically be rendered on top of existing scene
  41578. */
  41579. shouldRender: boolean;
  41580. /**
  41581. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41582. */
  41583. onlyCheckPointerDownEvents: boolean;
  41584. /**
  41585. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41586. */
  41587. processAllEvents: boolean;
  41588. /**
  41589. * Observable raised when the pointer move from the utility layer scene to the main scene
  41590. */
  41591. onPointerOutObservable: Observable<number>;
  41592. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41593. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41594. private _afterRenderObserver;
  41595. private _sceneDisposeObserver;
  41596. private _originalPointerObserver;
  41597. /**
  41598. * Instantiates a UtilityLayerRenderer
  41599. * @param originalScene the original scene that will be rendered on top of
  41600. * @param handleEvents boolean indicating if the utility layer should handle events
  41601. */
  41602. constructor(
  41603. /** the original scene that will be rendered on top of */
  41604. originalScene: Scene, handleEvents?: boolean);
  41605. private _notifyObservers;
  41606. /**
  41607. * Renders the utility layers scene on top of the original scene
  41608. */
  41609. render(): void;
  41610. /**
  41611. * Disposes of the renderer
  41612. */
  41613. dispose(): void;
  41614. private _updateCamera;
  41615. }
  41616. }
  41617. declare module "babylonjs/Gizmos/gizmo" {
  41618. import { Nullable } from "babylonjs/types";
  41619. import { IDisposable } from "babylonjs/scene";
  41620. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41621. import { Mesh } from "babylonjs/Meshes/mesh";
  41622. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41623. /**
  41624. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41625. */
  41626. export class Gizmo implements IDisposable {
  41627. /** The utility layer the gizmo will be added to */
  41628. gizmoLayer: UtilityLayerRenderer;
  41629. /**
  41630. * The root mesh of the gizmo
  41631. */
  41632. _rootMesh: Mesh;
  41633. private _attachedMesh;
  41634. /**
  41635. * Ratio for the scale of the gizmo (Default: 1)
  41636. */
  41637. scaleRatio: number;
  41638. private _tmpMatrix;
  41639. /**
  41640. * If a custom mesh has been set (Default: false)
  41641. */
  41642. protected _customMeshSet: boolean;
  41643. /**
  41644. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41645. * * When set, interactions will be enabled
  41646. */
  41647. attachedMesh: Nullable<AbstractMesh>;
  41648. /**
  41649. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41650. * @param mesh The mesh to replace the default mesh of the gizmo
  41651. */
  41652. setCustomMesh(mesh: Mesh): void;
  41653. /**
  41654. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41655. */
  41656. updateGizmoRotationToMatchAttachedMesh: boolean;
  41657. /**
  41658. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41659. */
  41660. updateGizmoPositionToMatchAttachedMesh: boolean;
  41661. /**
  41662. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  41663. */
  41664. protected _updateScale: boolean;
  41665. protected _interactionsEnabled: boolean;
  41666. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41667. private _beforeRenderObserver;
  41668. /**
  41669. * Creates a gizmo
  41670. * @param gizmoLayer The utility layer the gizmo will be added to
  41671. */
  41672. constructor(
  41673. /** The utility layer the gizmo will be added to */
  41674. gizmoLayer?: UtilityLayerRenderer);
  41675. private _tempVector;
  41676. /**
  41677. * @hidden
  41678. * Updates the gizmo to match the attached mesh's position/rotation
  41679. */
  41680. protected _update(): void;
  41681. /**
  41682. * Disposes of the gizmo
  41683. */
  41684. dispose(): void;
  41685. }
  41686. }
  41687. declare module "babylonjs/Gizmos/axisDragGizmo" {
  41688. import { Observable } from "babylonjs/Misc/observable";
  41689. import { Nullable } from "babylonjs/types";
  41690. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41691. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41692. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41693. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41694. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  41695. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41696. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  41697. import { Scene } from "babylonjs/scene";
  41698. /**
  41699. * Single axis drag gizmo
  41700. */
  41701. export class AxisDragGizmo extends Gizmo {
  41702. /**
  41703. * Drag behavior responsible for the gizmos dragging interactions
  41704. */
  41705. dragBehavior: PointerDragBehavior;
  41706. private _pointerObserver;
  41707. /**
  41708. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41709. */
  41710. snapDistance: number;
  41711. /**
  41712. * Event that fires each time the gizmo snaps to a new location.
  41713. * * snapDistance is the the change in distance
  41714. */
  41715. onSnapObservable: Observable<{
  41716. snapDistance: number;
  41717. }>;
  41718. /** @hidden */
  41719. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  41720. /** @hidden */
  41721. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41722. /**
  41723. * Creates an AxisDragGizmo
  41724. * @param gizmoLayer The utility layer the gizmo will be added to
  41725. * @param dragAxis The axis which the gizmo will be able to drag on
  41726. * @param color The color of the gizmo
  41727. */
  41728. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41729. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41730. /**
  41731. * Disposes of the gizmo
  41732. */
  41733. dispose(): void;
  41734. }
  41735. }
  41736. declare module "babylonjs/Debug/axesViewer" {
  41737. import { Vector3 } from "babylonjs/Maths/math";
  41738. import { Nullable } from "babylonjs/types";
  41739. import { Scene } from "babylonjs/scene";
  41740. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41741. /**
  41742. * The Axes viewer will show 3 axes in a specific point in space
  41743. */
  41744. export class AxesViewer {
  41745. private _xAxis;
  41746. private _yAxis;
  41747. private _zAxis;
  41748. private _scaleLinesFactor;
  41749. private _instanced;
  41750. /**
  41751. * Gets the hosting scene
  41752. */
  41753. scene: Scene;
  41754. /**
  41755. * Gets or sets a number used to scale line length
  41756. */
  41757. scaleLines: number;
  41758. /** Gets the node hierarchy used to render x-axis */
  41759. readonly xAxis: TransformNode;
  41760. /** Gets the node hierarchy used to render y-axis */
  41761. readonly yAxis: TransformNode;
  41762. /** Gets the node hierarchy used to render z-axis */
  41763. readonly zAxis: TransformNode;
  41764. /**
  41765. * Creates a new AxesViewer
  41766. * @param scene defines the hosting scene
  41767. * @param scaleLines defines a number used to scale line length (1 by default)
  41768. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  41769. * @param xAxis defines the node hierarchy used to render the x-axis
  41770. * @param yAxis defines the node hierarchy used to render the y-axis
  41771. * @param zAxis defines the node hierarchy used to render the z-axis
  41772. */
  41773. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  41774. /**
  41775. * Force the viewer to update
  41776. * @param position defines the position of the viewer
  41777. * @param xaxis defines the x axis of the viewer
  41778. * @param yaxis defines the y axis of the viewer
  41779. * @param zaxis defines the z axis of the viewer
  41780. */
  41781. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  41782. /**
  41783. * Creates an instance of this axes viewer.
  41784. * @returns a new axes viewer with instanced meshes
  41785. */
  41786. createInstance(): AxesViewer;
  41787. /** Releases resources */
  41788. dispose(): void;
  41789. private static _SetRenderingGroupId;
  41790. }
  41791. }
  41792. declare module "babylonjs/Debug/boneAxesViewer" {
  41793. import { Nullable } from "babylonjs/types";
  41794. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  41795. import { Vector3 } from "babylonjs/Maths/math";
  41796. import { Mesh } from "babylonjs/Meshes/mesh";
  41797. import { Bone } from "babylonjs/Bones/bone";
  41798. import { Scene } from "babylonjs/scene";
  41799. /**
  41800. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  41801. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  41802. */
  41803. export class BoneAxesViewer extends AxesViewer {
  41804. /**
  41805. * Gets or sets the target mesh where to display the axes viewer
  41806. */
  41807. mesh: Nullable<Mesh>;
  41808. /**
  41809. * Gets or sets the target bone where to display the axes viewer
  41810. */
  41811. bone: Nullable<Bone>;
  41812. /** Gets current position */
  41813. pos: Vector3;
  41814. /** Gets direction of X axis */
  41815. xaxis: Vector3;
  41816. /** Gets direction of Y axis */
  41817. yaxis: Vector3;
  41818. /** Gets direction of Z axis */
  41819. zaxis: Vector3;
  41820. /**
  41821. * Creates a new BoneAxesViewer
  41822. * @param scene defines the hosting scene
  41823. * @param bone defines the target bone
  41824. * @param mesh defines the target mesh
  41825. * @param scaleLines defines a scaling factor for line length (1 by default)
  41826. */
  41827. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  41828. /**
  41829. * Force the viewer to update
  41830. */
  41831. update(): void;
  41832. /** Releases resources */
  41833. dispose(): void;
  41834. }
  41835. }
  41836. declare module "babylonjs/Debug/debugLayer" {
  41837. import { Observable } from "babylonjs/Misc/observable";
  41838. import { Scene } from "babylonjs/scene";
  41839. /**
  41840. * Interface used to define scene explorer extensibility option
  41841. */
  41842. export interface IExplorerExtensibilityOption {
  41843. /**
  41844. * Define the option label
  41845. */
  41846. label: string;
  41847. /**
  41848. * Defines the action to execute on click
  41849. */
  41850. action: (entity: any) => void;
  41851. }
  41852. /**
  41853. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  41854. */
  41855. export interface IExplorerExtensibilityGroup {
  41856. /**
  41857. * Defines a predicate to test if a given type mut be extended
  41858. */
  41859. predicate: (entity: any) => boolean;
  41860. /**
  41861. * Gets the list of options added to a type
  41862. */
  41863. entries: IExplorerExtensibilityOption[];
  41864. }
  41865. /**
  41866. * Interface used to define the options to use to create the Inspector
  41867. */
  41868. export interface IInspectorOptions {
  41869. /**
  41870. * Display in overlay mode (default: false)
  41871. */
  41872. overlay?: boolean;
  41873. /**
  41874. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  41875. */
  41876. globalRoot?: HTMLElement;
  41877. /**
  41878. * Display the Scene explorer
  41879. */
  41880. showExplorer?: boolean;
  41881. /**
  41882. * Display the property inspector
  41883. */
  41884. showInspector?: boolean;
  41885. /**
  41886. * Display in embed mode (both panes on the right)
  41887. */
  41888. embedMode?: boolean;
  41889. /**
  41890. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  41891. */
  41892. handleResize?: boolean;
  41893. /**
  41894. * Allow the panes to popup (default: true)
  41895. */
  41896. enablePopup?: boolean;
  41897. /**
  41898. * Allow the panes to be closed by users (default: true)
  41899. */
  41900. enableClose?: boolean;
  41901. /**
  41902. * Optional list of extensibility entries
  41903. */
  41904. explorerExtensibility?: IExplorerExtensibilityGroup[];
  41905. /**
  41906. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  41907. */
  41908. inspectorURL?: string;
  41909. }
  41910. module "babylonjs/scene" {
  41911. interface Scene {
  41912. /**
  41913. * @hidden
  41914. * Backing field
  41915. */
  41916. _debugLayer: DebugLayer;
  41917. /**
  41918. * Gets the debug layer (aka Inspector) associated with the scene
  41919. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41920. */
  41921. debugLayer: DebugLayer;
  41922. }
  41923. }
  41924. /**
  41925. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41926. * what is happening in your scene
  41927. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41928. */
  41929. export class DebugLayer {
  41930. /**
  41931. * Define the url to get the inspector script from.
  41932. * By default it uses the babylonjs CDN.
  41933. * @ignoreNaming
  41934. */
  41935. static InspectorURL: string;
  41936. private _scene;
  41937. private BJSINSPECTOR;
  41938. /**
  41939. * Observable triggered when a property is changed through the inspector.
  41940. */
  41941. onPropertyChangedObservable: Observable<{
  41942. object: any;
  41943. property: string;
  41944. value: any;
  41945. initialValue: any;
  41946. }>;
  41947. /**
  41948. * Instantiates a new debug layer.
  41949. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41950. * what is happening in your scene
  41951. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41952. * @param scene Defines the scene to inspect
  41953. */
  41954. constructor(scene: Scene);
  41955. /** Creates the inspector window. */
  41956. private _createInspector;
  41957. /**
  41958. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  41959. * @param entity defines the entity to select
  41960. * @param lineContainerTitle defines the specific block to highlight
  41961. */
  41962. select(entity: any, lineContainerTitle?: string): void;
  41963. /** Get the inspector from bundle or global */
  41964. private _getGlobalInspector;
  41965. /**
  41966. * Get if the inspector is visible or not.
  41967. * @returns true if visible otherwise, false
  41968. */
  41969. isVisible(): boolean;
  41970. /**
  41971. * Hide the inspector and close its window.
  41972. */
  41973. hide(): void;
  41974. /**
  41975. * Launch the debugLayer.
  41976. * @param config Define the configuration of the inspector
  41977. * @return a promise fulfilled when the debug layer is visible
  41978. */
  41979. show(config?: IInspectorOptions): Promise<DebugLayer>;
  41980. }
  41981. }
  41982. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  41983. import { Nullable } from "babylonjs/types";
  41984. import { Scene } from "babylonjs/scene";
  41985. import { Vector4, Color4 } from "babylonjs/Maths/math";
  41986. import { Mesh } from "babylonjs/Meshes/mesh";
  41987. /**
  41988. * Class containing static functions to help procedurally build meshes
  41989. */
  41990. export class BoxBuilder {
  41991. /**
  41992. * Creates a box mesh
  41993. * * The parameter `size` sets the size (float) of each box side (default 1)
  41994. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  41995. * * 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)
  41996. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  41997. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41998. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41999. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42000. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42001. * @param name defines the name of the mesh
  42002. * @param options defines the options used to create the mesh
  42003. * @param scene defines the hosting scene
  42004. * @returns the box mesh
  42005. */
  42006. static CreateBox(name: string, options: {
  42007. size?: number;
  42008. width?: number;
  42009. height?: number;
  42010. depth?: number;
  42011. faceUV?: Vector4[];
  42012. faceColors?: Color4[];
  42013. sideOrientation?: number;
  42014. frontUVs?: Vector4;
  42015. backUVs?: Vector4;
  42016. updatable?: boolean;
  42017. }, scene?: Nullable<Scene>): Mesh;
  42018. }
  42019. }
  42020. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  42021. import { Vector4 } from "babylonjs/Maths/math";
  42022. import { Mesh } from "babylonjs/Meshes/mesh";
  42023. /**
  42024. * Class containing static functions to help procedurally build meshes
  42025. */
  42026. export class SphereBuilder {
  42027. /**
  42028. * Creates a sphere mesh
  42029. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42030. * * 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`)
  42031. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42032. * * 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
  42033. * * 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)
  42034. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42035. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42036. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42037. * @param name defines the name of the mesh
  42038. * @param options defines the options used to create the mesh
  42039. * @param scene defines the hosting scene
  42040. * @returns the sphere mesh
  42041. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42042. */
  42043. static CreateSphere(name: string, options: {
  42044. segments?: number;
  42045. diameter?: number;
  42046. diameterX?: number;
  42047. diameterY?: number;
  42048. diameterZ?: number;
  42049. arc?: number;
  42050. slice?: number;
  42051. sideOrientation?: number;
  42052. frontUVs?: Vector4;
  42053. backUVs?: Vector4;
  42054. updatable?: boolean;
  42055. }, scene: any): Mesh;
  42056. }
  42057. }
  42058. declare module "babylonjs/Debug/physicsViewer" {
  42059. import { Nullable } from "babylonjs/types";
  42060. import { Scene } from "babylonjs/scene";
  42061. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42062. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  42063. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  42064. /**
  42065. * Used to show the physics impostor around the specific mesh
  42066. */
  42067. export class PhysicsViewer {
  42068. /** @hidden */
  42069. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42070. /** @hidden */
  42071. protected _meshes: Array<Nullable<AbstractMesh>>;
  42072. /** @hidden */
  42073. protected _scene: Nullable<Scene>;
  42074. /** @hidden */
  42075. protected _numMeshes: number;
  42076. /** @hidden */
  42077. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42078. private _renderFunction;
  42079. private _utilityLayer;
  42080. private _debugBoxMesh;
  42081. private _debugSphereMesh;
  42082. private _debugMaterial;
  42083. /**
  42084. * Creates a new PhysicsViewer
  42085. * @param scene defines the hosting scene
  42086. */
  42087. constructor(scene: Scene);
  42088. /** @hidden */
  42089. protected _updateDebugMeshes(): void;
  42090. /**
  42091. * Renders a specified physic impostor
  42092. * @param impostor defines the impostor to render
  42093. * @returns the new debug mesh used to render the impostor
  42094. */
  42095. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  42096. /**
  42097. * Hides a specified physic impostor
  42098. * @param impostor defines the impostor to hide
  42099. */
  42100. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42101. private _getDebugMaterial;
  42102. private _getDebugBoxMesh;
  42103. private _getDebugSphereMesh;
  42104. private _getDebugMesh;
  42105. /** Releases all resources */
  42106. dispose(): void;
  42107. }
  42108. }
  42109. declare module "babylonjs/Debug/rayHelper" {
  42110. import { Nullable } from "babylonjs/types";
  42111. import { Ray } from "babylonjs/Culling/ray";
  42112. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42113. import { Scene } from "babylonjs/scene";
  42114. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42115. import "babylonjs/Meshes/Builders/linesBuilder";
  42116. /**
  42117. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42118. * in order to better appreciate the issue one might have.
  42119. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42120. */
  42121. export class RayHelper {
  42122. /**
  42123. * Defines the ray we are currently tryin to visualize.
  42124. */
  42125. ray: Nullable<Ray>;
  42126. private _renderPoints;
  42127. private _renderLine;
  42128. private _renderFunction;
  42129. private _scene;
  42130. private _updateToMeshFunction;
  42131. private _attachedToMesh;
  42132. private _meshSpaceDirection;
  42133. private _meshSpaceOrigin;
  42134. /**
  42135. * Helper function to create a colored helper in a scene in one line.
  42136. * @param ray Defines the ray we are currently tryin to visualize
  42137. * @param scene Defines the scene the ray is used in
  42138. * @param color Defines the color we want to see the ray in
  42139. * @returns The newly created ray helper.
  42140. */
  42141. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42142. /**
  42143. * Instantiate a new ray helper.
  42144. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42145. * in order to better appreciate the issue one might have.
  42146. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42147. * @param ray Defines the ray we are currently tryin to visualize
  42148. */
  42149. constructor(ray: Ray);
  42150. /**
  42151. * Shows the ray we are willing to debug.
  42152. * @param scene Defines the scene the ray needs to be rendered in
  42153. * @param color Defines the color the ray needs to be rendered in
  42154. */
  42155. show(scene: Scene, color?: Color3): void;
  42156. /**
  42157. * Hides the ray we are debugging.
  42158. */
  42159. hide(): void;
  42160. private _render;
  42161. /**
  42162. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42163. * @param mesh Defines the mesh we want the helper attached to
  42164. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42165. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42166. * @param length Defines the length of the ray
  42167. */
  42168. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42169. /**
  42170. * Detach the ray helper from the mesh it has previously been attached to.
  42171. */
  42172. detachFromMesh(): void;
  42173. private _updateToMesh;
  42174. /**
  42175. * Dispose the helper and release its associated resources.
  42176. */
  42177. dispose(): void;
  42178. }
  42179. }
  42180. declare module "babylonjs/Debug/skeletonViewer" {
  42181. import { Color3 } from "babylonjs/Maths/math";
  42182. import { Scene } from "babylonjs/scene";
  42183. import { Nullable } from "babylonjs/types";
  42184. import { Skeleton } from "babylonjs/Bones/skeleton";
  42185. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42186. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42187. /**
  42188. * Class used to render a debug view of a given skeleton
  42189. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42190. */
  42191. export class SkeletonViewer {
  42192. /** defines the skeleton to render */
  42193. skeleton: Skeleton;
  42194. /** defines the mesh attached to the skeleton */
  42195. mesh: AbstractMesh;
  42196. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42197. autoUpdateBonesMatrices: boolean;
  42198. /** defines the rendering group id to use with the viewer */
  42199. renderingGroupId: number;
  42200. /** Gets or sets the color used to render the skeleton */
  42201. color: Color3;
  42202. private _scene;
  42203. private _debugLines;
  42204. private _debugMesh;
  42205. private _isEnabled;
  42206. private _renderFunction;
  42207. private _utilityLayer;
  42208. /**
  42209. * Returns the mesh used to render the bones
  42210. */
  42211. readonly debugMesh: Nullable<LinesMesh>;
  42212. /**
  42213. * Creates a new SkeletonViewer
  42214. * @param skeleton defines the skeleton to render
  42215. * @param mesh defines the mesh attached to the skeleton
  42216. * @param scene defines the hosting scene
  42217. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  42218. * @param renderingGroupId defines the rendering group id to use with the viewer
  42219. */
  42220. constructor(
  42221. /** defines the skeleton to render */
  42222. skeleton: Skeleton,
  42223. /** defines the mesh attached to the skeleton */
  42224. mesh: AbstractMesh, scene: Scene,
  42225. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42226. autoUpdateBonesMatrices?: boolean,
  42227. /** defines the rendering group id to use with the viewer */
  42228. renderingGroupId?: number);
  42229. /** Gets or sets a boolean indicating if the viewer is enabled */
  42230. isEnabled: boolean;
  42231. private _getBonePosition;
  42232. private _getLinesForBonesWithLength;
  42233. private _getLinesForBonesNoLength;
  42234. /** Update the viewer to sync with current skeleton state */
  42235. update(): void;
  42236. /** Release associated resources */
  42237. dispose(): void;
  42238. }
  42239. }
  42240. declare module "babylonjs/Debug/index" {
  42241. export * from "babylonjs/Debug/axesViewer";
  42242. export * from "babylonjs/Debug/boneAxesViewer";
  42243. export * from "babylonjs/Debug/debugLayer";
  42244. export * from "babylonjs/Debug/physicsViewer";
  42245. export * from "babylonjs/Debug/rayHelper";
  42246. export * from "babylonjs/Debug/skeletonViewer";
  42247. }
  42248. declare module "babylonjs/Engines/nullEngine" {
  42249. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  42250. import { Scene } from "babylonjs/scene";
  42251. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  42252. import { Engine } from "babylonjs/Engines/engine";
  42253. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  42254. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  42255. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42256. import { Effect } from "babylonjs/Materials/effect";
  42257. /**
  42258. * Options to create the null engine
  42259. */
  42260. export class NullEngineOptions {
  42261. /**
  42262. * Render width (Default: 512)
  42263. */
  42264. renderWidth: number;
  42265. /**
  42266. * Render height (Default: 256)
  42267. */
  42268. renderHeight: number;
  42269. /**
  42270. * Texture size (Default: 512)
  42271. */
  42272. textureSize: number;
  42273. /**
  42274. * If delta time between frames should be constant
  42275. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42276. */
  42277. deterministicLockstep: boolean;
  42278. /**
  42279. * Maximum about of steps between frames (Default: 4)
  42280. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42281. */
  42282. lockstepMaxSteps: number;
  42283. }
  42284. /**
  42285. * The null engine class provides support for headless version of babylon.js.
  42286. * This can be used in server side scenario or for testing purposes
  42287. */
  42288. export class NullEngine extends Engine {
  42289. private _options;
  42290. /**
  42291. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42292. */
  42293. isDeterministicLockStep(): boolean;
  42294. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  42295. getLockstepMaxSteps(): number;
  42296. /**
  42297. * Sets hardware scaling, used to save performance if needed
  42298. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  42299. */
  42300. getHardwareScalingLevel(): number;
  42301. constructor(options?: NullEngineOptions);
  42302. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  42303. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  42304. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42305. getRenderWidth(useScreen?: boolean): number;
  42306. getRenderHeight(useScreen?: boolean): number;
  42307. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  42308. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  42309. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  42310. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  42311. bindSamplers(effect: Effect): void;
  42312. enableEffect(effect: Effect): void;
  42313. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42314. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  42315. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  42316. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  42317. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  42318. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  42319. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  42320. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  42321. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  42322. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  42323. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  42324. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  42325. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  42326. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  42327. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  42328. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42329. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42330. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42331. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42332. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42333. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42334. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42335. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  42336. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  42337. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42338. bindBuffers(vertexBuffers: {
  42339. [key: string]: VertexBuffer;
  42340. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  42341. wipeCaches(bruteForce?: boolean): void;
  42342. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42343. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42344. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42345. /** @hidden */
  42346. _createTexture(): WebGLTexture;
  42347. /** @hidden */
  42348. _releaseTexture(texture: InternalTexture): void;
  42349. 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;
  42350. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42351. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42352. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42353. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42354. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  42355. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42356. areAllEffectsReady(): boolean;
  42357. /**
  42358. * @hidden
  42359. * Get the current error code of the webGL context
  42360. * @returns the error code
  42361. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42362. */
  42363. getError(): number;
  42364. /** @hidden */
  42365. _getUnpackAlignement(): number;
  42366. /** @hidden */
  42367. _unpackFlipY(value: boolean): void;
  42368. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42369. /**
  42370. * Updates a dynamic vertex buffer.
  42371. * @param vertexBuffer the vertex buffer to update
  42372. * @param data the data used to update the vertex buffer
  42373. * @param byteOffset the byte offset of the data (optional)
  42374. * @param byteLength the byte length of the data (optional)
  42375. */
  42376. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  42377. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42378. /** @hidden */
  42379. _bindTexture(channel: number, texture: InternalTexture): void;
  42380. /** @hidden */
  42381. _releaseBuffer(buffer: WebGLBuffer): boolean;
  42382. releaseEffects(): void;
  42383. displayLoadingUI(): void;
  42384. hideLoadingUI(): void;
  42385. /** @hidden */
  42386. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42387. /** @hidden */
  42388. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42389. /** @hidden */
  42390. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42391. /** @hidden */
  42392. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42393. }
  42394. }
  42395. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  42396. import { Nullable, int } from "babylonjs/types";
  42397. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  42398. /** @hidden */
  42399. export class _OcclusionDataStorage {
  42400. /** @hidden */
  42401. occlusionInternalRetryCounter: number;
  42402. /** @hidden */
  42403. isOcclusionQueryInProgress: boolean;
  42404. /** @hidden */
  42405. isOccluded: boolean;
  42406. /** @hidden */
  42407. occlusionRetryCount: number;
  42408. /** @hidden */
  42409. occlusionType: number;
  42410. /** @hidden */
  42411. occlusionQueryAlgorithmType: number;
  42412. }
  42413. module "babylonjs/Engines/engine" {
  42414. interface Engine {
  42415. /**
  42416. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42417. * @return the new query
  42418. */
  42419. createQuery(): WebGLQuery;
  42420. /**
  42421. * Delete and release a webGL query
  42422. * @param query defines the query to delete
  42423. * @return the current engine
  42424. */
  42425. deleteQuery(query: WebGLQuery): Engine;
  42426. /**
  42427. * Check if a given query has resolved and got its value
  42428. * @param query defines the query to check
  42429. * @returns true if the query got its value
  42430. */
  42431. isQueryResultAvailable(query: WebGLQuery): boolean;
  42432. /**
  42433. * Gets the value of a given query
  42434. * @param query defines the query to check
  42435. * @returns the value of the query
  42436. */
  42437. getQueryResult(query: WebGLQuery): number;
  42438. /**
  42439. * Initiates an occlusion query
  42440. * @param algorithmType defines the algorithm to use
  42441. * @param query defines the query to use
  42442. * @returns the current engine
  42443. * @see http://doc.babylonjs.com/features/occlusionquery
  42444. */
  42445. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42446. /**
  42447. * Ends an occlusion query
  42448. * @see http://doc.babylonjs.com/features/occlusionquery
  42449. * @param algorithmType defines the algorithm to use
  42450. * @returns the current engine
  42451. */
  42452. endOcclusionQuery(algorithmType: number): Engine;
  42453. /**
  42454. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42455. * Please note that only one query can be issued at a time
  42456. * @returns a time token used to track the time span
  42457. */
  42458. startTimeQuery(): Nullable<_TimeToken>;
  42459. /**
  42460. * Ends a time query
  42461. * @param token defines the token used to measure the time span
  42462. * @returns the time spent (in ns)
  42463. */
  42464. endTimeQuery(token: _TimeToken): int;
  42465. /** @hidden */
  42466. _currentNonTimestampToken: Nullable<_TimeToken>;
  42467. /** @hidden */
  42468. _createTimeQuery(): WebGLQuery;
  42469. /** @hidden */
  42470. _deleteTimeQuery(query: WebGLQuery): void;
  42471. /** @hidden */
  42472. _getGlAlgorithmType(algorithmType: number): number;
  42473. /** @hidden */
  42474. _getTimeQueryResult(query: WebGLQuery): any;
  42475. /** @hidden */
  42476. _getTimeQueryAvailability(query: WebGLQuery): any;
  42477. }
  42478. }
  42479. module "babylonjs/Meshes/abstractMesh" {
  42480. interface AbstractMesh {
  42481. /**
  42482. * Backing filed
  42483. * @hidden
  42484. */
  42485. __occlusionDataStorage: _OcclusionDataStorage;
  42486. /**
  42487. * Access property
  42488. * @hidden
  42489. */
  42490. _occlusionDataStorage: _OcclusionDataStorage;
  42491. /**
  42492. * 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.
  42493. * The default value is -1 which means don't break the query and wait till the result
  42494. * @see http://doc.babylonjs.com/features/occlusionquery
  42495. */
  42496. occlusionRetryCount: number;
  42497. /**
  42498. * 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:
  42499. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42500. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42501. * * 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.
  42502. * @see http://doc.babylonjs.com/features/occlusionquery
  42503. */
  42504. occlusionType: number;
  42505. /**
  42506. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42507. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42508. * * 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.
  42509. * @see http://doc.babylonjs.com/features/occlusionquery
  42510. */
  42511. occlusionQueryAlgorithmType: number;
  42512. /**
  42513. * 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
  42514. * @see http://doc.babylonjs.com/features/occlusionquery
  42515. */
  42516. isOccluded: boolean;
  42517. /**
  42518. * Flag to check the progress status of the query
  42519. * @see http://doc.babylonjs.com/features/occlusionquery
  42520. */
  42521. isOcclusionQueryInProgress: boolean;
  42522. }
  42523. }
  42524. }
  42525. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  42526. import { Nullable } from "babylonjs/types";
  42527. /** @hidden */
  42528. export var _forceTransformFeedbackToBundle: boolean;
  42529. module "babylonjs/Engines/engine" {
  42530. interface Engine {
  42531. /**
  42532. * Creates a webGL transform feedback object
  42533. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42534. * @returns the webGL transform feedback object
  42535. */
  42536. createTransformFeedback(): WebGLTransformFeedback;
  42537. /**
  42538. * Delete a webGL transform feedback object
  42539. * @param value defines the webGL transform feedback object to delete
  42540. */
  42541. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42542. /**
  42543. * Bind a webGL transform feedback object to the webgl context
  42544. * @param value defines the webGL transform feedback object to bind
  42545. */
  42546. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42547. /**
  42548. * Begins a transform feedback operation
  42549. * @param usePoints defines if points or triangles must be used
  42550. */
  42551. beginTransformFeedback(usePoints: boolean): void;
  42552. /**
  42553. * Ends a transform feedback operation
  42554. */
  42555. endTransformFeedback(): void;
  42556. /**
  42557. * Specify the varyings to use with transform feedback
  42558. * @param program defines the associated webGL program
  42559. * @param value defines the list of strings representing the varying names
  42560. */
  42561. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42562. /**
  42563. * Bind a webGL buffer for a transform feedback operation
  42564. * @param value defines the webGL buffer to bind
  42565. */
  42566. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  42567. }
  42568. }
  42569. }
  42570. declare module "babylonjs/Engines/Extensions/index" {
  42571. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  42572. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  42573. }
  42574. declare module "babylonjs/Engines/index" {
  42575. export * from "babylonjs/Engines/constants";
  42576. export * from "babylonjs/Engines/engine";
  42577. export * from "babylonjs/Engines/engineStore";
  42578. export * from "babylonjs/Engines/nullEngine";
  42579. export * from "babylonjs/Engines/Extensions/index";
  42580. }
  42581. declare module "babylonjs/Events/clipboardEvents" {
  42582. /**
  42583. * Gather the list of clipboard event types as constants.
  42584. */
  42585. export class ClipboardEventTypes {
  42586. /**
  42587. * The clipboard event is fired when a copy command is active (pressed).
  42588. */
  42589. static readonly COPY: number;
  42590. /**
  42591. * The clipboard event is fired when a cut command is active (pressed).
  42592. */
  42593. static readonly CUT: number;
  42594. /**
  42595. * The clipboard event is fired when a paste command is active (pressed).
  42596. */
  42597. static readonly PASTE: number;
  42598. }
  42599. /**
  42600. * This class is used to store clipboard related info for the onClipboardObservable event.
  42601. */
  42602. export class ClipboardInfo {
  42603. /**
  42604. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42605. */
  42606. type: number;
  42607. /**
  42608. * Defines the related dom event
  42609. */
  42610. event: ClipboardEvent;
  42611. /**
  42612. *Creates an instance of ClipboardInfo.
  42613. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  42614. * @param event Defines the related dom event
  42615. */
  42616. constructor(
  42617. /**
  42618. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42619. */
  42620. type: number,
  42621. /**
  42622. * Defines the related dom event
  42623. */
  42624. event: ClipboardEvent);
  42625. /**
  42626. * Get the clipboard event's type from the keycode.
  42627. * @param keyCode Defines the keyCode for the current keyboard event.
  42628. * @return {number}
  42629. */
  42630. static GetTypeFromCharacter(keyCode: number): number;
  42631. }
  42632. }
  42633. declare module "babylonjs/Events/index" {
  42634. export * from "babylonjs/Events/keyboardEvents";
  42635. export * from "babylonjs/Events/pointerEvents";
  42636. export * from "babylonjs/Events/clipboardEvents";
  42637. }
  42638. declare module "babylonjs/Loading/sceneLoader" {
  42639. import { Observable } from "babylonjs/Misc/observable";
  42640. import { Nullable } from "babylonjs/types";
  42641. import { Scene } from "babylonjs/scene";
  42642. import { Engine } from "babylonjs/Engines/engine";
  42643. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42644. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42645. import { AssetContainer } from "babylonjs/assetContainer";
  42646. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42647. import { Skeleton } from "babylonjs/Bones/skeleton";
  42648. /**
  42649. * Class used to represent data loading progression
  42650. */
  42651. export class SceneLoaderProgressEvent {
  42652. /** defines if data length to load can be evaluated */
  42653. readonly lengthComputable: boolean;
  42654. /** defines the loaded data length */
  42655. readonly loaded: number;
  42656. /** defines the data length to load */
  42657. readonly total: number;
  42658. /**
  42659. * Create a new progress event
  42660. * @param lengthComputable defines if data length to load can be evaluated
  42661. * @param loaded defines the loaded data length
  42662. * @param total defines the data length to load
  42663. */
  42664. constructor(
  42665. /** defines if data length to load can be evaluated */
  42666. lengthComputable: boolean,
  42667. /** defines the loaded data length */
  42668. loaded: number,
  42669. /** defines the data length to load */
  42670. total: number);
  42671. /**
  42672. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42673. * @param event defines the source event
  42674. * @returns a new SceneLoaderProgressEvent
  42675. */
  42676. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42677. }
  42678. /**
  42679. * Interface used by SceneLoader plugins to define supported file extensions
  42680. */
  42681. export interface ISceneLoaderPluginExtensions {
  42682. /**
  42683. * Defines the list of supported extensions
  42684. */
  42685. [extension: string]: {
  42686. isBinary: boolean;
  42687. };
  42688. }
  42689. /**
  42690. * Interface used by SceneLoader plugin factory
  42691. */
  42692. export interface ISceneLoaderPluginFactory {
  42693. /**
  42694. * Defines the name of the factory
  42695. */
  42696. name: string;
  42697. /**
  42698. * Function called to create a new plugin
  42699. * @return the new plugin
  42700. */
  42701. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42702. /**
  42703. * Boolean indicating if the plugin can direct load specific data
  42704. */
  42705. canDirectLoad?: (data: string) => boolean;
  42706. }
  42707. /**
  42708. * Interface used to define a SceneLoader plugin
  42709. */
  42710. export interface ISceneLoaderPlugin {
  42711. /**
  42712. * The friendly name of this plugin.
  42713. */
  42714. name: string;
  42715. /**
  42716. * The file extensions supported by this plugin.
  42717. */
  42718. extensions: string | ISceneLoaderPluginExtensions;
  42719. /**
  42720. * Import meshes into a scene.
  42721. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42722. * @param scene The scene to import into
  42723. * @param data The data to import
  42724. * @param rootUrl The root url for scene and resources
  42725. * @param meshes The meshes array to import into
  42726. * @param particleSystems The particle systems array to import into
  42727. * @param skeletons The skeletons array to import into
  42728. * @param onError The callback when import fails
  42729. * @returns True if successful or false otherwise
  42730. */
  42731. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42732. /**
  42733. * Load into a scene.
  42734. * @param scene The scene to load into
  42735. * @param data The data to import
  42736. * @param rootUrl The root url for scene and resources
  42737. * @param onError The callback when import fails
  42738. * @returns true if successful or false otherwise
  42739. */
  42740. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42741. /**
  42742. * The callback that returns true if the data can be directly loaded.
  42743. */
  42744. canDirectLoad?: (data: string) => boolean;
  42745. /**
  42746. * The callback that allows custom handling of the root url based on the response url.
  42747. */
  42748. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42749. /**
  42750. * Load into an asset container.
  42751. * @param scene The scene to load into
  42752. * @param data The data to import
  42753. * @param rootUrl The root url for scene and resources
  42754. * @param onError The callback when import fails
  42755. * @returns The loaded asset container
  42756. */
  42757. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42758. }
  42759. /**
  42760. * Interface used to define an async SceneLoader plugin
  42761. */
  42762. export interface ISceneLoaderPluginAsync {
  42763. /**
  42764. * The friendly name of this plugin.
  42765. */
  42766. name: string;
  42767. /**
  42768. * The file extensions supported by this plugin.
  42769. */
  42770. extensions: string | ISceneLoaderPluginExtensions;
  42771. /**
  42772. * Import meshes into a scene.
  42773. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42774. * @param scene The scene to import into
  42775. * @param data The data to import
  42776. * @param rootUrl The root url for scene and resources
  42777. * @param onProgress The callback when the load progresses
  42778. * @param fileName Defines the name of the file to load
  42779. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42780. */
  42781. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42782. meshes: AbstractMesh[];
  42783. particleSystems: IParticleSystem[];
  42784. skeletons: Skeleton[];
  42785. animationGroups: AnimationGroup[];
  42786. }>;
  42787. /**
  42788. * Load into a scene.
  42789. * @param scene The scene to load into
  42790. * @param data The data to import
  42791. * @param rootUrl The root url for scene and resources
  42792. * @param onProgress The callback when the load progresses
  42793. * @param fileName Defines the name of the file to load
  42794. * @returns Nothing
  42795. */
  42796. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42797. /**
  42798. * The callback that returns true if the data can be directly loaded.
  42799. */
  42800. canDirectLoad?: (data: string) => boolean;
  42801. /**
  42802. * The callback that allows custom handling of the root url based on the response url.
  42803. */
  42804. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42805. /**
  42806. * Load into an asset container.
  42807. * @param scene The scene to load into
  42808. * @param data The data to import
  42809. * @param rootUrl The root url for scene and resources
  42810. * @param onProgress The callback when the load progresses
  42811. * @param fileName Defines the name of the file to load
  42812. * @returns The loaded asset container
  42813. */
  42814. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42815. }
  42816. /**
  42817. * Class used to load scene from various file formats using registered plugins
  42818. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42819. */
  42820. export class SceneLoader {
  42821. /**
  42822. * No logging while loading
  42823. */
  42824. static readonly NO_LOGGING: number;
  42825. /**
  42826. * Minimal logging while loading
  42827. */
  42828. static readonly MINIMAL_LOGGING: number;
  42829. /**
  42830. * Summary logging while loading
  42831. */
  42832. static readonly SUMMARY_LOGGING: number;
  42833. /**
  42834. * Detailled logging while loading
  42835. */
  42836. static readonly DETAILED_LOGGING: number;
  42837. /**
  42838. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42839. */
  42840. static ForceFullSceneLoadingForIncremental: boolean;
  42841. /**
  42842. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42843. */
  42844. static ShowLoadingScreen: boolean;
  42845. /**
  42846. * Defines the current logging level (while loading the scene)
  42847. * @ignorenaming
  42848. */
  42849. static loggingLevel: number;
  42850. /**
  42851. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42852. */
  42853. static CleanBoneMatrixWeights: boolean;
  42854. /**
  42855. * Event raised when a plugin is used to load a scene
  42856. */
  42857. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42858. private static _registeredPlugins;
  42859. private static _getDefaultPlugin;
  42860. private static _getPluginForExtension;
  42861. private static _getPluginForDirectLoad;
  42862. private static _getPluginForFilename;
  42863. private static _getDirectLoad;
  42864. private static _loadData;
  42865. private static _getFileInfo;
  42866. /**
  42867. * Gets a plugin that can load the given extension
  42868. * @param extension defines the extension to load
  42869. * @returns a plugin or null if none works
  42870. */
  42871. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42872. /**
  42873. * Gets a boolean indicating that the given extension can be loaded
  42874. * @param extension defines the extension to load
  42875. * @returns true if the extension is supported
  42876. */
  42877. static IsPluginForExtensionAvailable(extension: string): boolean;
  42878. /**
  42879. * Adds a new plugin to the list of registered plugins
  42880. * @param plugin defines the plugin to add
  42881. */
  42882. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42883. /**
  42884. * Import meshes into a scene
  42885. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42886. * @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)
  42887. * @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)
  42888. * @param scene the instance of BABYLON.Scene to append to
  42889. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42890. * @param onProgress a callback with a progress event for each file being loaded
  42891. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42892. * @param pluginExtension the extension used to determine the plugin
  42893. * @returns The loaded plugin
  42894. */
  42895. 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>;
  42896. /**
  42897. * Import meshes into a scene
  42898. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42899. * @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)
  42900. * @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)
  42901. * @param scene the instance of BABYLON.Scene to append to
  42902. * @param onProgress a callback with a progress event for each file being loaded
  42903. * @param pluginExtension the extension used to determine the plugin
  42904. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42905. */
  42906. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42907. meshes: AbstractMesh[];
  42908. particleSystems: IParticleSystem[];
  42909. skeletons: Skeleton[];
  42910. animationGroups: AnimationGroup[];
  42911. }>;
  42912. /**
  42913. * Load a scene
  42914. * @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)
  42915. * @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)
  42916. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42917. * @param onSuccess a callback with the scene when import succeeds
  42918. * @param onProgress a callback with a progress event for each file being loaded
  42919. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42920. * @param pluginExtension the extension used to determine the plugin
  42921. * @returns The loaded plugin
  42922. */
  42923. 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>;
  42924. /**
  42925. * Load a scene
  42926. * @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)
  42927. * @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)
  42928. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42929. * @param onProgress a callback with a progress event for each file being loaded
  42930. * @param pluginExtension the extension used to determine the plugin
  42931. * @returns The loaded scene
  42932. */
  42933. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42934. /**
  42935. * Append a scene
  42936. * @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)
  42937. * @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)
  42938. * @param scene is the instance of BABYLON.Scene to append to
  42939. * @param onSuccess a callback with the scene when import succeeds
  42940. * @param onProgress a callback with a progress event for each file being loaded
  42941. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42942. * @param pluginExtension the extension used to determine the plugin
  42943. * @returns The loaded plugin
  42944. */
  42945. 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>;
  42946. /**
  42947. * Append a scene
  42948. * @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)
  42949. * @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)
  42950. * @param scene is the instance of BABYLON.Scene to append to
  42951. * @param onProgress a callback with a progress event for each file being loaded
  42952. * @param pluginExtension the extension used to determine the plugin
  42953. * @returns The given scene
  42954. */
  42955. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42956. /**
  42957. * Load a scene into an asset container
  42958. * @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)
  42959. * @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)
  42960. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42961. * @param onSuccess a callback with the scene when import succeeds
  42962. * @param onProgress a callback with a progress event for each file being loaded
  42963. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42964. * @param pluginExtension the extension used to determine the plugin
  42965. * @returns The loaded plugin
  42966. */
  42967. 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>;
  42968. /**
  42969. * Load a scene into an asset container
  42970. * @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)
  42971. * @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)
  42972. * @param scene is the instance of Scene to append to
  42973. * @param onProgress a callback with a progress event for each file being loaded
  42974. * @param pluginExtension the extension used to determine the plugin
  42975. * @returns The loaded asset container
  42976. */
  42977. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42978. }
  42979. }
  42980. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  42981. import { Scene } from "babylonjs/scene";
  42982. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42983. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42984. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42985. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42986. /**
  42987. * Google Daydream controller
  42988. */
  42989. export class DaydreamController extends WebVRController {
  42990. /**
  42991. * Base Url for the controller model.
  42992. */
  42993. static MODEL_BASE_URL: string;
  42994. /**
  42995. * File name for the controller model.
  42996. */
  42997. static MODEL_FILENAME: string;
  42998. /**
  42999. * Gamepad Id prefix used to identify Daydream Controller.
  43000. */
  43001. static readonly GAMEPAD_ID_PREFIX: string;
  43002. /**
  43003. * Creates a new DaydreamController from a gamepad
  43004. * @param vrGamepad the gamepad that the controller should be created from
  43005. */
  43006. constructor(vrGamepad: any);
  43007. /**
  43008. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43009. * @param scene scene in which to add meshes
  43010. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43011. */
  43012. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43013. /**
  43014. * Called once for each button that changed state since the last frame
  43015. * @param buttonIdx Which button index changed
  43016. * @param state New state of the button
  43017. * @param changes Which properties on the state changed since last frame
  43018. */
  43019. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43020. }
  43021. }
  43022. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  43023. import { Scene } from "babylonjs/scene";
  43024. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43025. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43026. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43027. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43028. /**
  43029. * Gear VR Controller
  43030. */
  43031. export class GearVRController extends WebVRController {
  43032. /**
  43033. * Base Url for the controller model.
  43034. */
  43035. static MODEL_BASE_URL: string;
  43036. /**
  43037. * File name for the controller model.
  43038. */
  43039. static MODEL_FILENAME: string;
  43040. /**
  43041. * Gamepad Id prefix used to identify this controller.
  43042. */
  43043. static readonly GAMEPAD_ID_PREFIX: string;
  43044. private readonly _buttonIndexToObservableNameMap;
  43045. /**
  43046. * Creates a new GearVRController from a gamepad
  43047. * @param vrGamepad the gamepad that the controller should be created from
  43048. */
  43049. constructor(vrGamepad: any);
  43050. /**
  43051. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43052. * @param scene scene in which to add meshes
  43053. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43054. */
  43055. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43056. /**
  43057. * Called once for each button that changed state since the last frame
  43058. * @param buttonIdx Which button index changed
  43059. * @param state New state of the button
  43060. * @param changes Which properties on the state changed since last frame
  43061. */
  43062. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43063. }
  43064. }
  43065. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43066. import { Scene } from "babylonjs/scene";
  43067. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43068. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43069. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43070. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43071. /**
  43072. * Generic Controller
  43073. */
  43074. export class GenericController extends WebVRController {
  43075. /**
  43076. * Base Url for the controller model.
  43077. */
  43078. static readonly MODEL_BASE_URL: string;
  43079. /**
  43080. * File name for the controller model.
  43081. */
  43082. static readonly MODEL_FILENAME: string;
  43083. /**
  43084. * Creates a new GenericController from a gamepad
  43085. * @param vrGamepad the gamepad that the controller should be created from
  43086. */
  43087. constructor(vrGamepad: any);
  43088. /**
  43089. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43090. * @param scene scene in which to add meshes
  43091. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43092. */
  43093. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43094. /**
  43095. * Called once for each button that changed state since the last frame
  43096. * @param buttonIdx Which button index changed
  43097. * @param state New state of the button
  43098. * @param changes Which properties on the state changed since last frame
  43099. */
  43100. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43101. }
  43102. }
  43103. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43104. import { Observable } from "babylonjs/Misc/observable";
  43105. import { Scene } from "babylonjs/scene";
  43106. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43107. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43108. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43109. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43110. /**
  43111. * Oculus Touch Controller
  43112. */
  43113. export class OculusTouchController extends WebVRController {
  43114. /**
  43115. * Base Url for the controller model.
  43116. */
  43117. static MODEL_BASE_URL: string;
  43118. /**
  43119. * File name for the left controller model.
  43120. */
  43121. static MODEL_LEFT_FILENAME: string;
  43122. /**
  43123. * File name for the right controller model.
  43124. */
  43125. static MODEL_RIGHT_FILENAME: string;
  43126. /**
  43127. * Fired when the secondary trigger on this controller is modified
  43128. */
  43129. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43130. /**
  43131. * Fired when the thumb rest on this controller is modified
  43132. */
  43133. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43134. /**
  43135. * Creates a new OculusTouchController from a gamepad
  43136. * @param vrGamepad the gamepad that the controller should be created from
  43137. */
  43138. constructor(vrGamepad: any);
  43139. /**
  43140. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43141. * @param scene scene in which to add meshes
  43142. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43143. */
  43144. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43145. /**
  43146. * Fired when the A button on this controller is modified
  43147. */
  43148. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43149. /**
  43150. * Fired when the B button on this controller is modified
  43151. */
  43152. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43153. /**
  43154. * Fired when the X button on this controller is modified
  43155. */
  43156. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43157. /**
  43158. * Fired when the Y button on this controller is modified
  43159. */
  43160. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43161. /**
  43162. * Called once for each button that changed state since the last frame
  43163. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43164. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43165. * 2) secondary trigger (same)
  43166. * 3) A (right) X (left), touch, pressed = value
  43167. * 4) B / Y
  43168. * 5) thumb rest
  43169. * @param buttonIdx Which button index changed
  43170. * @param state New state of the button
  43171. * @param changes Which properties on the state changed since last frame
  43172. */
  43173. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43174. }
  43175. }
  43176. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43177. import { Scene } from "babylonjs/scene";
  43178. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43179. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43180. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43181. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43182. import { Observable } from "babylonjs/Misc/observable";
  43183. /**
  43184. * Vive Controller
  43185. */
  43186. export class ViveController extends WebVRController {
  43187. /**
  43188. * Base Url for the controller model.
  43189. */
  43190. static MODEL_BASE_URL: string;
  43191. /**
  43192. * File name for the controller model.
  43193. */
  43194. static MODEL_FILENAME: string;
  43195. /**
  43196. * Creates a new ViveController from a gamepad
  43197. * @param vrGamepad the gamepad that the controller should be created from
  43198. */
  43199. constructor(vrGamepad: any);
  43200. /**
  43201. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43202. * @param scene scene in which to add meshes
  43203. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43204. */
  43205. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43206. /**
  43207. * Fired when the left button on this controller is modified
  43208. */
  43209. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43210. /**
  43211. * Fired when the right button on this controller is modified
  43212. */
  43213. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43214. /**
  43215. * Fired when the menu button on this controller is modified
  43216. */
  43217. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43218. /**
  43219. * Called once for each button that changed state since the last frame
  43220. * Vive mapping:
  43221. * 0: touchpad
  43222. * 1: trigger
  43223. * 2: left AND right buttons
  43224. * 3: menu button
  43225. * @param buttonIdx Which button index changed
  43226. * @param state New state of the button
  43227. * @param changes Which properties on the state changed since last frame
  43228. */
  43229. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43230. }
  43231. }
  43232. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43233. import { Observable } from "babylonjs/Misc/observable";
  43234. import { Scene } from "babylonjs/scene";
  43235. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43236. import { Ray } from "babylonjs/Culling/ray";
  43237. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43238. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43239. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43240. /**
  43241. * Defines the WindowsMotionController object that the state of the windows motion controller
  43242. */
  43243. export class WindowsMotionController extends WebVRController {
  43244. /**
  43245. * The base url used to load the left and right controller models
  43246. */
  43247. static MODEL_BASE_URL: string;
  43248. /**
  43249. * The name of the left controller model file
  43250. */
  43251. static MODEL_LEFT_FILENAME: string;
  43252. /**
  43253. * The name of the right controller model file
  43254. */
  43255. static MODEL_RIGHT_FILENAME: string;
  43256. /**
  43257. * The controller name prefix for this controller type
  43258. */
  43259. static readonly GAMEPAD_ID_PREFIX: string;
  43260. /**
  43261. * The controller id pattern for this controller type
  43262. */
  43263. private static readonly GAMEPAD_ID_PATTERN;
  43264. private _loadedMeshInfo;
  43265. private readonly _mapping;
  43266. /**
  43267. * Fired when the trackpad on this controller is clicked
  43268. */
  43269. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43270. /**
  43271. * Fired when the trackpad on this controller is modified
  43272. */
  43273. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43274. /**
  43275. * The current x and y values of this controller's trackpad
  43276. */
  43277. trackpad: StickValues;
  43278. /**
  43279. * Creates a new WindowsMotionController from a gamepad
  43280. * @param vrGamepad the gamepad that the controller should be created from
  43281. */
  43282. constructor(vrGamepad: any);
  43283. /**
  43284. * Fired when the trigger on this controller is modified
  43285. */
  43286. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43287. /**
  43288. * Fired when the menu button on this controller is modified
  43289. */
  43290. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43291. /**
  43292. * Fired when the grip button on this controller is modified
  43293. */
  43294. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43295. /**
  43296. * Fired when the thumbstick button on this controller is modified
  43297. */
  43298. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43299. /**
  43300. * Fired when the touchpad button on this controller is modified
  43301. */
  43302. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43303. /**
  43304. * Fired when the touchpad values on this controller are modified
  43305. */
  43306. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43307. private _updateTrackpad;
  43308. /**
  43309. * Called once per frame by the engine.
  43310. */
  43311. update(): void;
  43312. /**
  43313. * Called once for each button that changed state since the last frame
  43314. * @param buttonIdx Which button index changed
  43315. * @param state New state of the button
  43316. * @param changes Which properties on the state changed since last frame
  43317. */
  43318. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43319. /**
  43320. * Moves the buttons on the controller mesh based on their current state
  43321. * @param buttonName the name of the button to move
  43322. * @param buttonValue the value of the button which determines the buttons new position
  43323. */
  43324. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43325. /**
  43326. * Moves the axis on the controller mesh based on its current state
  43327. * @param axis the index of the axis
  43328. * @param axisValue the value of the axis which determines the meshes new position
  43329. * @hidden
  43330. */
  43331. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43332. /**
  43333. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43334. * @param scene scene in which to add meshes
  43335. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43336. */
  43337. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43338. /**
  43339. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43340. * can be transformed by button presses and axes values, based on this._mapping.
  43341. *
  43342. * @param scene scene in which the meshes exist
  43343. * @param meshes list of meshes that make up the controller model to process
  43344. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43345. */
  43346. private processModel;
  43347. private createMeshInfo;
  43348. /**
  43349. * Gets the ray of the controller in the direction the controller is pointing
  43350. * @param length the length the resulting ray should be
  43351. * @returns a ray in the direction the controller is pointing
  43352. */
  43353. getForwardRay(length?: number): Ray;
  43354. /**
  43355. * Disposes of the controller
  43356. */
  43357. dispose(): void;
  43358. }
  43359. }
  43360. declare module "babylonjs/Gamepads/Controllers/index" {
  43361. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  43362. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  43363. export * from "babylonjs/Gamepads/Controllers/genericController";
  43364. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  43365. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43366. export * from "babylonjs/Gamepads/Controllers/viveController";
  43367. export * from "babylonjs/Gamepads/Controllers/webVRController";
  43368. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  43369. }
  43370. declare module "babylonjs/Gamepads/index" {
  43371. export * from "babylonjs/Gamepads/Controllers/index";
  43372. export * from "babylonjs/Gamepads/gamepad";
  43373. export * from "babylonjs/Gamepads/gamepadManager";
  43374. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  43375. export * from "babylonjs/Gamepads/xboxGamepad";
  43376. }
  43377. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  43378. import { Observable } from "babylonjs/Misc/observable";
  43379. import { Nullable } from "babylonjs/types";
  43380. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43381. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43382. import { Mesh } from "babylonjs/Meshes/mesh";
  43383. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43384. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43385. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43386. /**
  43387. * Single axis scale gizmo
  43388. */
  43389. export class AxisScaleGizmo extends Gizmo {
  43390. private _coloredMaterial;
  43391. /**
  43392. * Drag behavior responsible for the gizmos dragging interactions
  43393. */
  43394. dragBehavior: PointerDragBehavior;
  43395. private _pointerObserver;
  43396. /**
  43397. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43398. */
  43399. snapDistance: number;
  43400. /**
  43401. * Event that fires each time the gizmo snaps to a new location.
  43402. * * snapDistance is the the change in distance
  43403. */
  43404. onSnapObservable: Observable<{
  43405. snapDistance: number;
  43406. }>;
  43407. /**
  43408. * If the scaling operation should be done on all axis (default: false)
  43409. */
  43410. uniformScaling: boolean;
  43411. /**
  43412. * Creates an AxisScaleGizmo
  43413. * @param gizmoLayer The utility layer the gizmo will be added to
  43414. * @param dragAxis The axis which the gizmo will be able to scale on
  43415. * @param color The color of the gizmo
  43416. */
  43417. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43418. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43419. /**
  43420. * Disposes of the gizmo
  43421. */
  43422. dispose(): void;
  43423. /**
  43424. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43425. * @param mesh The mesh to replace the default mesh of the gizmo
  43426. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43427. */
  43428. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43429. }
  43430. }
  43431. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  43432. import { Observable } from "babylonjs/Misc/observable";
  43433. import { Nullable } from "babylonjs/types";
  43434. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43435. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43436. import { Mesh } from "babylonjs/Meshes/mesh";
  43437. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43438. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43439. import "babylonjs/Meshes/Builders/boxBuilder";
  43440. /**
  43441. * Bounding box gizmo
  43442. */
  43443. export class BoundingBoxGizmo extends Gizmo {
  43444. private _lineBoundingBox;
  43445. private _rotateSpheresParent;
  43446. private _scaleBoxesParent;
  43447. private _boundingDimensions;
  43448. private _renderObserver;
  43449. private _pointerObserver;
  43450. private _scaleDragSpeed;
  43451. private _tmpQuaternion;
  43452. private _tmpVector;
  43453. private _tmpRotationMatrix;
  43454. /**
  43455. * 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)
  43456. */
  43457. ignoreChildren: boolean;
  43458. /**
  43459. * 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)
  43460. */
  43461. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43462. /**
  43463. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43464. */
  43465. rotationSphereSize: number;
  43466. /**
  43467. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43468. */
  43469. scaleBoxSize: number;
  43470. /**
  43471. * 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)
  43472. */
  43473. fixedDragMeshScreenSize: boolean;
  43474. /**
  43475. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43476. */
  43477. fixedDragMeshScreenSizeDistanceFactor: number;
  43478. /**
  43479. * Fired when a rotation sphere or scale box is dragged
  43480. */
  43481. onDragStartObservable: Observable<{}>;
  43482. /**
  43483. * Fired when a scale box is dragged
  43484. */
  43485. onScaleBoxDragObservable: Observable<{}>;
  43486. /**
  43487. * Fired when a scale box drag is ended
  43488. */
  43489. onScaleBoxDragEndObservable: Observable<{}>;
  43490. /**
  43491. * Fired when a rotation sphere is dragged
  43492. */
  43493. onRotationSphereDragObservable: Observable<{}>;
  43494. /**
  43495. * Fired when a rotation sphere drag is ended
  43496. */
  43497. onRotationSphereDragEndObservable: Observable<{}>;
  43498. /**
  43499. * 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)
  43500. */
  43501. scalePivot: Nullable<Vector3>;
  43502. private _anchorMesh;
  43503. private _existingMeshScale;
  43504. private _dragMesh;
  43505. private pointerDragBehavior;
  43506. private coloredMaterial;
  43507. private hoverColoredMaterial;
  43508. /**
  43509. * Sets the color of the bounding box gizmo
  43510. * @param color the color to set
  43511. */
  43512. setColor(color: Color3): void;
  43513. /**
  43514. * Creates an BoundingBoxGizmo
  43515. * @param gizmoLayer The utility layer the gizmo will be added to
  43516. * @param color The color of the gizmo
  43517. */
  43518. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43519. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43520. private _selectNode;
  43521. /**
  43522. * Updates the bounding box information for the Gizmo
  43523. */
  43524. updateBoundingBox(): void;
  43525. private _updateRotationSpheres;
  43526. private _updateScaleBoxes;
  43527. /**
  43528. * Enables rotation on the specified axis and disables rotation on the others
  43529. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43530. */
  43531. setEnabledRotationAxis(axis: string): void;
  43532. /**
  43533. * Enables/disables scaling
  43534. * @param enable if scaling should be enabled
  43535. */
  43536. setEnabledScaling(enable: boolean): void;
  43537. private _updateDummy;
  43538. /**
  43539. * Enables a pointer drag behavior on the bounding box of the gizmo
  43540. */
  43541. enableDragBehavior(): void;
  43542. /**
  43543. * Disposes of the gizmo
  43544. */
  43545. dispose(): void;
  43546. /**
  43547. * 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)
  43548. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43549. * @returns the bounding box mesh with the passed in mesh as a child
  43550. */
  43551. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43552. /**
  43553. * CustomMeshes are not supported by this gizmo
  43554. * @param mesh The mesh to replace the default mesh of the gizmo
  43555. */
  43556. setCustomMesh(mesh: Mesh): void;
  43557. }
  43558. }
  43559. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  43560. import { Observable } from "babylonjs/Misc/observable";
  43561. import { Nullable } from "babylonjs/types";
  43562. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43563. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43564. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43565. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43566. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43567. import "babylonjs/Meshes/Builders/linesBuilder";
  43568. /**
  43569. * Single plane rotation gizmo
  43570. */
  43571. export class PlaneRotationGizmo extends Gizmo {
  43572. /**
  43573. * Drag behavior responsible for the gizmos dragging interactions
  43574. */
  43575. dragBehavior: PointerDragBehavior;
  43576. private _pointerObserver;
  43577. /**
  43578. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43579. */
  43580. snapDistance: number;
  43581. /**
  43582. * Event that fires each time the gizmo snaps to a new location.
  43583. * * snapDistance is the the change in distance
  43584. */
  43585. onSnapObservable: Observable<{
  43586. snapDistance: number;
  43587. }>;
  43588. /**
  43589. * Creates a PlaneRotationGizmo
  43590. * @param gizmoLayer The utility layer the gizmo will be added to
  43591. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43592. * @param color The color of the gizmo
  43593. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43594. */
  43595. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43596. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43597. /**
  43598. * Disposes of the gizmo
  43599. */
  43600. dispose(): void;
  43601. }
  43602. }
  43603. declare module "babylonjs/Gizmos/rotationGizmo" {
  43604. import { Observable } from "babylonjs/Misc/observable";
  43605. import { Nullable } from "babylonjs/types";
  43606. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43607. import { Mesh } from "babylonjs/Meshes/mesh";
  43608. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43609. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  43610. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43611. /**
  43612. * Gizmo that enables rotating a mesh along 3 axis
  43613. */
  43614. export class RotationGizmo extends Gizmo {
  43615. /**
  43616. * Internal gizmo used for interactions on the x axis
  43617. */
  43618. xGizmo: PlaneRotationGizmo;
  43619. /**
  43620. * Internal gizmo used for interactions on the y axis
  43621. */
  43622. yGizmo: PlaneRotationGizmo;
  43623. /**
  43624. * Internal gizmo used for interactions on the z axis
  43625. */
  43626. zGizmo: PlaneRotationGizmo;
  43627. /** Fires an event when any of it's sub gizmos are dragged */
  43628. onDragStartObservable: Observable<{}>;
  43629. /** Fires an event when any of it's sub gizmos are released from dragging */
  43630. onDragEndObservable: Observable<{}>;
  43631. attachedMesh: Nullable<AbstractMesh>;
  43632. /**
  43633. * Creates a RotationGizmo
  43634. * @param gizmoLayer The utility layer the gizmo will be added to
  43635. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43636. */
  43637. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43638. updateGizmoRotationToMatchAttachedMesh: boolean;
  43639. /**
  43640. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43641. */
  43642. snapDistance: number;
  43643. /**
  43644. * Ratio for the scale of the gizmo (Default: 1)
  43645. */
  43646. scaleRatio: number;
  43647. /**
  43648. * Disposes of the gizmo
  43649. */
  43650. dispose(): void;
  43651. /**
  43652. * CustomMeshes are not supported by this gizmo
  43653. * @param mesh The mesh to replace the default mesh of the gizmo
  43654. */
  43655. setCustomMesh(mesh: Mesh): void;
  43656. }
  43657. }
  43658. declare module "babylonjs/Gizmos/positionGizmo" {
  43659. import { Observable } from "babylonjs/Misc/observable";
  43660. import { Nullable } from "babylonjs/types";
  43661. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43662. import { Mesh } from "babylonjs/Meshes/mesh";
  43663. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43664. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  43665. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43666. /**
  43667. * Gizmo that enables dragging a mesh along 3 axis
  43668. */
  43669. export class PositionGizmo extends Gizmo {
  43670. /**
  43671. * Internal gizmo used for interactions on the x axis
  43672. */
  43673. xGizmo: AxisDragGizmo;
  43674. /**
  43675. * Internal gizmo used for interactions on the y axis
  43676. */
  43677. yGizmo: AxisDragGizmo;
  43678. /**
  43679. * Internal gizmo used for interactions on the z axis
  43680. */
  43681. zGizmo: AxisDragGizmo;
  43682. /** Fires an event when any of it's sub gizmos are dragged */
  43683. onDragStartObservable: Observable<{}>;
  43684. /** Fires an event when any of it's sub gizmos are released from dragging */
  43685. onDragEndObservable: Observable<{}>;
  43686. attachedMesh: Nullable<AbstractMesh>;
  43687. /**
  43688. * Creates a PositionGizmo
  43689. * @param gizmoLayer The utility layer the gizmo will be added to
  43690. */
  43691. constructor(gizmoLayer?: UtilityLayerRenderer);
  43692. updateGizmoRotationToMatchAttachedMesh: boolean;
  43693. /**
  43694. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43695. */
  43696. snapDistance: number;
  43697. /**
  43698. * Ratio for the scale of the gizmo (Default: 1)
  43699. */
  43700. scaleRatio: number;
  43701. /**
  43702. * Disposes of the gizmo
  43703. */
  43704. dispose(): void;
  43705. /**
  43706. * CustomMeshes are not supported by this gizmo
  43707. * @param mesh The mesh to replace the default mesh of the gizmo
  43708. */
  43709. setCustomMesh(mesh: Mesh): void;
  43710. }
  43711. }
  43712. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  43713. import { Scene } from "babylonjs/scene";
  43714. import { Color4, Vector4 } from "babylonjs/Maths/math";
  43715. import { Mesh } from "babylonjs/Meshes/mesh";
  43716. /**
  43717. * Class containing static functions to help procedurally build meshes
  43718. */
  43719. export class PolyhedronBuilder {
  43720. /**
  43721. * Creates a polyhedron mesh
  43722. * * 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
  43723. * * The parameter `size` (positive float, default 1) sets the polygon size
  43724. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  43725. * * 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`
  43726. * * 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
  43727. * * 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)`)
  43728. * * 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
  43729. * * 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
  43730. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43731. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43732. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43733. * @param name defines the name of the mesh
  43734. * @param options defines the options used to create the mesh
  43735. * @param scene defines the hosting scene
  43736. * @returns the polyhedron mesh
  43737. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  43738. */
  43739. static CreatePolyhedron(name: string, options: {
  43740. type?: number;
  43741. size?: number;
  43742. sizeX?: number;
  43743. sizeY?: number;
  43744. sizeZ?: number;
  43745. custom?: any;
  43746. faceUV?: Vector4[];
  43747. faceColors?: Color4[];
  43748. flat?: boolean;
  43749. updatable?: boolean;
  43750. sideOrientation?: number;
  43751. frontUVs?: Vector4;
  43752. backUVs?: Vector4;
  43753. }, scene: Scene): Mesh;
  43754. }
  43755. }
  43756. declare module "babylonjs/Gizmos/scaleGizmo" {
  43757. import { Observable } from "babylonjs/Misc/observable";
  43758. import { Nullable } from "babylonjs/types";
  43759. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43760. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43761. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  43762. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43763. /**
  43764. * Gizmo that enables scaling a mesh along 3 axis
  43765. */
  43766. export class ScaleGizmo extends Gizmo {
  43767. /**
  43768. * Internal gizmo used for interactions on the x axis
  43769. */
  43770. xGizmo: AxisScaleGizmo;
  43771. /**
  43772. * Internal gizmo used for interactions on the y axis
  43773. */
  43774. yGizmo: AxisScaleGizmo;
  43775. /**
  43776. * Internal gizmo used for interactions on the z axis
  43777. */
  43778. zGizmo: AxisScaleGizmo;
  43779. /**
  43780. * Internal gizmo used to scale all axis equally
  43781. */
  43782. uniformScaleGizmo: AxisScaleGizmo;
  43783. /** Fires an event when any of it's sub gizmos are dragged */
  43784. onDragStartObservable: Observable<{}>;
  43785. /** Fires an event when any of it's sub gizmos are released from dragging */
  43786. onDragEndObservable: Observable<{}>;
  43787. attachedMesh: Nullable<AbstractMesh>;
  43788. /**
  43789. * Creates a ScaleGizmo
  43790. * @param gizmoLayer The utility layer the gizmo will be added to
  43791. */
  43792. constructor(gizmoLayer?: UtilityLayerRenderer);
  43793. updateGizmoRotationToMatchAttachedMesh: boolean;
  43794. /**
  43795. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43796. */
  43797. snapDistance: number;
  43798. /**
  43799. * Ratio for the scale of the gizmo (Default: 1)
  43800. */
  43801. scaleRatio: number;
  43802. /**
  43803. * Disposes of the gizmo
  43804. */
  43805. dispose(): void;
  43806. }
  43807. }
  43808. declare module "babylonjs/Gizmos/gizmoManager" {
  43809. import { Observable } from "babylonjs/Misc/observable";
  43810. import { Nullable } from "babylonjs/types";
  43811. import { Scene, IDisposable } from "babylonjs/scene";
  43812. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43813. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  43814. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  43815. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  43816. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  43817. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  43818. /**
  43819. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  43820. */
  43821. export class GizmoManager implements IDisposable {
  43822. private scene;
  43823. /**
  43824. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  43825. */
  43826. gizmos: {
  43827. positionGizmo: Nullable<PositionGizmo>;
  43828. rotationGizmo: Nullable<RotationGizmo>;
  43829. scaleGizmo: Nullable<ScaleGizmo>;
  43830. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  43831. };
  43832. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  43833. clearGizmoOnEmptyPointerEvent: boolean;
  43834. /** Fires an event when the manager is attached to a mesh */
  43835. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  43836. private _gizmosEnabled;
  43837. private _pointerObserver;
  43838. private _attachedMesh;
  43839. private _boundingBoxColor;
  43840. private _defaultUtilityLayer;
  43841. private _defaultKeepDepthUtilityLayer;
  43842. /**
  43843. * When bounding box gizmo is enabled, this can be used to track drag/end events
  43844. */
  43845. boundingBoxDragBehavior: SixDofDragBehavior;
  43846. /**
  43847. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  43848. */
  43849. attachableMeshes: Nullable<Array<AbstractMesh>>;
  43850. /**
  43851. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43852. */
  43853. usePointerToAttachGizmos: boolean;
  43854. /**
  43855. * Instatiates a gizmo manager
  43856. * @param scene the scene to overlay the gizmos on top of
  43857. */
  43858. constructor(scene: Scene);
  43859. /**
  43860. * Attaches a set of gizmos to the specified mesh
  43861. * @param mesh The mesh the gizmo's should be attached to
  43862. */
  43863. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43864. /**
  43865. * If the position gizmo is enabled
  43866. */
  43867. positionGizmoEnabled: boolean;
  43868. /**
  43869. * If the rotation gizmo is enabled
  43870. */
  43871. rotationGizmoEnabled: boolean;
  43872. /**
  43873. * If the scale gizmo is enabled
  43874. */
  43875. scaleGizmoEnabled: boolean;
  43876. /**
  43877. * If the boundingBox gizmo is enabled
  43878. */
  43879. boundingBoxGizmoEnabled: boolean;
  43880. /**
  43881. * Disposes of the gizmo manager
  43882. */
  43883. dispose(): void;
  43884. }
  43885. }
  43886. declare module "babylonjs/Gizmos/lightGizmo" {
  43887. import { Nullable } from "babylonjs/types";
  43888. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43889. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43890. import { Light } from "babylonjs/Lights/light";
  43891. /**
  43892. * Gizmo that enables viewing a light
  43893. */
  43894. export class LightGizmo extends Gizmo {
  43895. private _box;
  43896. /**
  43897. * Creates a LightGizmo
  43898. * @param gizmoLayer The utility layer the gizmo will be added to
  43899. */
  43900. constructor(gizmoLayer?: UtilityLayerRenderer);
  43901. private _light;
  43902. /**
  43903. * The light that the gizmo is attached to
  43904. */
  43905. light: Nullable<Light>;
  43906. /**
  43907. * @hidden
  43908. * Updates the gizmo to match the attached mesh's position/rotation
  43909. */
  43910. protected _update(): void;
  43911. }
  43912. }
  43913. declare module "babylonjs/Gizmos/index" {
  43914. export * from "babylonjs/Gizmos/axisDragGizmo";
  43915. export * from "babylonjs/Gizmos/axisScaleGizmo";
  43916. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  43917. export * from "babylonjs/Gizmos/gizmo";
  43918. export * from "babylonjs/Gizmos/gizmoManager";
  43919. export * from "babylonjs/Gizmos/planeRotationGizmo";
  43920. export * from "babylonjs/Gizmos/positionGizmo";
  43921. export * from "babylonjs/Gizmos/rotationGizmo";
  43922. export * from "babylonjs/Gizmos/scaleGizmo";
  43923. export * from "babylonjs/Gizmos/lightGizmo";
  43924. }
  43925. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  43926. /** @hidden */
  43927. export var backgroundFragmentDeclaration: {
  43928. name: string;
  43929. shader: string;
  43930. };
  43931. }
  43932. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  43933. /** @hidden */
  43934. export var backgroundUboDeclaration: {
  43935. name: string;
  43936. shader: string;
  43937. };
  43938. }
  43939. declare module "babylonjs/Shaders/background.fragment" {
  43940. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  43941. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43942. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  43943. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43944. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43945. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43946. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43947. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  43948. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  43949. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43950. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  43951. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  43952. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  43953. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  43954. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  43955. /** @hidden */
  43956. export var backgroundPixelShader: {
  43957. name: string;
  43958. shader: string;
  43959. };
  43960. }
  43961. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  43962. /** @hidden */
  43963. export var backgroundVertexDeclaration: {
  43964. name: string;
  43965. shader: string;
  43966. };
  43967. }
  43968. declare module "babylonjs/Shaders/background.vertex" {
  43969. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  43970. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43971. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43972. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  43973. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  43974. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  43975. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  43976. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43977. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43978. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  43979. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  43980. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  43981. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  43982. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  43983. /** @hidden */
  43984. export var backgroundVertexShader: {
  43985. name: string;
  43986. shader: string;
  43987. };
  43988. }
  43989. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  43990. import { Nullable, int, float } from "babylonjs/types";
  43991. import { Scene } from "babylonjs/scene";
  43992. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  43993. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43994. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43995. import { Mesh } from "babylonjs/Meshes/mesh";
  43996. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  43997. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43998. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43999. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44000. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  44001. import "babylonjs/Shaders/background.fragment";
  44002. import "babylonjs/Shaders/background.vertex";
  44003. /**
  44004. * Background material used to create an efficient environement around your scene.
  44005. */
  44006. export class BackgroundMaterial extends PushMaterial {
  44007. /**
  44008. * Standard reflectance value at parallel view angle.
  44009. */
  44010. static StandardReflectance0: number;
  44011. /**
  44012. * Standard reflectance value at grazing angle.
  44013. */
  44014. static StandardReflectance90: number;
  44015. protected _primaryColor: Color3;
  44016. /**
  44017. * Key light Color (multiply against the environement texture)
  44018. */
  44019. primaryColor: Color3;
  44020. protected __perceptualColor: Nullable<Color3>;
  44021. /**
  44022. * Experimental Internal Use Only.
  44023. *
  44024. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44025. * This acts as a helper to set the primary color to a more "human friendly" value.
  44026. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44027. * output color as close as possible from the chosen value.
  44028. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44029. * part of lighting setup.)
  44030. */
  44031. _perceptualColor: Nullable<Color3>;
  44032. protected _primaryColorShadowLevel: float;
  44033. /**
  44034. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44035. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44036. */
  44037. primaryColorShadowLevel: float;
  44038. protected _primaryColorHighlightLevel: float;
  44039. /**
  44040. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44041. * The primary color is used at the level chosen to define what the white area would look.
  44042. */
  44043. primaryColorHighlightLevel: float;
  44044. protected _reflectionTexture: Nullable<BaseTexture>;
  44045. /**
  44046. * Reflection Texture used in the material.
  44047. * Should be author in a specific way for the best result (refer to the documentation).
  44048. */
  44049. reflectionTexture: Nullable<BaseTexture>;
  44050. protected _reflectionBlur: float;
  44051. /**
  44052. * Reflection Texture level of blur.
  44053. *
  44054. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44055. * texture twice.
  44056. */
  44057. reflectionBlur: float;
  44058. protected _diffuseTexture: Nullable<BaseTexture>;
  44059. /**
  44060. * Diffuse Texture used in the material.
  44061. * Should be author in a specific way for the best result (refer to the documentation).
  44062. */
  44063. diffuseTexture: Nullable<BaseTexture>;
  44064. protected _shadowLights: Nullable<IShadowLight[]>;
  44065. /**
  44066. * Specify the list of lights casting shadow on the material.
  44067. * All scene shadow lights will be included if null.
  44068. */
  44069. shadowLights: Nullable<IShadowLight[]>;
  44070. protected _shadowLevel: float;
  44071. /**
  44072. * Helps adjusting the shadow to a softer level if required.
  44073. * 0 means black shadows and 1 means no shadows.
  44074. */
  44075. shadowLevel: float;
  44076. protected _sceneCenter: Vector3;
  44077. /**
  44078. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44079. * It is usually zero but might be interesting to modify according to your setup.
  44080. */
  44081. sceneCenter: Vector3;
  44082. protected _opacityFresnel: boolean;
  44083. /**
  44084. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44085. * This helps ensuring a nice transition when the camera goes under the ground.
  44086. */
  44087. opacityFresnel: boolean;
  44088. protected _reflectionFresnel: boolean;
  44089. /**
  44090. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44091. * This helps adding a mirror texture on the ground.
  44092. */
  44093. reflectionFresnel: boolean;
  44094. protected _reflectionFalloffDistance: number;
  44095. /**
  44096. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44097. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44098. */
  44099. reflectionFalloffDistance: number;
  44100. protected _reflectionAmount: number;
  44101. /**
  44102. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44103. */
  44104. reflectionAmount: number;
  44105. protected _reflectionReflectance0: number;
  44106. /**
  44107. * This specifies the weight of the reflection at grazing angle.
  44108. */
  44109. reflectionReflectance0: number;
  44110. protected _reflectionReflectance90: number;
  44111. /**
  44112. * This specifies the weight of the reflection at a perpendicular point of view.
  44113. */
  44114. reflectionReflectance90: number;
  44115. /**
  44116. * Sets the reflection reflectance fresnel values according to the default standard
  44117. * empirically know to work well :-)
  44118. */
  44119. reflectionStandardFresnelWeight: number;
  44120. protected _useRGBColor: boolean;
  44121. /**
  44122. * Helps to directly use the maps channels instead of their level.
  44123. */
  44124. useRGBColor: boolean;
  44125. protected _enableNoise: boolean;
  44126. /**
  44127. * This helps reducing the banding effect that could occur on the background.
  44128. */
  44129. enableNoise: boolean;
  44130. /**
  44131. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44132. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44133. * Recommended to be keep at 1.0 except for special cases.
  44134. */
  44135. fovMultiplier: number;
  44136. private _fovMultiplier;
  44137. /**
  44138. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44139. */
  44140. useEquirectangularFOV: boolean;
  44141. private _maxSimultaneousLights;
  44142. /**
  44143. * Number of Simultaneous lights allowed on the material.
  44144. */
  44145. maxSimultaneousLights: int;
  44146. /**
  44147. * Default configuration related to image processing available in the Background Material.
  44148. */
  44149. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44150. /**
  44151. * Keep track of the image processing observer to allow dispose and replace.
  44152. */
  44153. private _imageProcessingObserver;
  44154. /**
  44155. * Attaches a new image processing configuration to the PBR Material.
  44156. * @param configuration (if null the scene configuration will be use)
  44157. */
  44158. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44159. /**
  44160. * Gets the image processing configuration used either in this material.
  44161. */
  44162. /**
  44163. * Sets the Default image processing configuration used either in the this material.
  44164. *
  44165. * If sets to null, the scene one is in use.
  44166. */
  44167. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44168. /**
  44169. * Gets wether the color curves effect is enabled.
  44170. */
  44171. /**
  44172. * Sets wether the color curves effect is enabled.
  44173. */
  44174. cameraColorCurvesEnabled: boolean;
  44175. /**
  44176. * Gets wether the color grading effect is enabled.
  44177. */
  44178. /**
  44179. * Gets wether the color grading effect is enabled.
  44180. */
  44181. cameraColorGradingEnabled: boolean;
  44182. /**
  44183. * Gets wether tonemapping is enabled or not.
  44184. */
  44185. /**
  44186. * Sets wether tonemapping is enabled or not
  44187. */
  44188. cameraToneMappingEnabled: boolean;
  44189. /**
  44190. * The camera exposure used on this material.
  44191. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44192. * This corresponds to a photographic exposure.
  44193. */
  44194. /**
  44195. * The camera exposure used on this material.
  44196. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44197. * This corresponds to a photographic exposure.
  44198. */
  44199. cameraExposure: float;
  44200. /**
  44201. * Gets The camera contrast used on this material.
  44202. */
  44203. /**
  44204. * Sets The camera contrast used on this material.
  44205. */
  44206. cameraContrast: float;
  44207. /**
  44208. * Gets the Color Grading 2D Lookup Texture.
  44209. */
  44210. /**
  44211. * Sets the Color Grading 2D Lookup Texture.
  44212. */
  44213. cameraColorGradingTexture: Nullable<BaseTexture>;
  44214. /**
  44215. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44216. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44217. * 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;
  44218. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44219. */
  44220. /**
  44221. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44222. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44223. * 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;
  44224. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44225. */
  44226. cameraColorCurves: Nullable<ColorCurves>;
  44227. /**
  44228. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44229. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44230. */
  44231. switchToBGR: boolean;
  44232. private _renderTargets;
  44233. private _reflectionControls;
  44234. private _white;
  44235. private _primaryShadowColor;
  44236. private _primaryHighlightColor;
  44237. /**
  44238. * Instantiates a Background Material in the given scene
  44239. * @param name The friendly name of the material
  44240. * @param scene The scene to add the material to
  44241. */
  44242. constructor(name: string, scene: Scene);
  44243. /**
  44244. * Gets a boolean indicating that current material needs to register RTT
  44245. */
  44246. readonly hasRenderTargetTextures: boolean;
  44247. /**
  44248. * The entire material has been created in order to prevent overdraw.
  44249. * @returns false
  44250. */
  44251. needAlphaTesting(): boolean;
  44252. /**
  44253. * The entire material has been created in order to prevent overdraw.
  44254. * @returns true if blending is enable
  44255. */
  44256. needAlphaBlending(): boolean;
  44257. /**
  44258. * Checks wether the material is ready to be rendered for a given mesh.
  44259. * @param mesh The mesh to render
  44260. * @param subMesh The submesh to check against
  44261. * @param useInstances Specify wether or not the material is used with instances
  44262. * @returns true if all the dependencies are ready (Textures, Effects...)
  44263. */
  44264. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44265. /**
  44266. * Compute the primary color according to the chosen perceptual color.
  44267. */
  44268. private _computePrimaryColorFromPerceptualColor;
  44269. /**
  44270. * Compute the highlights and shadow colors according to their chosen levels.
  44271. */
  44272. private _computePrimaryColors;
  44273. /**
  44274. * Build the uniform buffer used in the material.
  44275. */
  44276. buildUniformLayout(): void;
  44277. /**
  44278. * Unbind the material.
  44279. */
  44280. unbind(): void;
  44281. /**
  44282. * Bind only the world matrix to the material.
  44283. * @param world The world matrix to bind.
  44284. */
  44285. bindOnlyWorldMatrix(world: Matrix): void;
  44286. /**
  44287. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44288. * @param world The world matrix to bind.
  44289. * @param subMesh The submesh to bind for.
  44290. */
  44291. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44292. /**
  44293. * Dispose the material.
  44294. * @param forceDisposeEffect Force disposal of the associated effect.
  44295. * @param forceDisposeTextures Force disposal of the associated textures.
  44296. */
  44297. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44298. /**
  44299. * Clones the material.
  44300. * @param name The cloned name.
  44301. * @returns The cloned material.
  44302. */
  44303. clone(name: string): BackgroundMaterial;
  44304. /**
  44305. * Serializes the current material to its JSON representation.
  44306. * @returns The JSON representation.
  44307. */
  44308. serialize(): any;
  44309. /**
  44310. * Gets the class name of the material
  44311. * @returns "BackgroundMaterial"
  44312. */
  44313. getClassName(): string;
  44314. /**
  44315. * Parse a JSON input to create back a background material.
  44316. * @param source The JSON data to parse
  44317. * @param scene The scene to create the parsed material in
  44318. * @param rootUrl The root url of the assets the material depends upon
  44319. * @returns the instantiated BackgroundMaterial.
  44320. */
  44321. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  44322. }
  44323. }
  44324. declare module "babylonjs/Helpers/environmentHelper" {
  44325. import { Observable } from "babylonjs/Misc/observable";
  44326. import { Nullable } from "babylonjs/types";
  44327. import { Scene } from "babylonjs/scene";
  44328. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44330. import { Mesh } from "babylonjs/Meshes/mesh";
  44331. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44332. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  44333. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44334. import "babylonjs/Meshes/Builders/planeBuilder";
  44335. import "babylonjs/Meshes/Builders/boxBuilder";
  44336. /**
  44337. * Represents the different options available during the creation of
  44338. * a Environment helper.
  44339. *
  44340. * This can control the default ground, skybox and image processing setup of your scene.
  44341. */
  44342. export interface IEnvironmentHelperOptions {
  44343. /**
  44344. * Specifies wether or not to create a ground.
  44345. * True by default.
  44346. */
  44347. createGround: boolean;
  44348. /**
  44349. * Specifies the ground size.
  44350. * 15 by default.
  44351. */
  44352. groundSize: number;
  44353. /**
  44354. * The texture used on the ground for the main color.
  44355. * Comes from the BabylonJS CDN by default.
  44356. *
  44357. * Remarks: Can be either a texture or a url.
  44358. */
  44359. groundTexture: string | BaseTexture;
  44360. /**
  44361. * The color mixed in the ground texture by default.
  44362. * BabylonJS clearColor by default.
  44363. */
  44364. groundColor: Color3;
  44365. /**
  44366. * Specifies the ground opacity.
  44367. * 1 by default.
  44368. */
  44369. groundOpacity: number;
  44370. /**
  44371. * Enables the ground to receive shadows.
  44372. * True by default.
  44373. */
  44374. enableGroundShadow: boolean;
  44375. /**
  44376. * Helps preventing the shadow to be fully black on the ground.
  44377. * 0.5 by default.
  44378. */
  44379. groundShadowLevel: number;
  44380. /**
  44381. * Creates a mirror texture attach to the ground.
  44382. * false by default.
  44383. */
  44384. enableGroundMirror: boolean;
  44385. /**
  44386. * Specifies the ground mirror size ratio.
  44387. * 0.3 by default as the default kernel is 64.
  44388. */
  44389. groundMirrorSizeRatio: number;
  44390. /**
  44391. * Specifies the ground mirror blur kernel size.
  44392. * 64 by default.
  44393. */
  44394. groundMirrorBlurKernel: number;
  44395. /**
  44396. * Specifies the ground mirror visibility amount.
  44397. * 1 by default
  44398. */
  44399. groundMirrorAmount: number;
  44400. /**
  44401. * Specifies the ground mirror reflectance weight.
  44402. * This uses the standard weight of the background material to setup the fresnel effect
  44403. * of the mirror.
  44404. * 1 by default.
  44405. */
  44406. groundMirrorFresnelWeight: number;
  44407. /**
  44408. * Specifies the ground mirror Falloff distance.
  44409. * This can helps reducing the size of the reflection.
  44410. * 0 by Default.
  44411. */
  44412. groundMirrorFallOffDistance: number;
  44413. /**
  44414. * Specifies the ground mirror texture type.
  44415. * Unsigned Int by Default.
  44416. */
  44417. groundMirrorTextureType: number;
  44418. /**
  44419. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  44420. * the shown objects.
  44421. */
  44422. groundYBias: number;
  44423. /**
  44424. * Specifies wether or not to create a skybox.
  44425. * True by default.
  44426. */
  44427. createSkybox: boolean;
  44428. /**
  44429. * Specifies the skybox size.
  44430. * 20 by default.
  44431. */
  44432. skyboxSize: number;
  44433. /**
  44434. * The texture used on the skybox for the main color.
  44435. * Comes from the BabylonJS CDN by default.
  44436. *
  44437. * Remarks: Can be either a texture or a url.
  44438. */
  44439. skyboxTexture: string | BaseTexture;
  44440. /**
  44441. * The color mixed in the skybox texture by default.
  44442. * BabylonJS clearColor by default.
  44443. */
  44444. skyboxColor: Color3;
  44445. /**
  44446. * The background rotation around the Y axis of the scene.
  44447. * This helps aligning the key lights of your scene with the background.
  44448. * 0 by default.
  44449. */
  44450. backgroundYRotation: number;
  44451. /**
  44452. * Compute automatically the size of the elements to best fit with the scene.
  44453. */
  44454. sizeAuto: boolean;
  44455. /**
  44456. * Default position of the rootMesh if autoSize is not true.
  44457. */
  44458. rootPosition: Vector3;
  44459. /**
  44460. * Sets up the image processing in the scene.
  44461. * true by default.
  44462. */
  44463. setupImageProcessing: boolean;
  44464. /**
  44465. * The texture used as your environment texture in the scene.
  44466. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  44467. *
  44468. * Remarks: Can be either a texture or a url.
  44469. */
  44470. environmentTexture: string | BaseTexture;
  44471. /**
  44472. * The value of the exposure to apply to the scene.
  44473. * 0.6 by default if setupImageProcessing is true.
  44474. */
  44475. cameraExposure: number;
  44476. /**
  44477. * The value of the contrast to apply to the scene.
  44478. * 1.6 by default if setupImageProcessing is true.
  44479. */
  44480. cameraContrast: number;
  44481. /**
  44482. * Specifies wether or not tonemapping should be enabled in the scene.
  44483. * true by default if setupImageProcessing is true.
  44484. */
  44485. toneMappingEnabled: boolean;
  44486. }
  44487. /**
  44488. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  44489. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  44490. * It also helps with the default setup of your imageProcessing configuration.
  44491. */
  44492. export class EnvironmentHelper {
  44493. /**
  44494. * Default ground texture URL.
  44495. */
  44496. private static _groundTextureCDNUrl;
  44497. /**
  44498. * Default skybox texture URL.
  44499. */
  44500. private static _skyboxTextureCDNUrl;
  44501. /**
  44502. * Default environment texture URL.
  44503. */
  44504. private static _environmentTextureCDNUrl;
  44505. /**
  44506. * Creates the default options for the helper.
  44507. */
  44508. private static _getDefaultOptions;
  44509. private _rootMesh;
  44510. /**
  44511. * Gets the root mesh created by the helper.
  44512. */
  44513. readonly rootMesh: Mesh;
  44514. private _skybox;
  44515. /**
  44516. * Gets the skybox created by the helper.
  44517. */
  44518. readonly skybox: Nullable<Mesh>;
  44519. private _skyboxTexture;
  44520. /**
  44521. * Gets the skybox texture created by the helper.
  44522. */
  44523. readonly skyboxTexture: Nullable<BaseTexture>;
  44524. private _skyboxMaterial;
  44525. /**
  44526. * Gets the skybox material created by the helper.
  44527. */
  44528. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  44529. private _ground;
  44530. /**
  44531. * Gets the ground mesh created by the helper.
  44532. */
  44533. readonly ground: Nullable<Mesh>;
  44534. private _groundTexture;
  44535. /**
  44536. * Gets the ground texture created by the helper.
  44537. */
  44538. readonly groundTexture: Nullable<BaseTexture>;
  44539. private _groundMirror;
  44540. /**
  44541. * Gets the ground mirror created by the helper.
  44542. */
  44543. readonly groundMirror: Nullable<MirrorTexture>;
  44544. /**
  44545. * Gets the ground mirror render list to helps pushing the meshes
  44546. * you wish in the ground reflection.
  44547. */
  44548. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  44549. private _groundMaterial;
  44550. /**
  44551. * Gets the ground material created by the helper.
  44552. */
  44553. readonly groundMaterial: Nullable<BackgroundMaterial>;
  44554. /**
  44555. * Stores the creation options.
  44556. */
  44557. private readonly _scene;
  44558. private _options;
  44559. /**
  44560. * This observable will be notified with any error during the creation of the environment,
  44561. * mainly texture creation errors.
  44562. */
  44563. onErrorObservable: Observable<{
  44564. message?: string;
  44565. exception?: any;
  44566. }>;
  44567. /**
  44568. * constructor
  44569. * @param options Defines the options we want to customize the helper
  44570. * @param scene The scene to add the material to
  44571. */
  44572. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  44573. /**
  44574. * Updates the background according to the new options
  44575. * @param options
  44576. */
  44577. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  44578. /**
  44579. * Sets the primary color of all the available elements.
  44580. * @param color the main color to affect to the ground and the background
  44581. */
  44582. setMainColor(color: Color3): void;
  44583. /**
  44584. * Setup the image processing according to the specified options.
  44585. */
  44586. private _setupImageProcessing;
  44587. /**
  44588. * Setup the environment texture according to the specified options.
  44589. */
  44590. private _setupEnvironmentTexture;
  44591. /**
  44592. * Setup the background according to the specified options.
  44593. */
  44594. private _setupBackground;
  44595. /**
  44596. * Get the scene sizes according to the setup.
  44597. */
  44598. private _getSceneSize;
  44599. /**
  44600. * Setup the ground according to the specified options.
  44601. */
  44602. private _setupGround;
  44603. /**
  44604. * Setup the ground material according to the specified options.
  44605. */
  44606. private _setupGroundMaterial;
  44607. /**
  44608. * Setup the ground diffuse texture according to the specified options.
  44609. */
  44610. private _setupGroundDiffuseTexture;
  44611. /**
  44612. * Setup the ground mirror texture according to the specified options.
  44613. */
  44614. private _setupGroundMirrorTexture;
  44615. /**
  44616. * Setup the ground to receive the mirror texture.
  44617. */
  44618. private _setupMirrorInGroundMaterial;
  44619. /**
  44620. * Setup the skybox according to the specified options.
  44621. */
  44622. private _setupSkybox;
  44623. /**
  44624. * Setup the skybox material according to the specified options.
  44625. */
  44626. private _setupSkyboxMaterial;
  44627. /**
  44628. * Setup the skybox reflection texture according to the specified options.
  44629. */
  44630. private _setupSkyboxReflectionTexture;
  44631. private _errorHandler;
  44632. /**
  44633. * Dispose all the elements created by the Helper.
  44634. */
  44635. dispose(): void;
  44636. }
  44637. }
  44638. declare module "babylonjs/Helpers/photoDome" {
  44639. import { Observable } from "babylonjs/Misc/observable";
  44640. import { Nullable } from "babylonjs/types";
  44641. import { Scene } from "babylonjs/scene";
  44642. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44643. import { Mesh } from "babylonjs/Meshes/mesh";
  44644. import { Texture } from "babylonjs/Materials/Textures/texture";
  44645. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44646. import "babylonjs/Meshes/Builders/sphereBuilder";
  44647. /**
  44648. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  44649. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  44650. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  44651. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44652. */
  44653. export class PhotoDome extends TransformNode {
  44654. private _useDirectMapping;
  44655. /**
  44656. * The texture being displayed on the sphere
  44657. */
  44658. protected _photoTexture: Texture;
  44659. /**
  44660. * Gets or sets the texture being displayed on the sphere
  44661. */
  44662. photoTexture: Texture;
  44663. /**
  44664. * Observable raised when an error occured while loading the 360 image
  44665. */
  44666. onLoadErrorObservable: Observable<string>;
  44667. /**
  44668. * The skybox material
  44669. */
  44670. protected _material: BackgroundMaterial;
  44671. /**
  44672. * The surface used for the skybox
  44673. */
  44674. protected _mesh: Mesh;
  44675. /**
  44676. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44677. * Also see the options.resolution property.
  44678. */
  44679. fovMultiplier: number;
  44680. /**
  44681. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  44682. * @param name Element's name, child elements will append suffixes for their own names.
  44683. * @param urlsOfPhoto defines the url of the photo to display
  44684. * @param options defines an object containing optional or exposed sub element properties
  44685. * @param onError defines a callback called when an error occured while loading the texture
  44686. */
  44687. constructor(name: string, urlOfPhoto: string, options: {
  44688. resolution?: number;
  44689. size?: number;
  44690. useDirectMapping?: boolean;
  44691. faceForward?: boolean;
  44692. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  44693. /**
  44694. * Releases resources associated with this node.
  44695. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44696. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44697. */
  44698. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44699. }
  44700. }
  44701. declare module "babylonjs/Misc/textureTools" {
  44702. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44703. import { Texture } from "babylonjs/Materials/Textures/texture";
  44704. import { Scene } from "babylonjs/scene";
  44705. /**
  44706. * Class used to host texture specific utilities
  44707. */
  44708. export class TextureTools {
  44709. /**
  44710. * Uses the GPU to create a copy texture rescaled at a given size
  44711. * @param texture Texture to copy from
  44712. * @param width defines the desired width
  44713. * @param height defines the desired height
  44714. * @param useBilinearMode defines if bilinear mode has to be used
  44715. * @return the generated texture
  44716. */
  44717. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  44718. /**
  44719. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  44720. * @param scene defines the hosting scene
  44721. * @returns the environment BRDF texture
  44722. */
  44723. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44724. private static _environmentBRDFBase64Texture;
  44725. }
  44726. }
  44727. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  44728. import { Nullable } from "babylonjs/types";
  44729. import { IAnimatable } from "babylonjs/Misc/tools";
  44730. import { Color3 } from "babylonjs/Maths/math";
  44731. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44732. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44733. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44734. import { Engine } from "babylonjs/Engines/engine";
  44735. import { Scene } from "babylonjs/scene";
  44736. /**
  44737. * @hidden
  44738. */
  44739. export interface IMaterialClearCoatDefines {
  44740. CLEARCOAT: boolean;
  44741. CLEARCOAT_DEFAULTIOR: boolean;
  44742. CLEARCOAT_TEXTURE: boolean;
  44743. CLEARCOAT_TEXTUREDIRECTUV: number;
  44744. CLEARCOAT_BUMP: boolean;
  44745. CLEARCOAT_BUMPDIRECTUV: number;
  44746. CLEARCOAT_TINT: boolean;
  44747. CLEARCOAT_TINT_TEXTURE: boolean;
  44748. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44749. /** @hidden */
  44750. _areTexturesDirty: boolean;
  44751. }
  44752. /**
  44753. * Define the code related to the clear coat parameters of the pbr material.
  44754. */
  44755. export class PBRClearCoatConfiguration {
  44756. /**
  44757. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44758. * The default fits with a polyurethane material.
  44759. */
  44760. private static readonly _DefaultIndiceOfRefraction;
  44761. private _isEnabled;
  44762. /**
  44763. * Defines if the clear coat is enabled in the material.
  44764. */
  44765. isEnabled: boolean;
  44766. /**
  44767. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  44768. */
  44769. intensity: number;
  44770. /**
  44771. * Defines the clear coat layer roughness.
  44772. */
  44773. roughness: number;
  44774. private _indiceOfRefraction;
  44775. /**
  44776. * Defines the indice of refraction of the clear coat.
  44777. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44778. * The default fits with a polyurethane material.
  44779. * Changing the default value is more performance intensive.
  44780. */
  44781. indiceOfRefraction: number;
  44782. private _texture;
  44783. /**
  44784. * Stores the clear coat values in a texture.
  44785. */
  44786. texture: Nullable<BaseTexture>;
  44787. private _bumpTexture;
  44788. /**
  44789. * Define the clear coat specific bump texture.
  44790. */
  44791. bumpTexture: Nullable<BaseTexture>;
  44792. private _isTintEnabled;
  44793. /**
  44794. * Defines if the clear coat tint is enabled in the material.
  44795. */
  44796. isTintEnabled: boolean;
  44797. /**
  44798. * Defines if the clear coat tint is enabled in the material.
  44799. * This is only use if tint is enabled
  44800. */
  44801. tintColor: Color3;
  44802. /**
  44803. * Defines if the distance at which the tint color should be found in the
  44804. * clear coat media.
  44805. * This is only use if tint is enabled
  44806. */
  44807. tintColorAtDistance: number;
  44808. /**
  44809. * Defines the clear coat layer thickness.
  44810. * This is only use if tint is enabled
  44811. */
  44812. tintThickness: number;
  44813. private _tintTexture;
  44814. /**
  44815. * Stores the clear tint values in a texture.
  44816. * rgb is tint
  44817. * a is a thickness factor
  44818. */
  44819. tintTexture: Nullable<BaseTexture>;
  44820. /** @hidden */
  44821. private _internalMarkAllSubMeshesAsTexturesDirty;
  44822. /** @hidden */
  44823. _markAllSubMeshesAsTexturesDirty(): void;
  44824. /**
  44825. * Instantiate a new istance of clear coat configuration.
  44826. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44827. */
  44828. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44829. /**
  44830. * Specifies that the submesh is ready to be used.
  44831. * @param defines the list of "defines" to update.
  44832. * @param scene defines the scene the material belongs to.
  44833. * @param engine defines the engine the material belongs to.
  44834. * @param disableBumpMap defines wether the material disables bump or not.
  44835. * @returns - boolean indicating that the submesh is ready or not.
  44836. */
  44837. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  44838. /**
  44839. * Checks to see if a texture is used in the material.
  44840. * @param defines the list of "defines" to update.
  44841. * @param scene defines the scene to the material belongs to.
  44842. */
  44843. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  44844. /**
  44845. * Binds the material data.
  44846. * @param uniformBuffer defines the Uniform buffer to fill in.
  44847. * @param scene defines the scene the material belongs to.
  44848. * @param engine defines the engine the material belongs to.
  44849. * @param disableBumpMap defines wether the material disables bump or not.
  44850. * @param isFrozen defines wether the material is frozen or not.
  44851. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44852. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44853. */
  44854. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  44855. /**
  44856. * Checks to see if a texture is used in the material.
  44857. * @param texture - Base texture to use.
  44858. * @returns - Boolean specifying if a texture is used in the material.
  44859. */
  44860. hasTexture(texture: BaseTexture): boolean;
  44861. /**
  44862. * Returns an array of the actively used textures.
  44863. * @param activeTextures Array of BaseTextures
  44864. */
  44865. getActiveTextures(activeTextures: BaseTexture[]): void;
  44866. /**
  44867. * Returns the animatable textures.
  44868. * @param animatables Array of animatable textures.
  44869. */
  44870. getAnimatables(animatables: IAnimatable[]): void;
  44871. /**
  44872. * Disposes the resources of the material.
  44873. * @param forceDisposeTextures - Forces the disposal of all textures.
  44874. */
  44875. dispose(forceDisposeTextures?: boolean): void;
  44876. /**
  44877. * Get the current class name of the texture useful for serialization or dynamic coding.
  44878. * @returns "PBRClearCoatConfiguration"
  44879. */
  44880. getClassName(): string;
  44881. /**
  44882. * Add fallbacks to the effect fallbacks list.
  44883. * @param defines defines the Base texture to use.
  44884. * @param fallbacks defines the current fallback list.
  44885. * @param currentRank defines the current fallback rank.
  44886. * @returns the new fallback rank.
  44887. */
  44888. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44889. /**
  44890. * Add the required uniforms to the current list.
  44891. * @param uniforms defines the current uniform list.
  44892. */
  44893. static AddUniforms(uniforms: string[]): void;
  44894. /**
  44895. * Add the required samplers to the current list.
  44896. * @param samplers defines the current sampler list.
  44897. */
  44898. static AddSamplers(samplers: string[]): void;
  44899. /**
  44900. * Add the required uniforms to the current buffer.
  44901. * @param uniformBuffer defines the current uniform buffer.
  44902. */
  44903. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44904. /**
  44905. * Makes a duplicate of the current configuration into another one.
  44906. * @param clearCoatConfiguration define the config where to copy the info
  44907. */
  44908. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  44909. /**
  44910. * Serializes this clear coat configuration.
  44911. * @returns - An object with the serialized config.
  44912. */
  44913. serialize(): any;
  44914. /**
  44915. * Parses a Clear Coat Configuration from a serialized object.
  44916. * @param source - Serialized object.
  44917. */
  44918. parse(source: any): void;
  44919. }
  44920. }
  44921. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  44922. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44923. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44924. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44925. import { Vector2 } from "babylonjs/Maths/math";
  44926. import { Scene } from "babylonjs/scene";
  44927. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44928. import { IAnimatable } from "babylonjs/Misc/tools";
  44929. import { Nullable } from "babylonjs/types";
  44930. /**
  44931. * @hidden
  44932. */
  44933. export interface IMaterialAnisotropicDefines {
  44934. ANISOTROPIC: boolean;
  44935. ANISOTROPIC_TEXTURE: boolean;
  44936. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44937. MAINUV1: boolean;
  44938. _areTexturesDirty: boolean;
  44939. _needUVs: boolean;
  44940. }
  44941. /**
  44942. * Define the code related to the anisotropic parameters of the pbr material.
  44943. */
  44944. export class PBRAnisotropicConfiguration {
  44945. private _isEnabled;
  44946. /**
  44947. * Defines if the anisotropy is enabled in the material.
  44948. */
  44949. isEnabled: boolean;
  44950. /**
  44951. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  44952. */
  44953. intensity: number;
  44954. /**
  44955. * Defines if the effect is along the tangents, bitangents or in between.
  44956. * By default, the effect is "strectching" the highlights along the tangents.
  44957. */
  44958. direction: Vector2;
  44959. private _texture;
  44960. /**
  44961. * Stores the anisotropy values in a texture.
  44962. * rg is direction (like normal from -1 to 1)
  44963. * b is a intensity
  44964. */
  44965. texture: Nullable<BaseTexture>;
  44966. /** @hidden */
  44967. private _internalMarkAllSubMeshesAsTexturesDirty;
  44968. /** @hidden */
  44969. _markAllSubMeshesAsTexturesDirty(): void;
  44970. /**
  44971. * Instantiate a new istance of anisotropy configuration.
  44972. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44973. */
  44974. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44975. /**
  44976. * Specifies that the submesh is ready to be used.
  44977. * @param defines the list of "defines" to update.
  44978. * @param scene defines the scene the material belongs to.
  44979. * @returns - boolean indicating that the submesh is ready or not.
  44980. */
  44981. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  44982. /**
  44983. * Checks to see if a texture is used in the material.
  44984. * @param defines the list of "defines" to update.
  44985. * @param mesh the mesh we are preparing the defines for.
  44986. * @param scene defines the scene the material belongs to.
  44987. */
  44988. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  44989. /**
  44990. * Binds the material data.
  44991. * @param uniformBuffer defines the Uniform buffer to fill in.
  44992. * @param scene defines the scene the material belongs to.
  44993. * @param isFrozen defines wether the material is frozen or not.
  44994. */
  44995. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44996. /**
  44997. * Checks to see if a texture is used in the material.
  44998. * @param texture - Base texture to use.
  44999. * @returns - Boolean specifying if a texture is used in the material.
  45000. */
  45001. hasTexture(texture: BaseTexture): boolean;
  45002. /**
  45003. * Returns an array of the actively used textures.
  45004. * @param activeTextures Array of BaseTextures
  45005. */
  45006. getActiveTextures(activeTextures: BaseTexture[]): void;
  45007. /**
  45008. * Returns the animatable textures.
  45009. * @param animatables Array of animatable textures.
  45010. */
  45011. getAnimatables(animatables: IAnimatable[]): void;
  45012. /**
  45013. * Disposes the resources of the material.
  45014. * @param forceDisposeTextures - Forces the disposal of all textures.
  45015. */
  45016. dispose(forceDisposeTextures?: boolean): void;
  45017. /**
  45018. * Get the current class name of the texture useful for serialization or dynamic coding.
  45019. * @returns "PBRAnisotropicConfiguration"
  45020. */
  45021. getClassName(): string;
  45022. /**
  45023. * Add fallbacks to the effect fallbacks list.
  45024. * @param defines defines the Base texture to use.
  45025. * @param fallbacks defines the current fallback list.
  45026. * @param currentRank defines the current fallback rank.
  45027. * @returns the new fallback rank.
  45028. */
  45029. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45030. /**
  45031. * Add the required uniforms to the current list.
  45032. * @param uniforms defines the current uniform list.
  45033. */
  45034. static AddUniforms(uniforms: string[]): void;
  45035. /**
  45036. * Add the required uniforms to the current buffer.
  45037. * @param uniformBuffer defines the current uniform buffer.
  45038. */
  45039. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45040. /**
  45041. * Add the required samplers to the current list.
  45042. * @param samplers defines the current sampler list.
  45043. */
  45044. static AddSamplers(samplers: string[]): void;
  45045. /**
  45046. * Makes a duplicate of the current configuration into another one.
  45047. * @param anisotropicConfiguration define the config where to copy the info
  45048. */
  45049. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  45050. /**
  45051. * Serializes this anisotropy configuration.
  45052. * @returns - An object with the serialized config.
  45053. */
  45054. serialize(): any;
  45055. /**
  45056. * Parses a anisotropy Configuration from a serialized object.
  45057. * @param source - Serialized object.
  45058. */
  45059. parse(source: any): void;
  45060. }
  45061. }
  45062. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  45063. /**
  45064. * @hidden
  45065. */
  45066. export interface IMaterialBRDFDefines {
  45067. BRDF_V_HEIGHT_CORRELATED: boolean;
  45068. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45069. /** @hidden */
  45070. _areMiscDirty: boolean;
  45071. }
  45072. /**
  45073. * Define the code related to the BRDF parameters of the pbr material.
  45074. */
  45075. export class PBRBRDFConfiguration {
  45076. private _useEnergyConservation;
  45077. /**
  45078. * Defines if the material uses energy conservation.
  45079. */
  45080. useEnergyConservation: boolean;
  45081. private _useSmithVisibilityHeightCorrelated;
  45082. /**
  45083. * LEGACY Mode set to false
  45084. * Defines if the material uses height smith correlated visibility term.
  45085. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  45086. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45087. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  45088. * Not relying on height correlated will also disable energy conservation.
  45089. */
  45090. useSmithVisibilityHeightCorrelated: boolean;
  45091. /** @hidden */
  45092. private _internalMarkAllSubMeshesAsMiscDirty;
  45093. /** @hidden */
  45094. _markAllSubMeshesAsMiscDirty(): void;
  45095. /**
  45096. * Instantiate a new istance of clear coat configuration.
  45097. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  45098. */
  45099. constructor(markAllSubMeshesAsMiscDirty: () => void);
  45100. /**
  45101. * Checks to see if a texture is used in the material.
  45102. * @param defines the list of "defines" to update.
  45103. */
  45104. prepareDefines(defines: IMaterialBRDFDefines): void;
  45105. /**
  45106. * Get the current class name of the texture useful for serialization or dynamic coding.
  45107. * @returns "PBRClearCoatConfiguration"
  45108. */
  45109. getClassName(): string;
  45110. /**
  45111. * Makes a duplicate of the current configuration into another one.
  45112. * @param brdfConfiguration define the config where to copy the info
  45113. */
  45114. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  45115. /**
  45116. * Serializes this BRDF configuration.
  45117. * @returns - An object with the serialized config.
  45118. */
  45119. serialize(): any;
  45120. /**
  45121. * Parses a BRDF Configuration from a serialized object.
  45122. * @param source - Serialized object.
  45123. */
  45124. parse(source: any): void;
  45125. }
  45126. }
  45127. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  45128. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45129. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45130. import { Color3 } from "babylonjs/Maths/math";
  45131. import { Scene } from "babylonjs/scene";
  45132. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45133. import { IAnimatable } from "babylonjs/Misc/tools";
  45134. import { Nullable } from "babylonjs/types";
  45135. /**
  45136. * @hidden
  45137. */
  45138. export interface IMaterialSheenDefines {
  45139. SHEEN: boolean;
  45140. SHEEN_TEXTURE: boolean;
  45141. SHEEN_TEXTUREDIRECTUV: number;
  45142. SHEEN_LINKWITHALBEDO: boolean;
  45143. /** @hidden */
  45144. _areTexturesDirty: boolean;
  45145. }
  45146. /**
  45147. * Define the code related to the Sheen parameters of the pbr material.
  45148. */
  45149. export class PBRSheenConfiguration {
  45150. private _isEnabled;
  45151. /**
  45152. * Defines if the material uses sheen.
  45153. */
  45154. isEnabled: boolean;
  45155. private _linkSheenWithAlbedo;
  45156. /**
  45157. * Defines if the sheen is linked to the sheen color.
  45158. */
  45159. linkSheenWithAlbedo: boolean;
  45160. /**
  45161. * Defines the sheen intensity.
  45162. */
  45163. intensity: number;
  45164. /**
  45165. * Defines the sheen color.
  45166. */
  45167. color: Color3;
  45168. private _texture;
  45169. /**
  45170. * Stores the sheen tint values in a texture.
  45171. * rgb is tint
  45172. * a is a intensity
  45173. */
  45174. texture: Nullable<BaseTexture>;
  45175. /** @hidden */
  45176. private _internalMarkAllSubMeshesAsTexturesDirty;
  45177. /** @hidden */
  45178. _markAllSubMeshesAsTexturesDirty(): void;
  45179. /**
  45180. * Instantiate a new istance of clear coat configuration.
  45181. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45182. */
  45183. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45184. /**
  45185. * Specifies that the submesh is ready to be used.
  45186. * @param defines the list of "defines" to update.
  45187. * @param scene defines the scene the material belongs to.
  45188. * @returns - boolean indicating that the submesh is ready or not.
  45189. */
  45190. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  45191. /**
  45192. * Checks to see if a texture is used in the material.
  45193. * @param defines the list of "defines" to update.
  45194. * @param scene defines the scene the material belongs to.
  45195. */
  45196. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  45197. /**
  45198. * Binds the material data.
  45199. * @param uniformBuffer defines the Uniform buffer to fill in.
  45200. * @param scene defines the scene the material belongs to.
  45201. * @param isFrozen defines wether the material is frozen or not.
  45202. */
  45203. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45204. /**
  45205. * Checks to see if a texture is used in the material.
  45206. * @param texture - Base texture to use.
  45207. * @returns - Boolean specifying if a texture is used in the material.
  45208. */
  45209. hasTexture(texture: BaseTexture): boolean;
  45210. /**
  45211. * Returns an array of the actively used textures.
  45212. * @param activeTextures Array of BaseTextures
  45213. */
  45214. getActiveTextures(activeTextures: BaseTexture[]): void;
  45215. /**
  45216. * Returns the animatable textures.
  45217. * @param animatables Array of animatable textures.
  45218. */
  45219. getAnimatables(animatables: IAnimatable[]): void;
  45220. /**
  45221. * Disposes the resources of the material.
  45222. * @param forceDisposeTextures - Forces the disposal of all textures.
  45223. */
  45224. dispose(forceDisposeTextures?: boolean): void;
  45225. /**
  45226. * Get the current class name of the texture useful for serialization or dynamic coding.
  45227. * @returns "PBRSheenConfiguration"
  45228. */
  45229. getClassName(): string;
  45230. /**
  45231. * Add fallbacks to the effect fallbacks list.
  45232. * @param defines defines the Base texture to use.
  45233. * @param fallbacks defines the current fallback list.
  45234. * @param currentRank defines the current fallback rank.
  45235. * @returns the new fallback rank.
  45236. */
  45237. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45238. /**
  45239. * Add the required uniforms to the current list.
  45240. * @param uniforms defines the current uniform list.
  45241. */
  45242. static AddUniforms(uniforms: string[]): void;
  45243. /**
  45244. * Add the required uniforms to the current buffer.
  45245. * @param uniformBuffer defines the current uniform buffer.
  45246. */
  45247. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45248. /**
  45249. * Add the required samplers to the current list.
  45250. * @param samplers defines the current sampler list.
  45251. */
  45252. static AddSamplers(samplers: string[]): void;
  45253. /**
  45254. * Makes a duplicate of the current configuration into another one.
  45255. * @param sheenConfiguration define the config where to copy the info
  45256. */
  45257. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  45258. /**
  45259. * Serializes this BRDF configuration.
  45260. * @returns - An object with the serialized config.
  45261. */
  45262. serialize(): any;
  45263. /**
  45264. * Parses a Sheen Configuration from a serialized object.
  45265. * @param source - Serialized object.
  45266. */
  45267. parse(source: any): void;
  45268. }
  45269. }
  45270. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  45271. /** @hidden */
  45272. export var pbrFragmentDeclaration: {
  45273. name: string;
  45274. shader: string;
  45275. };
  45276. }
  45277. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  45278. /** @hidden */
  45279. export var pbrUboDeclaration: {
  45280. name: string;
  45281. shader: string;
  45282. };
  45283. }
  45284. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  45285. /** @hidden */
  45286. export var pbrFragmentExtraDeclaration: {
  45287. name: string;
  45288. shader: string;
  45289. };
  45290. }
  45291. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  45292. /** @hidden */
  45293. export var pbrFragmentSamplersDeclaration: {
  45294. name: string;
  45295. shader: string;
  45296. };
  45297. }
  45298. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  45299. /** @hidden */
  45300. export var pbrHelperFunctions: {
  45301. name: string;
  45302. shader: string;
  45303. };
  45304. }
  45305. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  45306. /** @hidden */
  45307. export var harmonicsFunctions: {
  45308. name: string;
  45309. shader: string;
  45310. };
  45311. }
  45312. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  45313. /** @hidden */
  45314. export var pbrDirectLightingSetupFunctions: {
  45315. name: string;
  45316. shader: string;
  45317. };
  45318. }
  45319. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  45320. /** @hidden */
  45321. export var pbrDirectLightingFalloffFunctions: {
  45322. name: string;
  45323. shader: string;
  45324. };
  45325. }
  45326. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  45327. /** @hidden */
  45328. export var pbrBRDFFunctions: {
  45329. name: string;
  45330. shader: string;
  45331. };
  45332. }
  45333. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  45334. /** @hidden */
  45335. export var pbrDirectLightingFunctions: {
  45336. name: string;
  45337. shader: string;
  45338. };
  45339. }
  45340. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  45341. /** @hidden */
  45342. export var pbrIBLFunctions: {
  45343. name: string;
  45344. shader: string;
  45345. };
  45346. }
  45347. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  45348. /** @hidden */
  45349. export var pbrDebug: {
  45350. name: string;
  45351. shader: string;
  45352. };
  45353. }
  45354. declare module "babylonjs/Shaders/pbr.fragment" {
  45355. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  45356. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  45357. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  45358. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45359. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45360. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  45361. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  45362. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  45363. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  45364. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  45365. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45366. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  45367. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  45368. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  45369. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  45370. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  45371. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  45372. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  45373. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  45374. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  45375. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  45376. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  45377. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  45378. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  45379. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  45380. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  45381. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  45382. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  45383. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  45384. /** @hidden */
  45385. export var pbrPixelShader: {
  45386. name: string;
  45387. shader: string;
  45388. };
  45389. }
  45390. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  45391. /** @hidden */
  45392. export var pbrVertexDeclaration: {
  45393. name: string;
  45394. shader: string;
  45395. };
  45396. }
  45397. declare module "babylonjs/Shaders/pbr.vertex" {
  45398. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  45399. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  45400. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45401. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45402. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45403. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  45404. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  45405. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  45406. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  45407. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45408. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45409. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  45410. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  45411. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  45412. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  45413. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45414. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45415. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  45416. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  45417. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  45418. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  45419. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  45420. /** @hidden */
  45421. export var pbrVertexShader: {
  45422. name: string;
  45423. shader: string;
  45424. };
  45425. }
  45426. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  45427. import { IAnimatable } from "babylonjs/Misc/tools";
  45428. import { Nullable } from "babylonjs/types";
  45429. import { Scene } from "babylonjs/scene";
  45430. import { Matrix, Color3 } from "babylonjs/Maths/math";
  45431. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45432. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45433. import { Mesh } from "babylonjs/Meshes/mesh";
  45434. import { PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  45435. import { PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  45436. import { PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  45437. import { PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  45438. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45439. import { Material } from "babylonjs/Materials/material";
  45440. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  45441. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45442. import "babylonjs/Shaders/pbr.fragment";
  45443. import "babylonjs/Shaders/pbr.vertex";
  45444. /**
  45445. * The Physically based material base class of BJS.
  45446. *
  45447. * This offers the main features of a standard PBR material.
  45448. * For more information, please refer to the documentation :
  45449. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45450. */
  45451. export abstract class PBRBaseMaterial extends PushMaterial {
  45452. /**
  45453. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45454. */
  45455. static readonly PBRMATERIAL_OPAQUE: number;
  45456. /**
  45457. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45458. */
  45459. static readonly PBRMATERIAL_ALPHATEST: number;
  45460. /**
  45461. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45462. */
  45463. static readonly PBRMATERIAL_ALPHABLEND: number;
  45464. /**
  45465. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45466. * They are also discarded below the alpha cutoff threshold to improve performances.
  45467. */
  45468. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45469. /**
  45470. * Defines the default value of how much AO map is occluding the analytical lights
  45471. * (point spot...).
  45472. */
  45473. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45474. /**
  45475. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45476. */
  45477. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45478. /**
  45479. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45480. * to enhance interoperability with other engines.
  45481. */
  45482. static readonly LIGHTFALLOFF_GLTF: number;
  45483. /**
  45484. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45485. * to enhance interoperability with other materials.
  45486. */
  45487. static readonly LIGHTFALLOFF_STANDARD: number;
  45488. /**
  45489. * Intensity of the direct lights e.g. the four lights available in your scene.
  45490. * This impacts both the direct diffuse and specular highlights.
  45491. */
  45492. protected _directIntensity: number;
  45493. /**
  45494. * Intensity of the emissive part of the material.
  45495. * This helps controlling the emissive effect without modifying the emissive color.
  45496. */
  45497. protected _emissiveIntensity: number;
  45498. /**
  45499. * Intensity of the environment e.g. how much the environment will light the object
  45500. * either through harmonics for rough material or through the refelction for shiny ones.
  45501. */
  45502. protected _environmentIntensity: number;
  45503. /**
  45504. * This is a special control allowing the reduction of the specular highlights coming from the
  45505. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45506. */
  45507. protected _specularIntensity: number;
  45508. /**
  45509. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45510. */
  45511. private _lightingInfos;
  45512. /**
  45513. * Debug Control allowing disabling the bump map on this material.
  45514. */
  45515. protected _disableBumpMap: boolean;
  45516. /**
  45517. * AKA Diffuse Texture in standard nomenclature.
  45518. */
  45519. protected _albedoTexture: BaseTexture;
  45520. /**
  45521. * AKA Occlusion Texture in other nomenclature.
  45522. */
  45523. protected _ambientTexture: BaseTexture;
  45524. /**
  45525. * AKA Occlusion Texture Intensity in other nomenclature.
  45526. */
  45527. protected _ambientTextureStrength: number;
  45528. /**
  45529. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45530. * 1 means it completely occludes it
  45531. * 0 mean it has no impact
  45532. */
  45533. protected _ambientTextureImpactOnAnalyticalLights: number;
  45534. /**
  45535. * Stores the alpha values in a texture.
  45536. */
  45537. protected _opacityTexture: BaseTexture;
  45538. /**
  45539. * Stores the reflection values in a texture.
  45540. */
  45541. protected _reflectionTexture: BaseTexture;
  45542. /**
  45543. * Stores the refraction values in a texture.
  45544. */
  45545. protected _refractionTexture: BaseTexture;
  45546. /**
  45547. * Stores the emissive values in a texture.
  45548. */
  45549. protected _emissiveTexture: BaseTexture;
  45550. /**
  45551. * AKA Specular texture in other nomenclature.
  45552. */
  45553. protected _reflectivityTexture: BaseTexture;
  45554. /**
  45555. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45556. */
  45557. protected _metallicTexture: BaseTexture;
  45558. /**
  45559. * Specifies the metallic scalar of the metallic/roughness workflow.
  45560. * Can also be used to scale the metalness values of the metallic texture.
  45561. */
  45562. protected _metallic: Nullable<number>;
  45563. /**
  45564. * Specifies the roughness scalar of the metallic/roughness workflow.
  45565. * Can also be used to scale the roughness values of the metallic texture.
  45566. */
  45567. protected _roughness: Nullable<number>;
  45568. /**
  45569. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45570. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45571. */
  45572. protected _microSurfaceTexture: BaseTexture;
  45573. /**
  45574. * Stores surface normal data used to displace a mesh in a texture.
  45575. */
  45576. protected _bumpTexture: BaseTexture;
  45577. /**
  45578. * Stores the pre-calculated light information of a mesh in a texture.
  45579. */
  45580. protected _lightmapTexture: BaseTexture;
  45581. /**
  45582. * The color of a material in ambient lighting.
  45583. */
  45584. protected _ambientColor: Color3;
  45585. /**
  45586. * AKA Diffuse Color in other nomenclature.
  45587. */
  45588. protected _albedoColor: Color3;
  45589. /**
  45590. * AKA Specular Color in other nomenclature.
  45591. */
  45592. protected _reflectivityColor: Color3;
  45593. /**
  45594. * The color applied when light is reflected from a material.
  45595. */
  45596. protected _reflectionColor: Color3;
  45597. /**
  45598. * The color applied when light is emitted from a material.
  45599. */
  45600. protected _emissiveColor: Color3;
  45601. /**
  45602. * AKA Glossiness in other nomenclature.
  45603. */
  45604. protected _microSurface: number;
  45605. /**
  45606. * source material index of refraction (IOR)' / 'destination material IOR.
  45607. */
  45608. protected _indexOfRefraction: number;
  45609. /**
  45610. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45611. */
  45612. protected _invertRefractionY: boolean;
  45613. /**
  45614. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45615. * Materials half opaque for instance using refraction could benefit from this control.
  45616. */
  45617. protected _linkRefractionWithTransparency: boolean;
  45618. /**
  45619. * Specifies that the material will use the light map as a show map.
  45620. */
  45621. protected _useLightmapAsShadowmap: boolean;
  45622. /**
  45623. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45624. * makes the reflect vector face the model (under horizon).
  45625. */
  45626. protected _useHorizonOcclusion: boolean;
  45627. /**
  45628. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45629. * too much the area relying on ambient texture to define their ambient occlusion.
  45630. */
  45631. protected _useRadianceOcclusion: boolean;
  45632. /**
  45633. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45634. */
  45635. protected _useAlphaFromAlbedoTexture: boolean;
  45636. /**
  45637. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45638. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45639. */
  45640. protected _useSpecularOverAlpha: boolean;
  45641. /**
  45642. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45643. */
  45644. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45645. /**
  45646. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45647. */
  45648. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45649. /**
  45650. * Specifies if the metallic texture contains the roughness information in its green channel.
  45651. */
  45652. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45653. /**
  45654. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45655. */
  45656. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45657. /**
  45658. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45659. */
  45660. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45661. /**
  45662. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45663. */
  45664. protected _useAmbientInGrayScale: boolean;
  45665. /**
  45666. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45667. * The material will try to infer what glossiness each pixel should be.
  45668. */
  45669. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45670. /**
  45671. * Defines the falloff type used in this material.
  45672. * It by default is Physical.
  45673. */
  45674. protected _lightFalloff: number;
  45675. /**
  45676. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45677. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45678. */
  45679. protected _useRadianceOverAlpha: boolean;
  45680. /**
  45681. * Allows using an object space normal map (instead of tangent space).
  45682. */
  45683. protected _useObjectSpaceNormalMap: boolean;
  45684. /**
  45685. * Allows using the bump map in parallax mode.
  45686. */
  45687. protected _useParallax: boolean;
  45688. /**
  45689. * Allows using the bump map in parallax occlusion mode.
  45690. */
  45691. protected _useParallaxOcclusion: boolean;
  45692. /**
  45693. * Controls the scale bias of the parallax mode.
  45694. */
  45695. protected _parallaxScaleBias: number;
  45696. /**
  45697. * If sets to true, disables all the lights affecting the material.
  45698. */
  45699. protected _disableLighting: boolean;
  45700. /**
  45701. * Number of Simultaneous lights allowed on the material.
  45702. */
  45703. protected _maxSimultaneousLights: number;
  45704. /**
  45705. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45706. */
  45707. protected _invertNormalMapX: boolean;
  45708. /**
  45709. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45710. */
  45711. protected _invertNormalMapY: boolean;
  45712. /**
  45713. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45714. */
  45715. protected _twoSidedLighting: boolean;
  45716. /**
  45717. * Defines the alpha limits in alpha test mode.
  45718. */
  45719. protected _alphaCutOff: number;
  45720. /**
  45721. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45722. */
  45723. protected _forceAlphaTest: boolean;
  45724. /**
  45725. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45726. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45727. */
  45728. protected _useAlphaFresnel: boolean;
  45729. /**
  45730. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45731. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45732. */
  45733. protected _useLinearAlphaFresnel: boolean;
  45734. /**
  45735. * The transparency mode of the material.
  45736. */
  45737. protected _transparencyMode: Nullable<number>;
  45738. /**
  45739. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45740. * from cos thetav and roughness:
  45741. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45742. */
  45743. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45744. /**
  45745. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45746. */
  45747. protected _forceIrradianceInFragment: boolean;
  45748. /**
  45749. * Force normal to face away from face.
  45750. */
  45751. protected _forceNormalForward: boolean;
  45752. /**
  45753. * Enables specular anti aliasing in the PBR shader.
  45754. * It will both interacts on the Geometry for analytical and IBL lighting.
  45755. * It also prefilter the roughness map based on the bump values.
  45756. */
  45757. protected _enableSpecularAntiAliasing: boolean;
  45758. /**
  45759. * Default configuration related to image processing available in the PBR Material.
  45760. */
  45761. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45762. /**
  45763. * Keep track of the image processing observer to allow dispose and replace.
  45764. */
  45765. private _imageProcessingObserver;
  45766. /**
  45767. * Attaches a new image processing configuration to the PBR Material.
  45768. * @param configuration
  45769. */
  45770. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45771. /**
  45772. * Stores the available render targets.
  45773. */
  45774. private _renderTargets;
  45775. /**
  45776. * Sets the global ambient color for the material used in lighting calculations.
  45777. */
  45778. private _globalAmbientColor;
  45779. /**
  45780. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45781. */
  45782. private _useLogarithmicDepth;
  45783. /**
  45784. * If set to true, no lighting calculations will be applied.
  45785. */
  45786. private _unlit;
  45787. private _debugMode;
  45788. /**
  45789. * @hidden
  45790. * This is reserved for the inspector.
  45791. * Defines the material debug mode.
  45792. * It helps seeing only some components of the material while troubleshooting.
  45793. */
  45794. debugMode: number;
  45795. /**
  45796. * @hidden
  45797. * This is reserved for the inspector.
  45798. * Specify from where on screen the debug mode should start.
  45799. * The value goes from -1 (full screen) to 1 (not visible)
  45800. * It helps with side by side comparison against the final render
  45801. * This defaults to -1
  45802. */
  45803. private debugLimit;
  45804. /**
  45805. * @hidden
  45806. * This is reserved for the inspector.
  45807. * As the default viewing range might not be enough (if the ambient is really small for instance)
  45808. * You can use the factor to better multiply the final value.
  45809. */
  45810. private debugFactor;
  45811. /**
  45812. * Defines the clear coat layer parameters for the material.
  45813. */
  45814. readonly clearCoat: PBRClearCoatConfiguration;
  45815. /**
  45816. * Defines the anisotropic parameters for the material.
  45817. */
  45818. readonly anisotropy: PBRAnisotropicConfiguration;
  45819. /**
  45820. * Defines the BRDF parameters for the material.
  45821. */
  45822. readonly brdf: PBRBRDFConfiguration;
  45823. /**
  45824. * Defines the Sheen parameters for the material.
  45825. */
  45826. readonly sheen: PBRSheenConfiguration;
  45827. /**
  45828. * Instantiates a new PBRMaterial instance.
  45829. *
  45830. * @param name The material name
  45831. * @param scene The scene the material will be use in.
  45832. */
  45833. constructor(name: string, scene: Scene);
  45834. /**
  45835. * Gets a boolean indicating that current material needs to register RTT
  45836. */
  45837. readonly hasRenderTargetTextures: boolean;
  45838. /**
  45839. * Gets the name of the material class.
  45840. */
  45841. getClassName(): string;
  45842. /**
  45843. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45844. */
  45845. /**
  45846. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45847. */
  45848. useLogarithmicDepth: boolean;
  45849. /**
  45850. * Gets the current transparency mode.
  45851. */
  45852. /**
  45853. * Sets the transparency mode of the material.
  45854. *
  45855. * | Value | Type | Description |
  45856. * | ----- | ----------------------------------- | ----------- |
  45857. * | 0 | OPAQUE | |
  45858. * | 1 | ALPHATEST | |
  45859. * | 2 | ALPHABLEND | |
  45860. * | 3 | ALPHATESTANDBLEND | |
  45861. *
  45862. */
  45863. transparencyMode: Nullable<number>;
  45864. /**
  45865. * Returns true if alpha blending should be disabled.
  45866. */
  45867. private readonly _disableAlphaBlending;
  45868. /**
  45869. * Specifies whether or not this material should be rendered in alpha blend mode.
  45870. */
  45871. needAlphaBlending(): boolean;
  45872. /**
  45873. * Specifies if the mesh will require alpha blending.
  45874. * @param mesh - BJS mesh.
  45875. */
  45876. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45877. /**
  45878. * Specifies whether or not this material should be rendered in alpha test mode.
  45879. */
  45880. needAlphaTesting(): boolean;
  45881. /**
  45882. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45883. */
  45884. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45885. /**
  45886. * Gets the texture used for the alpha test.
  45887. */
  45888. getAlphaTestTexture(): BaseTexture;
  45889. /**
  45890. * Specifies that the submesh is ready to be used.
  45891. * @param mesh - BJS mesh.
  45892. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45893. * @param useInstances - Specifies that instances should be used.
  45894. * @returns - boolean indicating that the submesh is ready or not.
  45895. */
  45896. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45897. /**
  45898. * Specifies if the material uses metallic roughness workflow.
  45899. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45900. */
  45901. isMetallicWorkflow(): boolean;
  45902. private _prepareEffect;
  45903. private _prepareDefines;
  45904. /**
  45905. * Force shader compilation
  45906. */
  45907. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45908. clipPlane: boolean;
  45909. }>): void;
  45910. /**
  45911. * Initializes the uniform buffer layout for the shader.
  45912. */
  45913. buildUniformLayout(): void;
  45914. /**
  45915. * Unbinds the textures.
  45916. */
  45917. unbind(): void;
  45918. /**
  45919. * Binds the submesh data.
  45920. * @param world - The world matrix.
  45921. * @param mesh - The BJS mesh.
  45922. * @param subMesh - A submesh of the BJS mesh.
  45923. */
  45924. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45925. /**
  45926. * Returns the animatable textures.
  45927. * @returns - Array of animatable textures.
  45928. */
  45929. getAnimatables(): IAnimatable[];
  45930. /**
  45931. * Returns the texture used for reflections.
  45932. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45933. */
  45934. private _getReflectionTexture;
  45935. /**
  45936. * Returns the texture used for refraction or null if none is used.
  45937. * @returns - Refection texture if present. If no refraction texture and refraction
  45938. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45939. */
  45940. private _getRefractionTexture;
  45941. /**
  45942. * Returns an array of the actively used textures.
  45943. * @returns - Array of BaseTextures
  45944. */
  45945. getActiveTextures(): BaseTexture[];
  45946. /**
  45947. * Checks to see if a texture is used in the material.
  45948. * @param texture - Base texture to use.
  45949. * @returns - Boolean specifying if a texture is used in the material.
  45950. */
  45951. hasTexture(texture: BaseTexture): boolean;
  45952. /**
  45953. * Disposes the resources of the material.
  45954. * @param forceDisposeEffect - Forces the disposal of effects.
  45955. * @param forceDisposeTextures - Forces the disposal of all textures.
  45956. */
  45957. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45958. }
  45959. }
  45960. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  45961. import { Nullable } from "babylonjs/types";
  45962. import { Scene } from "babylonjs/scene";
  45963. import { Color3 } from "babylonjs/Maths/math";
  45964. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45965. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45966. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45967. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  45968. /**
  45969. * The Physically based material of BJS.
  45970. *
  45971. * This offers the main features of a standard PBR material.
  45972. * For more information, please refer to the documentation :
  45973. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45974. */
  45975. export class PBRMaterial extends PBRBaseMaterial {
  45976. /**
  45977. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45978. */
  45979. static readonly PBRMATERIAL_OPAQUE: number;
  45980. /**
  45981. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45982. */
  45983. static readonly PBRMATERIAL_ALPHATEST: number;
  45984. /**
  45985. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45986. */
  45987. static readonly PBRMATERIAL_ALPHABLEND: number;
  45988. /**
  45989. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45990. * They are also discarded below the alpha cutoff threshold to improve performances.
  45991. */
  45992. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45993. /**
  45994. * Defines the default value of how much AO map is occluding the analytical lights
  45995. * (point spot...).
  45996. */
  45997. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45998. /**
  45999. * Intensity of the direct lights e.g. the four lights available in your scene.
  46000. * This impacts both the direct diffuse and specular highlights.
  46001. */
  46002. directIntensity: number;
  46003. /**
  46004. * Intensity of the emissive part of the material.
  46005. * This helps controlling the emissive effect without modifying the emissive color.
  46006. */
  46007. emissiveIntensity: number;
  46008. /**
  46009. * Intensity of the environment e.g. how much the environment will light the object
  46010. * either through harmonics for rough material or through the refelction for shiny ones.
  46011. */
  46012. environmentIntensity: number;
  46013. /**
  46014. * This is a special control allowing the reduction of the specular highlights coming from the
  46015. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46016. */
  46017. specularIntensity: number;
  46018. /**
  46019. * Debug Control allowing disabling the bump map on this material.
  46020. */
  46021. disableBumpMap: boolean;
  46022. /**
  46023. * AKA Diffuse Texture in standard nomenclature.
  46024. */
  46025. albedoTexture: BaseTexture;
  46026. /**
  46027. * AKA Occlusion Texture in other nomenclature.
  46028. */
  46029. ambientTexture: BaseTexture;
  46030. /**
  46031. * AKA Occlusion Texture Intensity in other nomenclature.
  46032. */
  46033. ambientTextureStrength: number;
  46034. /**
  46035. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46036. * 1 means it completely occludes it
  46037. * 0 mean it has no impact
  46038. */
  46039. ambientTextureImpactOnAnalyticalLights: number;
  46040. /**
  46041. * Stores the alpha values in a texture.
  46042. */
  46043. opacityTexture: BaseTexture;
  46044. /**
  46045. * Stores the reflection values in a texture.
  46046. */
  46047. reflectionTexture: Nullable<BaseTexture>;
  46048. /**
  46049. * Stores the emissive values in a texture.
  46050. */
  46051. emissiveTexture: BaseTexture;
  46052. /**
  46053. * AKA Specular texture in other nomenclature.
  46054. */
  46055. reflectivityTexture: BaseTexture;
  46056. /**
  46057. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46058. */
  46059. metallicTexture: BaseTexture;
  46060. /**
  46061. * Specifies the metallic scalar of the metallic/roughness workflow.
  46062. * Can also be used to scale the metalness values of the metallic texture.
  46063. */
  46064. metallic: Nullable<number>;
  46065. /**
  46066. * Specifies the roughness scalar of the metallic/roughness workflow.
  46067. * Can also be used to scale the roughness values of the metallic texture.
  46068. */
  46069. roughness: Nullable<number>;
  46070. /**
  46071. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46072. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46073. */
  46074. microSurfaceTexture: BaseTexture;
  46075. /**
  46076. * Stores surface normal data used to displace a mesh in a texture.
  46077. */
  46078. bumpTexture: BaseTexture;
  46079. /**
  46080. * Stores the pre-calculated light information of a mesh in a texture.
  46081. */
  46082. lightmapTexture: BaseTexture;
  46083. /**
  46084. * Stores the refracted light information in a texture.
  46085. */
  46086. refractionTexture: BaseTexture;
  46087. /**
  46088. * The color of a material in ambient lighting.
  46089. */
  46090. ambientColor: Color3;
  46091. /**
  46092. * AKA Diffuse Color in other nomenclature.
  46093. */
  46094. albedoColor: Color3;
  46095. /**
  46096. * AKA Specular Color in other nomenclature.
  46097. */
  46098. reflectivityColor: Color3;
  46099. /**
  46100. * The color reflected from the material.
  46101. */
  46102. reflectionColor: Color3;
  46103. /**
  46104. * The color emitted from the material.
  46105. */
  46106. emissiveColor: Color3;
  46107. /**
  46108. * AKA Glossiness in other nomenclature.
  46109. */
  46110. microSurface: number;
  46111. /**
  46112. * source material index of refraction (IOR)' / 'destination material IOR.
  46113. */
  46114. indexOfRefraction: number;
  46115. /**
  46116. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46117. */
  46118. invertRefractionY: boolean;
  46119. /**
  46120. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46121. * Materials half opaque for instance using refraction could benefit from this control.
  46122. */
  46123. linkRefractionWithTransparency: boolean;
  46124. /**
  46125. * If true, the light map contains occlusion information instead of lighting info.
  46126. */
  46127. useLightmapAsShadowmap: boolean;
  46128. /**
  46129. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46130. */
  46131. useAlphaFromAlbedoTexture: boolean;
  46132. /**
  46133. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46134. */
  46135. forceAlphaTest: boolean;
  46136. /**
  46137. * Defines the alpha limits in alpha test mode.
  46138. */
  46139. alphaCutOff: number;
  46140. /**
  46141. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  46142. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46143. */
  46144. useSpecularOverAlpha: boolean;
  46145. /**
  46146. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46147. */
  46148. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46149. /**
  46150. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46151. */
  46152. useRoughnessFromMetallicTextureAlpha: boolean;
  46153. /**
  46154. * Specifies if the metallic texture contains the roughness information in its green channel.
  46155. */
  46156. useRoughnessFromMetallicTextureGreen: boolean;
  46157. /**
  46158. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46159. */
  46160. useMetallnessFromMetallicTextureBlue: boolean;
  46161. /**
  46162. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46163. */
  46164. useAmbientOcclusionFromMetallicTextureRed: boolean;
  46165. /**
  46166. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46167. */
  46168. useAmbientInGrayScale: boolean;
  46169. /**
  46170. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46171. * The material will try to infer what glossiness each pixel should be.
  46172. */
  46173. useAutoMicroSurfaceFromReflectivityMap: boolean;
  46174. /**
  46175. * BJS is using an harcoded light falloff based on a manually sets up range.
  46176. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46177. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46178. */
  46179. /**
  46180. * BJS is using an harcoded light falloff based on a manually sets up range.
  46181. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46182. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46183. */
  46184. usePhysicalLightFalloff: boolean;
  46185. /**
  46186. * In order to support the falloff compatibility with gltf, a special mode has been added
  46187. * to reproduce the gltf light falloff.
  46188. */
  46189. /**
  46190. * In order to support the falloff compatibility with gltf, a special mode has been added
  46191. * to reproduce the gltf light falloff.
  46192. */
  46193. useGLTFLightFalloff: boolean;
  46194. /**
  46195. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46196. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46197. */
  46198. useRadianceOverAlpha: boolean;
  46199. /**
  46200. * Allows using an object space normal map (instead of tangent space).
  46201. */
  46202. useObjectSpaceNormalMap: boolean;
  46203. /**
  46204. * Allows using the bump map in parallax mode.
  46205. */
  46206. useParallax: boolean;
  46207. /**
  46208. * Allows using the bump map in parallax occlusion mode.
  46209. */
  46210. useParallaxOcclusion: boolean;
  46211. /**
  46212. * Controls the scale bias of the parallax mode.
  46213. */
  46214. parallaxScaleBias: number;
  46215. /**
  46216. * If sets to true, disables all the lights affecting the material.
  46217. */
  46218. disableLighting: boolean;
  46219. /**
  46220. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46221. */
  46222. forceIrradianceInFragment: boolean;
  46223. /**
  46224. * Number of Simultaneous lights allowed on the material.
  46225. */
  46226. maxSimultaneousLights: number;
  46227. /**
  46228. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  46229. */
  46230. invertNormalMapX: boolean;
  46231. /**
  46232. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  46233. */
  46234. invertNormalMapY: boolean;
  46235. /**
  46236. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46237. */
  46238. twoSidedLighting: boolean;
  46239. /**
  46240. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46241. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46242. */
  46243. useAlphaFresnel: boolean;
  46244. /**
  46245. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46246. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46247. */
  46248. useLinearAlphaFresnel: boolean;
  46249. /**
  46250. * Let user defines the brdf lookup texture used for IBL.
  46251. * A default 8bit version is embedded but you could point at :
  46252. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  46253. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  46254. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46255. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  46256. */
  46257. environmentBRDFTexture: Nullable<BaseTexture>;
  46258. /**
  46259. * Force normal to face away from face.
  46260. */
  46261. forceNormalForward: boolean;
  46262. /**
  46263. * Enables specular anti aliasing in the PBR shader.
  46264. * It will both interacts on the Geometry for analytical and IBL lighting.
  46265. * It also prefilter the roughness map based on the bump values.
  46266. */
  46267. enableSpecularAntiAliasing: boolean;
  46268. /**
  46269. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46270. * makes the reflect vector face the model (under horizon).
  46271. */
  46272. useHorizonOcclusion: boolean;
  46273. /**
  46274. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46275. * too much the area relying on ambient texture to define their ambient occlusion.
  46276. */
  46277. useRadianceOcclusion: boolean;
  46278. /**
  46279. * If set to true, no lighting calculations will be applied.
  46280. */
  46281. unlit: boolean;
  46282. /**
  46283. * Gets the image processing configuration used either in this material.
  46284. */
  46285. /**
  46286. * Sets the Default image processing configuration used either in the this material.
  46287. *
  46288. * If sets to null, the scene one is in use.
  46289. */
  46290. imageProcessingConfiguration: ImageProcessingConfiguration;
  46291. /**
  46292. * Gets wether the color curves effect is enabled.
  46293. */
  46294. /**
  46295. * Sets wether the color curves effect is enabled.
  46296. */
  46297. cameraColorCurvesEnabled: boolean;
  46298. /**
  46299. * Gets wether the color grading effect is enabled.
  46300. */
  46301. /**
  46302. * Gets wether the color grading effect is enabled.
  46303. */
  46304. cameraColorGradingEnabled: boolean;
  46305. /**
  46306. * Gets wether tonemapping is enabled or not.
  46307. */
  46308. /**
  46309. * Sets wether tonemapping is enabled or not
  46310. */
  46311. cameraToneMappingEnabled: boolean;
  46312. /**
  46313. * The camera exposure used on this material.
  46314. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46315. * This corresponds to a photographic exposure.
  46316. */
  46317. /**
  46318. * The camera exposure used on this material.
  46319. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46320. * This corresponds to a photographic exposure.
  46321. */
  46322. cameraExposure: number;
  46323. /**
  46324. * Gets The camera contrast used on this material.
  46325. */
  46326. /**
  46327. * Sets The camera contrast used on this material.
  46328. */
  46329. cameraContrast: number;
  46330. /**
  46331. * Gets the Color Grading 2D Lookup Texture.
  46332. */
  46333. /**
  46334. * Sets the Color Grading 2D Lookup Texture.
  46335. */
  46336. cameraColorGradingTexture: Nullable<BaseTexture>;
  46337. /**
  46338. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46339. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46340. * 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;
  46341. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46342. */
  46343. /**
  46344. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46345. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46346. * 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;
  46347. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46348. */
  46349. cameraColorCurves: Nullable<ColorCurves>;
  46350. /**
  46351. * Instantiates a new PBRMaterial instance.
  46352. *
  46353. * @param name The material name
  46354. * @param scene The scene the material will be use in.
  46355. */
  46356. constructor(name: string, scene: Scene);
  46357. /**
  46358. * Returns the name of this material class.
  46359. */
  46360. getClassName(): string;
  46361. /**
  46362. * Makes a duplicate of the current material.
  46363. * @param name - name to use for the new material.
  46364. */
  46365. clone(name: string): PBRMaterial;
  46366. /**
  46367. * Serializes this PBR Material.
  46368. * @returns - An object with the serialized material.
  46369. */
  46370. serialize(): any;
  46371. /**
  46372. * Parses a PBR Material from a serialized object.
  46373. * @param source - Serialized object.
  46374. * @param scene - BJS scene instance.
  46375. * @param rootUrl - url for the scene object
  46376. * @returns - PBRMaterial
  46377. */
  46378. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  46379. }
  46380. }
  46381. declare module "babylonjs/Misc/dds" {
  46382. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46383. import { Engine } from "babylonjs/Engines/engine";
  46384. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46385. import { Nullable } from "babylonjs/types";
  46386. import { Scene } from "babylonjs/scene";
  46387. /**
  46388. * Direct draw surface info
  46389. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  46390. */
  46391. export interface DDSInfo {
  46392. /**
  46393. * Width of the texture
  46394. */
  46395. width: number;
  46396. /**
  46397. * Width of the texture
  46398. */
  46399. height: number;
  46400. /**
  46401. * Number of Mipmaps for the texture
  46402. * @see https://en.wikipedia.org/wiki/Mipmap
  46403. */
  46404. mipmapCount: number;
  46405. /**
  46406. * If the textures format is a known fourCC format
  46407. * @see https://www.fourcc.org/
  46408. */
  46409. isFourCC: boolean;
  46410. /**
  46411. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  46412. */
  46413. isRGB: boolean;
  46414. /**
  46415. * If the texture is a lumincance format
  46416. */
  46417. isLuminance: boolean;
  46418. /**
  46419. * If this is a cube texture
  46420. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  46421. */
  46422. isCube: boolean;
  46423. /**
  46424. * If the texture is a compressed format eg. FOURCC_DXT1
  46425. */
  46426. isCompressed: boolean;
  46427. /**
  46428. * The dxgiFormat of the texture
  46429. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  46430. */
  46431. dxgiFormat: number;
  46432. /**
  46433. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  46434. */
  46435. textureType: number;
  46436. /**
  46437. * Sphericle polynomial created for the dds texture
  46438. */
  46439. sphericalPolynomial?: SphericalPolynomial;
  46440. }
  46441. /**
  46442. * Class used to provide DDS decompression tools
  46443. */
  46444. export class DDSTools {
  46445. /**
  46446. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  46447. */
  46448. static StoreLODInAlphaChannel: boolean;
  46449. /**
  46450. * Gets DDS information from an array buffer
  46451. * @param arrayBuffer defines the array buffer to read data from
  46452. * @returns the DDS information
  46453. */
  46454. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  46455. private static _FloatView;
  46456. private static _Int32View;
  46457. private static _ToHalfFloat;
  46458. private static _FromHalfFloat;
  46459. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  46460. private static _GetHalfFloatRGBAArrayBuffer;
  46461. private static _GetFloatRGBAArrayBuffer;
  46462. private static _GetFloatAsUIntRGBAArrayBuffer;
  46463. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  46464. private static _GetRGBAArrayBuffer;
  46465. private static _ExtractLongWordOrder;
  46466. private static _GetRGBArrayBuffer;
  46467. private static _GetLuminanceArrayBuffer;
  46468. /**
  46469. * Uploads DDS Levels to a Babylon Texture
  46470. * @hidden
  46471. */
  46472. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  46473. }
  46474. module "babylonjs/Engines/engine" {
  46475. interface Engine {
  46476. /**
  46477. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  46478. * @param rootUrl defines the url where the file to load is located
  46479. * @param scene defines the current scene
  46480. * @param lodScale defines scale to apply to the mip map selection
  46481. * @param lodOffset defines offset to apply to the mip map selection
  46482. * @param onLoad defines an optional callback raised when the texture is loaded
  46483. * @param onError defines an optional callback raised if there is an issue to load the texture
  46484. * @param format defines the format of the data
  46485. * @param forcedExtension defines the extension to use to pick the right loader
  46486. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  46487. * @returns the cube texture as an InternalTexture
  46488. */
  46489. 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;
  46490. }
  46491. }
  46492. }
  46493. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  46494. import { Nullable } from "babylonjs/types";
  46495. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46496. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46497. /**
  46498. * Implementation of the DDS Texture Loader.
  46499. * @hidden
  46500. */
  46501. export class _DDSTextureLoader implements IInternalTextureLoader {
  46502. /**
  46503. * Defines wether the loader supports cascade loading the different faces.
  46504. */
  46505. readonly supportCascades: boolean;
  46506. /**
  46507. * This returns if the loader support the current file information.
  46508. * @param extension defines the file extension of the file being loaded
  46509. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46510. * @param fallback defines the fallback internal texture if any
  46511. * @param isBase64 defines whether the texture is encoded as a base64
  46512. * @param isBuffer defines whether the texture data are stored as a buffer
  46513. * @returns true if the loader can load the specified file
  46514. */
  46515. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46516. /**
  46517. * Transform the url before loading if required.
  46518. * @param rootUrl the url of the texture
  46519. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46520. * @returns the transformed texture
  46521. */
  46522. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46523. /**
  46524. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46525. * @param rootUrl the url of the texture
  46526. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46527. * @returns the fallback texture
  46528. */
  46529. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46530. /**
  46531. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46532. * @param data contains the texture data
  46533. * @param texture defines the BabylonJS internal texture
  46534. * @param createPolynomials will be true if polynomials have been requested
  46535. * @param onLoad defines the callback to trigger once the texture is ready
  46536. * @param onError defines the callback to trigger in case of error
  46537. */
  46538. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46539. /**
  46540. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46541. * @param data contains the texture data
  46542. * @param texture defines the BabylonJS internal texture
  46543. * @param callback defines the method to call once ready to upload
  46544. */
  46545. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46546. }
  46547. }
  46548. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46549. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46550. /** @hidden */
  46551. export var rgbdEncodePixelShader: {
  46552. name: string;
  46553. shader: string;
  46554. };
  46555. }
  46556. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46557. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46558. /** @hidden */
  46559. export var rgbdDecodePixelShader: {
  46560. name: string;
  46561. shader: string;
  46562. };
  46563. }
  46564. declare module "babylonjs/Misc/environmentTextureTools" {
  46565. import { Nullable } from "babylonjs/types";
  46566. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46567. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46568. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46569. import "babylonjs/Shaders/rgbdEncode.fragment";
  46570. import "babylonjs/Shaders/rgbdDecode.fragment";
  46571. /**
  46572. * Raw texture data and descriptor sufficient for WebGL texture upload
  46573. */
  46574. export interface EnvironmentTextureInfo {
  46575. /**
  46576. * Version of the environment map
  46577. */
  46578. version: number;
  46579. /**
  46580. * Width of image
  46581. */
  46582. width: number;
  46583. /**
  46584. * Irradiance information stored in the file.
  46585. */
  46586. irradiance: any;
  46587. /**
  46588. * Specular information stored in the file.
  46589. */
  46590. specular: any;
  46591. }
  46592. /**
  46593. * Sets of helpers addressing the serialization and deserialization of environment texture
  46594. * stored in a BabylonJS env file.
  46595. * Those files are usually stored as .env files.
  46596. */
  46597. export class EnvironmentTextureTools {
  46598. /**
  46599. * Magic number identifying the env file.
  46600. */
  46601. private static _MagicBytes;
  46602. /**
  46603. * Gets the environment info from an env file.
  46604. * @param data The array buffer containing the .env bytes.
  46605. * @returns the environment file info (the json header) if successfully parsed.
  46606. */
  46607. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46608. /**
  46609. * Creates an environment texture from a loaded cube texture.
  46610. * @param texture defines the cube texture to convert in env file
  46611. * @return a promise containing the environment data if succesfull.
  46612. */
  46613. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46614. /**
  46615. * Creates a JSON representation of the spherical data.
  46616. * @param texture defines the texture containing the polynomials
  46617. * @return the JSON representation of the spherical info
  46618. */
  46619. private static _CreateEnvTextureIrradiance;
  46620. /**
  46621. * Uploads the texture info contained in the env file to the GPU.
  46622. * @param texture defines the internal texture to upload to
  46623. * @param arrayBuffer defines the buffer cotaining the data to load
  46624. * @param info defines the texture info retrieved through the GetEnvInfo method
  46625. * @returns a promise
  46626. */
  46627. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46628. /**
  46629. * Uploads the levels of image data to the GPU.
  46630. * @param texture defines the internal texture to upload to
  46631. * @param imageData defines the array buffer views of image data [mipmap][face]
  46632. * @returns a promise
  46633. */
  46634. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46635. /**
  46636. * Uploads spherical polynomials information to the texture.
  46637. * @param texture defines the texture we are trying to upload the information to
  46638. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46639. */
  46640. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46641. /** @hidden */
  46642. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46643. }
  46644. }
  46645. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  46646. import { Nullable } from "babylonjs/types";
  46647. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46648. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46649. /**
  46650. * Implementation of the ENV Texture Loader.
  46651. * @hidden
  46652. */
  46653. export class _ENVTextureLoader implements IInternalTextureLoader {
  46654. /**
  46655. * Defines wether the loader supports cascade loading the different faces.
  46656. */
  46657. readonly supportCascades: boolean;
  46658. /**
  46659. * This returns if the loader support the current file information.
  46660. * @param extension defines the file extension of the file being loaded
  46661. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46662. * @param fallback defines the fallback internal texture if any
  46663. * @param isBase64 defines whether the texture is encoded as a base64
  46664. * @param isBuffer defines whether the texture data are stored as a buffer
  46665. * @returns true if the loader can load the specified file
  46666. */
  46667. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46668. /**
  46669. * Transform the url before loading if required.
  46670. * @param rootUrl the url of the texture
  46671. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46672. * @returns the transformed texture
  46673. */
  46674. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46675. /**
  46676. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46677. * @param rootUrl the url of the texture
  46678. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46679. * @returns the fallback texture
  46680. */
  46681. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46682. /**
  46683. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46684. * @param data contains the texture data
  46685. * @param texture defines the BabylonJS internal texture
  46686. * @param createPolynomials will be true if polynomials have been requested
  46687. * @param onLoad defines the callback to trigger once the texture is ready
  46688. * @param onError defines the callback to trigger in case of error
  46689. */
  46690. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46691. /**
  46692. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46693. * @param data contains the texture data
  46694. * @param texture defines the BabylonJS internal texture
  46695. * @param callback defines the method to call once ready to upload
  46696. */
  46697. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46698. }
  46699. }
  46700. declare module "babylonjs/Misc/khronosTextureContainer" {
  46701. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46702. /**
  46703. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  46704. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  46705. */
  46706. export class KhronosTextureContainer {
  46707. /** contents of the KTX container file */
  46708. arrayBuffer: any;
  46709. private static HEADER_LEN;
  46710. private static COMPRESSED_2D;
  46711. private static COMPRESSED_3D;
  46712. private static TEX_2D;
  46713. private static TEX_3D;
  46714. /**
  46715. * Gets the openGL type
  46716. */
  46717. glType: number;
  46718. /**
  46719. * Gets the openGL type size
  46720. */
  46721. glTypeSize: number;
  46722. /**
  46723. * Gets the openGL format
  46724. */
  46725. glFormat: number;
  46726. /**
  46727. * Gets the openGL internal format
  46728. */
  46729. glInternalFormat: number;
  46730. /**
  46731. * Gets the base internal format
  46732. */
  46733. glBaseInternalFormat: number;
  46734. /**
  46735. * Gets image width in pixel
  46736. */
  46737. pixelWidth: number;
  46738. /**
  46739. * Gets image height in pixel
  46740. */
  46741. pixelHeight: number;
  46742. /**
  46743. * Gets image depth in pixels
  46744. */
  46745. pixelDepth: number;
  46746. /**
  46747. * Gets the number of array elements
  46748. */
  46749. numberOfArrayElements: number;
  46750. /**
  46751. * Gets the number of faces
  46752. */
  46753. numberOfFaces: number;
  46754. /**
  46755. * Gets the number of mipmap levels
  46756. */
  46757. numberOfMipmapLevels: number;
  46758. /**
  46759. * Gets the bytes of key value data
  46760. */
  46761. bytesOfKeyValueData: number;
  46762. /**
  46763. * Gets the load type
  46764. */
  46765. loadType: number;
  46766. /**
  46767. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46768. */
  46769. isInvalid: boolean;
  46770. /**
  46771. * Creates a new KhronosTextureContainer
  46772. * @param arrayBuffer contents of the KTX container file
  46773. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  46774. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  46775. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  46776. */
  46777. constructor(
  46778. /** contents of the KTX container file */
  46779. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  46780. /**
  46781. * Uploads KTX content to a Babylon Texture.
  46782. * It is assumed that the texture has already been created & is currently bound
  46783. * @hidden
  46784. */
  46785. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  46786. private _upload2DCompressedLevels;
  46787. }
  46788. }
  46789. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  46790. import { Nullable } from "babylonjs/types";
  46791. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46792. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46793. /**
  46794. * Implementation of the KTX Texture Loader.
  46795. * @hidden
  46796. */
  46797. export class _KTXTextureLoader implements IInternalTextureLoader {
  46798. /**
  46799. * Defines wether the loader supports cascade loading the different faces.
  46800. */
  46801. readonly supportCascades: boolean;
  46802. /**
  46803. * This returns if the loader support the current file information.
  46804. * @param extension defines the file extension of the file being loaded
  46805. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46806. * @param fallback defines the fallback internal texture if any
  46807. * @param isBase64 defines whether the texture is encoded as a base64
  46808. * @param isBuffer defines whether the texture data are stored as a buffer
  46809. * @returns true if the loader can load the specified file
  46810. */
  46811. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46812. /**
  46813. * Transform the url before loading if required.
  46814. * @param rootUrl the url of the texture
  46815. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46816. * @returns the transformed texture
  46817. */
  46818. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46819. /**
  46820. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46821. * @param rootUrl the url of the texture
  46822. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46823. * @returns the fallback texture
  46824. */
  46825. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46826. /**
  46827. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46828. * @param data contains the texture data
  46829. * @param texture defines the BabylonJS internal texture
  46830. * @param createPolynomials will be true if polynomials have been requested
  46831. * @param onLoad defines the callback to trigger once the texture is ready
  46832. * @param onError defines the callback to trigger in case of error
  46833. */
  46834. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46835. /**
  46836. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46837. * @param data contains the texture data
  46838. * @param texture defines the BabylonJS internal texture
  46839. * @param callback defines the method to call once ready to upload
  46840. */
  46841. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  46842. }
  46843. }
  46844. declare module "babylonjs/Helpers/sceneHelpers" {
  46845. import { Nullable } from "babylonjs/types";
  46846. import { Mesh } from "babylonjs/Meshes/mesh";
  46847. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46848. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  46849. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  46850. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  46851. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  46852. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  46853. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  46854. import "babylonjs/Meshes/Builders/boxBuilder";
  46855. /** @hidden */
  46856. export var _forceSceneHelpersToBundle: boolean;
  46857. module "babylonjs/scene" {
  46858. interface Scene {
  46859. /**
  46860. * Creates a default light for the scene.
  46861. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  46862. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  46863. */
  46864. createDefaultLight(replace?: boolean): void;
  46865. /**
  46866. * Creates a default camera for the scene.
  46867. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  46868. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46869. * @param replace has default false, when true replaces the active camera in the scene
  46870. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  46871. */
  46872. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46873. /**
  46874. * Creates a default camera and a default light.
  46875. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  46876. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46877. * @param replace has the default false, when true replaces the active camera/light in the scene
  46878. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  46879. */
  46880. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46881. /**
  46882. * Creates a new sky box
  46883. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  46884. * @param environmentTexture defines the texture to use as environment texture
  46885. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  46886. * @param scale defines the overall scale of the skybox
  46887. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  46888. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  46889. * @returns a new mesh holding the sky box
  46890. */
  46891. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  46892. /**
  46893. * Creates a new environment
  46894. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  46895. * @param options defines the options you can use to configure the environment
  46896. * @returns the new EnvironmentHelper
  46897. */
  46898. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  46899. /**
  46900. * Creates a new VREXperienceHelper
  46901. * @see http://doc.babylonjs.com/how_to/webvr_helper
  46902. * @param webVROptions defines the options used to create the new VREXperienceHelper
  46903. * @returns a new VREXperienceHelper
  46904. */
  46905. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  46906. /**
  46907. * Creates a new XREXperienceHelper
  46908. * @see http://doc.babylonjs.com/how_to/webxr
  46909. * @returns a promise for a new XREXperienceHelper
  46910. */
  46911. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  46912. }
  46913. }
  46914. }
  46915. declare module "babylonjs/Helpers/videoDome" {
  46916. import { Scene } from "babylonjs/scene";
  46917. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46918. import { Mesh } from "babylonjs/Meshes/mesh";
  46919. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  46920. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46921. import "babylonjs/Meshes/Builders/sphereBuilder";
  46922. /**
  46923. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  46924. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  46925. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  46926. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46927. */
  46928. export class VideoDome extends TransformNode {
  46929. /**
  46930. * Define the video source as a Monoscopic panoramic 360 video.
  46931. */
  46932. static readonly MODE_MONOSCOPIC: number;
  46933. /**
  46934. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46935. */
  46936. static readonly MODE_TOPBOTTOM: number;
  46937. /**
  46938. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46939. */
  46940. static readonly MODE_SIDEBYSIDE: number;
  46941. private _useDirectMapping;
  46942. /**
  46943. * The video texture being displayed on the sphere
  46944. */
  46945. protected _videoTexture: VideoTexture;
  46946. /**
  46947. * Gets the video texture being displayed on the sphere
  46948. */
  46949. readonly videoTexture: VideoTexture;
  46950. /**
  46951. * The skybox material
  46952. */
  46953. protected _material: BackgroundMaterial;
  46954. /**
  46955. * The surface used for the skybox
  46956. */
  46957. protected _mesh: Mesh;
  46958. /**
  46959. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46960. * Also see the options.resolution property.
  46961. */
  46962. fovMultiplier: number;
  46963. private _videoMode;
  46964. /**
  46965. * Gets or set the current video mode for the video. It can be:
  46966. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  46967. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46968. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46969. */
  46970. videoMode: number;
  46971. /**
  46972. * Oberserver used in Stereoscopic VR Mode.
  46973. */
  46974. private _onBeforeCameraRenderObserver;
  46975. /**
  46976. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  46977. * @param name Element's name, child elements will append suffixes for their own names.
  46978. * @param urlsOrVideo defines the url(s) or the video element to use
  46979. * @param options An object containing optional or exposed sub element properties
  46980. */
  46981. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  46982. resolution?: number;
  46983. clickToPlay?: boolean;
  46984. autoPlay?: boolean;
  46985. loop?: boolean;
  46986. size?: number;
  46987. poster?: string;
  46988. faceForward?: boolean;
  46989. useDirectMapping?: boolean;
  46990. }, scene: Scene);
  46991. private _changeVideoMode;
  46992. /**
  46993. * Releases resources associated with this node.
  46994. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46995. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46996. */
  46997. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46998. }
  46999. }
  47000. declare module "babylonjs/Helpers/index" {
  47001. export * from "babylonjs/Helpers/environmentHelper";
  47002. export * from "babylonjs/Helpers/photoDome";
  47003. export * from "babylonjs/Helpers/sceneHelpers";
  47004. export * from "babylonjs/Helpers/videoDome";
  47005. }
  47006. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  47007. import { PerfCounter } from "babylonjs/Misc/tools";
  47008. import { IDisposable } from "babylonjs/scene";
  47009. import { Engine } from "babylonjs/Engines/engine";
  47010. /**
  47011. * This class can be used to get instrumentation data from a Babylon engine
  47012. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47013. */
  47014. export class EngineInstrumentation implements IDisposable {
  47015. /**
  47016. * Define the instrumented engine.
  47017. */
  47018. engine: Engine;
  47019. private _captureGPUFrameTime;
  47020. private _gpuFrameTimeToken;
  47021. private _gpuFrameTime;
  47022. private _captureShaderCompilationTime;
  47023. private _shaderCompilationTime;
  47024. private _onBeginFrameObserver;
  47025. private _onEndFrameObserver;
  47026. private _onBeforeShaderCompilationObserver;
  47027. private _onAfterShaderCompilationObserver;
  47028. /**
  47029. * Gets the perf counter used for GPU frame time
  47030. */
  47031. readonly gpuFrameTimeCounter: PerfCounter;
  47032. /**
  47033. * Gets the GPU frame time capture status
  47034. */
  47035. /**
  47036. * Enable or disable the GPU frame time capture
  47037. */
  47038. captureGPUFrameTime: boolean;
  47039. /**
  47040. * Gets the perf counter used for shader compilation time
  47041. */
  47042. readonly shaderCompilationTimeCounter: PerfCounter;
  47043. /**
  47044. * Gets the shader compilation time capture status
  47045. */
  47046. /**
  47047. * Enable or disable the shader compilation time capture
  47048. */
  47049. captureShaderCompilationTime: boolean;
  47050. /**
  47051. * Instantiates a new engine instrumentation.
  47052. * This class can be used to get instrumentation data from a Babylon engine
  47053. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47054. * @param engine Defines the engine to instrument
  47055. */
  47056. constructor(
  47057. /**
  47058. * Define the instrumented engine.
  47059. */
  47060. engine: Engine);
  47061. /**
  47062. * Dispose and release associated resources.
  47063. */
  47064. dispose(): void;
  47065. }
  47066. }
  47067. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  47068. import { PerfCounter } from "babylonjs/Misc/tools";
  47069. import { Scene, IDisposable } from "babylonjs/scene";
  47070. /**
  47071. * This class can be used to get instrumentation data from a Babylon engine
  47072. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47073. */
  47074. export class SceneInstrumentation implements IDisposable {
  47075. /**
  47076. * Defines the scene to instrument
  47077. */
  47078. scene: Scene;
  47079. private _captureActiveMeshesEvaluationTime;
  47080. private _activeMeshesEvaluationTime;
  47081. private _captureRenderTargetsRenderTime;
  47082. private _renderTargetsRenderTime;
  47083. private _captureFrameTime;
  47084. private _frameTime;
  47085. private _captureRenderTime;
  47086. private _renderTime;
  47087. private _captureInterFrameTime;
  47088. private _interFrameTime;
  47089. private _captureParticlesRenderTime;
  47090. private _particlesRenderTime;
  47091. private _captureSpritesRenderTime;
  47092. private _spritesRenderTime;
  47093. private _capturePhysicsTime;
  47094. private _physicsTime;
  47095. private _captureAnimationsTime;
  47096. private _animationsTime;
  47097. private _captureCameraRenderTime;
  47098. private _cameraRenderTime;
  47099. private _onBeforeActiveMeshesEvaluationObserver;
  47100. private _onAfterActiveMeshesEvaluationObserver;
  47101. private _onBeforeRenderTargetsRenderObserver;
  47102. private _onAfterRenderTargetsRenderObserver;
  47103. private _onAfterRenderObserver;
  47104. private _onBeforeDrawPhaseObserver;
  47105. private _onAfterDrawPhaseObserver;
  47106. private _onBeforeAnimationsObserver;
  47107. private _onBeforeParticlesRenderingObserver;
  47108. private _onAfterParticlesRenderingObserver;
  47109. private _onBeforeSpritesRenderingObserver;
  47110. private _onAfterSpritesRenderingObserver;
  47111. private _onBeforePhysicsObserver;
  47112. private _onAfterPhysicsObserver;
  47113. private _onAfterAnimationsObserver;
  47114. private _onBeforeCameraRenderObserver;
  47115. private _onAfterCameraRenderObserver;
  47116. /**
  47117. * Gets the perf counter used for active meshes evaluation time
  47118. */
  47119. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  47120. /**
  47121. * Gets the active meshes evaluation time capture status
  47122. */
  47123. /**
  47124. * Enable or disable the active meshes evaluation time capture
  47125. */
  47126. captureActiveMeshesEvaluationTime: boolean;
  47127. /**
  47128. * Gets the perf counter used for render targets render time
  47129. */
  47130. readonly renderTargetsRenderTimeCounter: PerfCounter;
  47131. /**
  47132. * Gets the render targets render time capture status
  47133. */
  47134. /**
  47135. * Enable or disable the render targets render time capture
  47136. */
  47137. captureRenderTargetsRenderTime: boolean;
  47138. /**
  47139. * Gets the perf counter used for particles render time
  47140. */
  47141. readonly particlesRenderTimeCounter: PerfCounter;
  47142. /**
  47143. * Gets the particles render time capture status
  47144. */
  47145. /**
  47146. * Enable or disable the particles render time capture
  47147. */
  47148. captureParticlesRenderTime: boolean;
  47149. /**
  47150. * Gets the perf counter used for sprites render time
  47151. */
  47152. readonly spritesRenderTimeCounter: PerfCounter;
  47153. /**
  47154. * Gets the sprites render time capture status
  47155. */
  47156. /**
  47157. * Enable or disable the sprites render time capture
  47158. */
  47159. captureSpritesRenderTime: boolean;
  47160. /**
  47161. * Gets the perf counter used for physics time
  47162. */
  47163. readonly physicsTimeCounter: PerfCounter;
  47164. /**
  47165. * Gets the physics time capture status
  47166. */
  47167. /**
  47168. * Enable or disable the physics time capture
  47169. */
  47170. capturePhysicsTime: boolean;
  47171. /**
  47172. * Gets the perf counter used for animations time
  47173. */
  47174. readonly animationsTimeCounter: PerfCounter;
  47175. /**
  47176. * Gets the animations time capture status
  47177. */
  47178. /**
  47179. * Enable or disable the animations time capture
  47180. */
  47181. captureAnimationsTime: boolean;
  47182. /**
  47183. * Gets the perf counter used for frame time capture
  47184. */
  47185. readonly frameTimeCounter: PerfCounter;
  47186. /**
  47187. * Gets the frame time capture status
  47188. */
  47189. /**
  47190. * Enable or disable the frame time capture
  47191. */
  47192. captureFrameTime: boolean;
  47193. /**
  47194. * Gets the perf counter used for inter-frames time capture
  47195. */
  47196. readonly interFrameTimeCounter: PerfCounter;
  47197. /**
  47198. * Gets the inter-frames time capture status
  47199. */
  47200. /**
  47201. * Enable or disable the inter-frames time capture
  47202. */
  47203. captureInterFrameTime: boolean;
  47204. /**
  47205. * Gets the perf counter used for render time capture
  47206. */
  47207. readonly renderTimeCounter: PerfCounter;
  47208. /**
  47209. * Gets the render time capture status
  47210. */
  47211. /**
  47212. * Enable or disable the render time capture
  47213. */
  47214. captureRenderTime: boolean;
  47215. /**
  47216. * Gets the perf counter used for camera render time capture
  47217. */
  47218. readonly cameraRenderTimeCounter: PerfCounter;
  47219. /**
  47220. * Gets the camera render time capture status
  47221. */
  47222. /**
  47223. * Enable or disable the camera render time capture
  47224. */
  47225. captureCameraRenderTime: boolean;
  47226. /**
  47227. * Gets the perf counter used for draw calls
  47228. */
  47229. readonly drawCallsCounter: PerfCounter;
  47230. /**
  47231. * Gets the perf counter used for texture collisions
  47232. */
  47233. readonly textureCollisionsCounter: PerfCounter;
  47234. /**
  47235. * Instantiates a new scene instrumentation.
  47236. * This class can be used to get instrumentation data from a Babylon engine
  47237. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47238. * @param scene Defines the scene to instrument
  47239. */
  47240. constructor(
  47241. /**
  47242. * Defines the scene to instrument
  47243. */
  47244. scene: Scene);
  47245. /**
  47246. * Dispose and release associated resources.
  47247. */
  47248. dispose(): void;
  47249. }
  47250. }
  47251. declare module "babylonjs/Instrumentation/index" {
  47252. export * from "babylonjs/Instrumentation/engineInstrumentation";
  47253. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  47254. export * from "babylonjs/Instrumentation/timeToken";
  47255. }
  47256. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  47257. /** @hidden */
  47258. export var glowMapGenerationPixelShader: {
  47259. name: string;
  47260. shader: string;
  47261. };
  47262. }
  47263. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  47264. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47265. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  47266. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  47267. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47268. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  47269. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47270. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47271. /** @hidden */
  47272. export var glowMapGenerationVertexShader: {
  47273. name: string;
  47274. shader: string;
  47275. };
  47276. }
  47277. declare module "babylonjs/Layers/effectLayer" {
  47278. import { Observable } from "babylonjs/Misc/observable";
  47279. import { Nullable } from "babylonjs/types";
  47280. import { Camera } from "babylonjs/Cameras/camera";
  47281. import { Scene } from "babylonjs/scene";
  47282. import { Color4, ISize } from "babylonjs/Maths/math";
  47283. import { Engine } from "babylonjs/Engines/engine";
  47284. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47285. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47286. import { Mesh } from "babylonjs/Meshes/mesh";
  47287. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  47288. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47289. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47290. import { Effect } from "babylonjs/Materials/effect";
  47291. import { Material } from "babylonjs/Materials/material";
  47292. import "babylonjs/Shaders/glowMapGeneration.fragment";
  47293. import "babylonjs/Shaders/glowMapGeneration.vertex";
  47294. /**
  47295. * Effect layer options. This helps customizing the behaviour
  47296. * of the effect layer.
  47297. */
  47298. export interface IEffectLayerOptions {
  47299. /**
  47300. * Multiplication factor apply to the canvas size to compute the render target size
  47301. * used to generated the objects (the smaller the faster).
  47302. */
  47303. mainTextureRatio: number;
  47304. /**
  47305. * Enforces a fixed size texture to ensure effect stability across devices.
  47306. */
  47307. mainTextureFixedSize?: number;
  47308. /**
  47309. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  47310. */
  47311. alphaBlendingMode: number;
  47312. /**
  47313. * The camera attached to the layer.
  47314. */
  47315. camera: Nullable<Camera>;
  47316. /**
  47317. * The rendering group to draw the layer in.
  47318. */
  47319. renderingGroupId: number;
  47320. }
  47321. /**
  47322. * The effect layer Helps adding post process effect blended with the main pass.
  47323. *
  47324. * This can be for instance use to generate glow or higlight effects on the scene.
  47325. *
  47326. * The effect layer class can not be used directly and is intented to inherited from to be
  47327. * customized per effects.
  47328. */
  47329. export abstract class EffectLayer {
  47330. private _vertexBuffers;
  47331. private _indexBuffer;
  47332. private _cachedDefines;
  47333. private _effectLayerMapGenerationEffect;
  47334. private _effectLayerOptions;
  47335. private _mergeEffect;
  47336. protected _scene: Scene;
  47337. protected _engine: Engine;
  47338. protected _maxSize: number;
  47339. protected _mainTextureDesiredSize: ISize;
  47340. protected _mainTexture: RenderTargetTexture;
  47341. protected _shouldRender: boolean;
  47342. protected _postProcesses: PostProcess[];
  47343. protected _textures: BaseTexture[];
  47344. protected _emissiveTextureAndColor: {
  47345. texture: Nullable<BaseTexture>;
  47346. color: Color4;
  47347. };
  47348. /**
  47349. * The name of the layer
  47350. */
  47351. name: string;
  47352. /**
  47353. * The clear color of the texture used to generate the glow map.
  47354. */
  47355. neutralColor: Color4;
  47356. /**
  47357. * Specifies wether the highlight layer is enabled or not.
  47358. */
  47359. isEnabled: boolean;
  47360. /**
  47361. * Gets the camera attached to the layer.
  47362. */
  47363. readonly camera: Nullable<Camera>;
  47364. /**
  47365. * Gets the rendering group id the layer should render in.
  47366. */
  47367. readonly renderingGroupId: number;
  47368. /**
  47369. * An event triggered when the effect layer has been disposed.
  47370. */
  47371. onDisposeObservable: Observable<EffectLayer>;
  47372. /**
  47373. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  47374. */
  47375. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  47376. /**
  47377. * An event triggered when the generated texture is being merged in the scene.
  47378. */
  47379. onBeforeComposeObservable: Observable<EffectLayer>;
  47380. /**
  47381. * An event triggered when the generated texture has been merged in the scene.
  47382. */
  47383. onAfterComposeObservable: Observable<EffectLayer>;
  47384. /**
  47385. * An event triggered when the efffect layer changes its size.
  47386. */
  47387. onSizeChangedObservable: Observable<EffectLayer>;
  47388. /** @hidden */
  47389. static _SceneComponentInitialization: (scene: Scene) => void;
  47390. /**
  47391. * Instantiates a new effect Layer and references it in the scene.
  47392. * @param name The name of the layer
  47393. * @param scene The scene to use the layer in
  47394. */
  47395. constructor(
  47396. /** The Friendly of the effect in the scene */
  47397. name: string, scene: Scene);
  47398. /**
  47399. * Get the effect name of the layer.
  47400. * @return The effect name
  47401. */
  47402. abstract getEffectName(): string;
  47403. /**
  47404. * Checks for the readiness of the element composing the layer.
  47405. * @param subMesh the mesh to check for
  47406. * @param useInstances specify wether or not to use instances to render the mesh
  47407. * @return true if ready otherwise, false
  47408. */
  47409. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47410. /**
  47411. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47412. * @returns true if the effect requires stencil during the main canvas render pass.
  47413. */
  47414. abstract needStencil(): boolean;
  47415. /**
  47416. * Create the merge effect. This is the shader use to blit the information back
  47417. * to the main canvas at the end of the scene rendering.
  47418. * @returns The effect containing the shader used to merge the effect on the main canvas
  47419. */
  47420. protected abstract _createMergeEffect(): Effect;
  47421. /**
  47422. * Creates the render target textures and post processes used in the effect layer.
  47423. */
  47424. protected abstract _createTextureAndPostProcesses(): void;
  47425. /**
  47426. * Implementation specific of rendering the generating effect on the main canvas.
  47427. * @param effect The effect used to render through
  47428. */
  47429. protected abstract _internalRender(effect: Effect): void;
  47430. /**
  47431. * Sets the required values for both the emissive texture and and the main color.
  47432. */
  47433. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47434. /**
  47435. * Free any resources and references associated to a mesh.
  47436. * Internal use
  47437. * @param mesh The mesh to free.
  47438. */
  47439. abstract _disposeMesh(mesh: Mesh): void;
  47440. /**
  47441. * Serializes this layer (Glow or Highlight for example)
  47442. * @returns a serialized layer object
  47443. */
  47444. abstract serialize?(): any;
  47445. /**
  47446. * Initializes the effect layer with the required options.
  47447. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  47448. */
  47449. protected _init(options: Partial<IEffectLayerOptions>): void;
  47450. /**
  47451. * Generates the index buffer of the full screen quad blending to the main canvas.
  47452. */
  47453. private _generateIndexBuffer;
  47454. /**
  47455. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  47456. */
  47457. private _genrateVertexBuffer;
  47458. /**
  47459. * Sets the main texture desired size which is the closest power of two
  47460. * of the engine canvas size.
  47461. */
  47462. private _setMainTextureSize;
  47463. /**
  47464. * Creates the main texture for the effect layer.
  47465. */
  47466. protected _createMainTexture(): void;
  47467. /**
  47468. * Adds specific effects defines.
  47469. * @param defines The defines to add specifics to.
  47470. */
  47471. protected _addCustomEffectDefines(defines: string[]): void;
  47472. /**
  47473. * Checks for the readiness of the element composing the layer.
  47474. * @param subMesh the mesh to check for
  47475. * @param useInstances specify wether or not to use instances to render the mesh
  47476. * @param emissiveTexture the associated emissive texture used to generate the glow
  47477. * @return true if ready otherwise, false
  47478. */
  47479. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  47480. /**
  47481. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  47482. */
  47483. render(): void;
  47484. /**
  47485. * Determine if a given mesh will be used in the current effect.
  47486. * @param mesh mesh to test
  47487. * @returns true if the mesh will be used
  47488. */
  47489. hasMesh(mesh: AbstractMesh): boolean;
  47490. /**
  47491. * Returns true if the layer contains information to display, otherwise false.
  47492. * @returns true if the glow layer should be rendered
  47493. */
  47494. shouldRender(): boolean;
  47495. /**
  47496. * Returns true if the mesh should render, otherwise false.
  47497. * @param mesh The mesh to render
  47498. * @returns true if it should render otherwise false
  47499. */
  47500. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  47501. /**
  47502. * Returns true if the mesh can be rendered, otherwise false.
  47503. * @param mesh The mesh to render
  47504. * @param material The material used on the mesh
  47505. * @returns true if it can be rendered otherwise false
  47506. */
  47507. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47508. /**
  47509. * Returns true if the mesh should render, otherwise false.
  47510. * @param mesh The mesh to render
  47511. * @returns true if it should render otherwise false
  47512. */
  47513. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  47514. /**
  47515. * Renders the submesh passed in parameter to the generation map.
  47516. */
  47517. protected _renderSubMesh(subMesh: SubMesh): void;
  47518. /**
  47519. * Rebuild the required buffers.
  47520. * @hidden Internal use only.
  47521. */
  47522. _rebuild(): void;
  47523. /**
  47524. * Dispose only the render target textures and post process.
  47525. */
  47526. private _disposeTextureAndPostProcesses;
  47527. /**
  47528. * Dispose the highlight layer and free resources.
  47529. */
  47530. dispose(): void;
  47531. /**
  47532. * Gets the class name of the effect layer
  47533. * @returns the string with the class name of the effect layer
  47534. */
  47535. getClassName(): string;
  47536. /**
  47537. * Creates an effect layer from parsed effect layer data
  47538. * @param parsedEffectLayer defines effect layer data
  47539. * @param scene defines the current scene
  47540. * @param rootUrl defines the root URL containing the effect layer information
  47541. * @returns a parsed effect Layer
  47542. */
  47543. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  47544. }
  47545. }
  47546. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  47547. import { Scene } from "babylonjs/scene";
  47548. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47549. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47550. import { AbstractScene } from "babylonjs/abstractScene";
  47551. module "babylonjs/abstractScene" {
  47552. interface AbstractScene {
  47553. /**
  47554. * The list of effect layers (highlights/glow) added to the scene
  47555. * @see http://doc.babylonjs.com/how_to/highlight_layer
  47556. * @see http://doc.babylonjs.com/how_to/glow_layer
  47557. */
  47558. effectLayers: Array<EffectLayer>;
  47559. /**
  47560. * Removes the given effect layer from this scene.
  47561. * @param toRemove defines the effect layer to remove
  47562. * @returns the index of the removed effect layer
  47563. */
  47564. removeEffectLayer(toRemove: EffectLayer): number;
  47565. /**
  47566. * Adds the given effect layer to this scene
  47567. * @param newEffectLayer defines the effect layer to add
  47568. */
  47569. addEffectLayer(newEffectLayer: EffectLayer): void;
  47570. }
  47571. }
  47572. /**
  47573. * Defines the layer scene component responsible to manage any effect layers
  47574. * in a given scene.
  47575. */
  47576. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  47577. /**
  47578. * The component name helpfull to identify the component in the list of scene components.
  47579. */
  47580. readonly name: string;
  47581. /**
  47582. * The scene the component belongs to.
  47583. */
  47584. scene: Scene;
  47585. private _engine;
  47586. private _renderEffects;
  47587. private _needStencil;
  47588. private _previousStencilState;
  47589. /**
  47590. * Creates a new instance of the component for the given scene
  47591. * @param scene Defines the scene to register the component in
  47592. */
  47593. constructor(scene: Scene);
  47594. /**
  47595. * Registers the component in a given scene
  47596. */
  47597. register(): void;
  47598. /**
  47599. * Rebuilds the elements related to this component in case of
  47600. * context lost for instance.
  47601. */
  47602. rebuild(): void;
  47603. /**
  47604. * Serializes the component data to the specified json object
  47605. * @param serializationObject The object to serialize to
  47606. */
  47607. serialize(serializationObject: any): void;
  47608. /**
  47609. * Adds all the element from the container to the scene
  47610. * @param container the container holding the elements
  47611. */
  47612. addFromContainer(container: AbstractScene): void;
  47613. /**
  47614. * Removes all the elements in the container from the scene
  47615. * @param container contains the elements to remove
  47616. */
  47617. removeFromContainer(container: AbstractScene): void;
  47618. /**
  47619. * Disposes the component and the associated ressources.
  47620. */
  47621. dispose(): void;
  47622. private _isReadyForMesh;
  47623. private _renderMainTexture;
  47624. private _setStencil;
  47625. private _setStencilBack;
  47626. private _draw;
  47627. private _drawCamera;
  47628. private _drawRenderingGroup;
  47629. }
  47630. }
  47631. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  47632. /** @hidden */
  47633. export var glowMapMergePixelShader: {
  47634. name: string;
  47635. shader: string;
  47636. };
  47637. }
  47638. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  47639. /** @hidden */
  47640. export var glowMapMergeVertexShader: {
  47641. name: string;
  47642. shader: string;
  47643. };
  47644. }
  47645. declare module "babylonjs/Layers/glowLayer" {
  47646. import { Nullable } from "babylonjs/types";
  47647. import { Camera } from "babylonjs/Cameras/camera";
  47648. import { Scene } from "babylonjs/scene";
  47649. import { Color4 } from "babylonjs/Maths/math";
  47650. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47651. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47652. import { Mesh } from "babylonjs/Meshes/mesh";
  47653. import { Texture } from "babylonjs/Materials/Textures/texture";
  47654. import { Effect } from "babylonjs/Materials/effect";
  47655. import { Material } from "babylonjs/Materials/material";
  47656. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47657. import "babylonjs/Shaders/glowMapMerge.fragment";
  47658. import "babylonjs/Shaders/glowMapMerge.vertex";
  47659. import "babylonjs/Layers/effectLayerSceneComponent";
  47660. module "babylonjs/abstractScene" {
  47661. interface AbstractScene {
  47662. /**
  47663. * Return a the first highlight layer of the scene with a given name.
  47664. * @param name The name of the highlight layer to look for.
  47665. * @return The highlight layer if found otherwise null.
  47666. */
  47667. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  47668. }
  47669. }
  47670. /**
  47671. * Glow layer options. This helps customizing the behaviour
  47672. * of the glow layer.
  47673. */
  47674. export interface IGlowLayerOptions {
  47675. /**
  47676. * Multiplication factor apply to the canvas size to compute the render target size
  47677. * used to generated the glowing objects (the smaller the faster).
  47678. */
  47679. mainTextureRatio: number;
  47680. /**
  47681. * Enforces a fixed size texture to ensure resize independant blur.
  47682. */
  47683. mainTextureFixedSize?: number;
  47684. /**
  47685. * How big is the kernel of the blur texture.
  47686. */
  47687. blurKernelSize: number;
  47688. /**
  47689. * The camera attached to the layer.
  47690. */
  47691. camera: Nullable<Camera>;
  47692. /**
  47693. * Enable MSAA by chosing the number of samples.
  47694. */
  47695. mainTextureSamples?: number;
  47696. /**
  47697. * The rendering group to draw the layer in.
  47698. */
  47699. renderingGroupId: number;
  47700. }
  47701. /**
  47702. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  47703. *
  47704. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47705. * glowy meshes to your scene.
  47706. *
  47707. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  47708. */
  47709. export class GlowLayer extends EffectLayer {
  47710. /**
  47711. * Effect Name of the layer.
  47712. */
  47713. static readonly EffectName: string;
  47714. /**
  47715. * The default blur kernel size used for the glow.
  47716. */
  47717. static DefaultBlurKernelSize: number;
  47718. /**
  47719. * The default texture size ratio used for the glow.
  47720. */
  47721. static DefaultTextureRatio: number;
  47722. /**
  47723. * Sets the kernel size of the blur.
  47724. */
  47725. /**
  47726. * Gets the kernel size of the blur.
  47727. */
  47728. blurKernelSize: number;
  47729. /**
  47730. * Sets the glow intensity.
  47731. */
  47732. /**
  47733. * Gets the glow intensity.
  47734. */
  47735. intensity: number;
  47736. private _options;
  47737. private _intensity;
  47738. private _horizontalBlurPostprocess1;
  47739. private _verticalBlurPostprocess1;
  47740. private _horizontalBlurPostprocess2;
  47741. private _verticalBlurPostprocess2;
  47742. private _blurTexture1;
  47743. private _blurTexture2;
  47744. private _postProcesses1;
  47745. private _postProcesses2;
  47746. private _includedOnlyMeshes;
  47747. private _excludedMeshes;
  47748. /**
  47749. * Callback used to let the user override the color selection on a per mesh basis
  47750. */
  47751. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  47752. /**
  47753. * Callback used to let the user override the texture selection on a per mesh basis
  47754. */
  47755. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  47756. /**
  47757. * Instantiates a new glow Layer and references it to the scene.
  47758. * @param name The name of the layer
  47759. * @param scene The scene to use the layer in
  47760. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  47761. */
  47762. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  47763. /**
  47764. * Get the effect name of the layer.
  47765. * @return The effect name
  47766. */
  47767. getEffectName(): string;
  47768. /**
  47769. * Create the merge effect. This is the shader use to blit the information back
  47770. * to the main canvas at the end of the scene rendering.
  47771. */
  47772. protected _createMergeEffect(): Effect;
  47773. /**
  47774. * Creates the render target textures and post processes used in the glow layer.
  47775. */
  47776. protected _createTextureAndPostProcesses(): void;
  47777. /**
  47778. * Checks for the readiness of the element composing the layer.
  47779. * @param subMesh the mesh to check for
  47780. * @param useInstances specify wether or not to use instances to render the mesh
  47781. * @param emissiveTexture the associated emissive texture used to generate the glow
  47782. * @return true if ready otherwise, false
  47783. */
  47784. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47785. /**
  47786. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47787. */
  47788. needStencil(): boolean;
  47789. /**
  47790. * Returns true if the mesh can be rendered, otherwise false.
  47791. * @param mesh The mesh to render
  47792. * @param material The material used on the mesh
  47793. * @returns true if it can be rendered otherwise false
  47794. */
  47795. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47796. /**
  47797. * Implementation specific of rendering the generating effect on the main canvas.
  47798. * @param effect The effect used to render through
  47799. */
  47800. protected _internalRender(effect: Effect): void;
  47801. /**
  47802. * Sets the required values for both the emissive texture and and the main color.
  47803. */
  47804. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47805. /**
  47806. * Returns true if the mesh should render, otherwise false.
  47807. * @param mesh The mesh to render
  47808. * @returns true if it should render otherwise false
  47809. */
  47810. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47811. /**
  47812. * Adds specific effects defines.
  47813. * @param defines The defines to add specifics to.
  47814. */
  47815. protected _addCustomEffectDefines(defines: string[]): void;
  47816. /**
  47817. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  47818. * @param mesh The mesh to exclude from the glow layer
  47819. */
  47820. addExcludedMesh(mesh: Mesh): void;
  47821. /**
  47822. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  47823. * @param mesh The mesh to remove
  47824. */
  47825. removeExcludedMesh(mesh: Mesh): void;
  47826. /**
  47827. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  47828. * @param mesh The mesh to include in the glow layer
  47829. */
  47830. addIncludedOnlyMesh(mesh: Mesh): void;
  47831. /**
  47832. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  47833. * @param mesh The mesh to remove
  47834. */
  47835. removeIncludedOnlyMesh(mesh: Mesh): void;
  47836. /**
  47837. * Determine if a given mesh will be used in the glow layer
  47838. * @param mesh The mesh to test
  47839. * @returns true if the mesh will be highlighted by the current glow layer
  47840. */
  47841. hasMesh(mesh: AbstractMesh): boolean;
  47842. /**
  47843. * Free any resources and references associated to a mesh.
  47844. * Internal use
  47845. * @param mesh The mesh to free.
  47846. * @hidden
  47847. */
  47848. _disposeMesh(mesh: Mesh): void;
  47849. /**
  47850. * Gets the class name of the effect layer
  47851. * @returns the string with the class name of the effect layer
  47852. */
  47853. getClassName(): string;
  47854. /**
  47855. * Serializes this glow layer
  47856. * @returns a serialized glow layer object
  47857. */
  47858. serialize(): any;
  47859. /**
  47860. * Creates a Glow Layer from parsed glow layer data
  47861. * @param parsedGlowLayer defines glow layer data
  47862. * @param scene defines the current scene
  47863. * @param rootUrl defines the root URL containing the glow layer information
  47864. * @returns a parsed Glow Layer
  47865. */
  47866. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  47867. }
  47868. }
  47869. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  47870. /** @hidden */
  47871. export var glowBlurPostProcessPixelShader: {
  47872. name: string;
  47873. shader: string;
  47874. };
  47875. }
  47876. declare module "babylonjs/Layers/highlightLayer" {
  47877. import { Observable } from "babylonjs/Misc/observable";
  47878. import { Nullable } from "babylonjs/types";
  47879. import { Camera } from "babylonjs/Cameras/camera";
  47880. import { Scene } from "babylonjs/scene";
  47881. import { Color3, Color4 } from "babylonjs/Maths/math";
  47882. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47883. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47884. import { Mesh } from "babylonjs/Meshes/mesh";
  47885. import { Effect } from "babylonjs/Materials/effect";
  47886. import { Material } from "babylonjs/Materials/material";
  47887. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47888. import "babylonjs/Shaders/glowMapMerge.fragment";
  47889. import "babylonjs/Shaders/glowMapMerge.vertex";
  47890. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  47891. module "babylonjs/abstractScene" {
  47892. interface AbstractScene {
  47893. /**
  47894. * Return a the first highlight layer of the scene with a given name.
  47895. * @param name The name of the highlight layer to look for.
  47896. * @return The highlight layer if found otherwise null.
  47897. */
  47898. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  47899. }
  47900. }
  47901. /**
  47902. * Highlight layer options. This helps customizing the behaviour
  47903. * of the highlight layer.
  47904. */
  47905. export interface IHighlightLayerOptions {
  47906. /**
  47907. * Multiplication factor apply to the canvas size to compute the render target size
  47908. * used to generated the glowing objects (the smaller the faster).
  47909. */
  47910. mainTextureRatio: number;
  47911. /**
  47912. * Enforces a fixed size texture to ensure resize independant blur.
  47913. */
  47914. mainTextureFixedSize?: number;
  47915. /**
  47916. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  47917. * of the picture to blur (the smaller the faster).
  47918. */
  47919. blurTextureSizeRatio: number;
  47920. /**
  47921. * How big in texel of the blur texture is the vertical blur.
  47922. */
  47923. blurVerticalSize: number;
  47924. /**
  47925. * How big in texel of the blur texture is the horizontal blur.
  47926. */
  47927. blurHorizontalSize: number;
  47928. /**
  47929. * Alpha blending mode used to apply the blur. Default is combine.
  47930. */
  47931. alphaBlendingMode: number;
  47932. /**
  47933. * The camera attached to the layer.
  47934. */
  47935. camera: Nullable<Camera>;
  47936. /**
  47937. * Should we display highlight as a solid stroke?
  47938. */
  47939. isStroke?: boolean;
  47940. /**
  47941. * The rendering group to draw the layer in.
  47942. */
  47943. renderingGroupId: number;
  47944. }
  47945. /**
  47946. * The highlight layer Helps adding a glow effect around a mesh.
  47947. *
  47948. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47949. * glowy meshes to your scene.
  47950. *
  47951. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  47952. */
  47953. export class HighlightLayer extends EffectLayer {
  47954. name: string;
  47955. /**
  47956. * Effect Name of the highlight layer.
  47957. */
  47958. static readonly EffectName: string;
  47959. /**
  47960. * The neutral color used during the preparation of the glow effect.
  47961. * This is black by default as the blend operation is a blend operation.
  47962. */
  47963. static NeutralColor: Color4;
  47964. /**
  47965. * Stencil value used for glowing meshes.
  47966. */
  47967. static GlowingMeshStencilReference: number;
  47968. /**
  47969. * Stencil value used for the other meshes in the scene.
  47970. */
  47971. static NormalMeshStencilReference: number;
  47972. /**
  47973. * Specifies whether or not the inner glow is ACTIVE in the layer.
  47974. */
  47975. innerGlow: boolean;
  47976. /**
  47977. * Specifies whether or not the outer glow is ACTIVE in the layer.
  47978. */
  47979. outerGlow: boolean;
  47980. /**
  47981. * Specifies the horizontal size of the blur.
  47982. */
  47983. /**
  47984. * Gets the horizontal size of the blur.
  47985. */
  47986. blurHorizontalSize: number;
  47987. /**
  47988. * Specifies the vertical size of the blur.
  47989. */
  47990. /**
  47991. * Gets the vertical size of the blur.
  47992. */
  47993. blurVerticalSize: number;
  47994. /**
  47995. * An event triggered when the highlight layer is being blurred.
  47996. */
  47997. onBeforeBlurObservable: Observable<HighlightLayer>;
  47998. /**
  47999. * An event triggered when the highlight layer has been blurred.
  48000. */
  48001. onAfterBlurObservable: Observable<HighlightLayer>;
  48002. private _instanceGlowingMeshStencilReference;
  48003. private _options;
  48004. private _downSamplePostprocess;
  48005. private _horizontalBlurPostprocess;
  48006. private _verticalBlurPostprocess;
  48007. private _blurTexture;
  48008. private _meshes;
  48009. private _excludedMeshes;
  48010. /**
  48011. * Instantiates a new highlight Layer and references it to the scene..
  48012. * @param name The name of the layer
  48013. * @param scene The scene to use the layer in
  48014. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  48015. */
  48016. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  48017. /**
  48018. * Get the effect name of the layer.
  48019. * @return The effect name
  48020. */
  48021. getEffectName(): string;
  48022. /**
  48023. * Create the merge effect. This is the shader use to blit the information back
  48024. * to the main canvas at the end of the scene rendering.
  48025. */
  48026. protected _createMergeEffect(): Effect;
  48027. /**
  48028. * Creates the render target textures and post processes used in the highlight layer.
  48029. */
  48030. protected _createTextureAndPostProcesses(): void;
  48031. /**
  48032. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48033. */
  48034. needStencil(): boolean;
  48035. /**
  48036. * Checks for the readiness of the element composing the layer.
  48037. * @param subMesh the mesh to check for
  48038. * @param useInstances specify wether or not to use instances to render the mesh
  48039. * @param emissiveTexture the associated emissive texture used to generate the glow
  48040. * @return true if ready otherwise, false
  48041. */
  48042. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48043. /**
  48044. * Implementation specific of rendering the generating effect on the main canvas.
  48045. * @param effect The effect used to render through
  48046. */
  48047. protected _internalRender(effect: Effect): void;
  48048. /**
  48049. * Returns true if the layer contains information to display, otherwise false.
  48050. */
  48051. shouldRender(): boolean;
  48052. /**
  48053. * Returns true if the mesh should render, otherwise false.
  48054. * @param mesh The mesh to render
  48055. * @returns true if it should render otherwise false
  48056. */
  48057. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48058. /**
  48059. * Sets the required values for both the emissive texture and and the main color.
  48060. */
  48061. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48062. /**
  48063. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  48064. * @param mesh The mesh to exclude from the highlight layer
  48065. */
  48066. addExcludedMesh(mesh: Mesh): void;
  48067. /**
  48068. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  48069. * @param mesh The mesh to highlight
  48070. */
  48071. removeExcludedMesh(mesh: Mesh): void;
  48072. /**
  48073. * Determine if a given mesh will be highlighted by the current HighlightLayer
  48074. * @param mesh mesh to test
  48075. * @returns true if the mesh will be highlighted by the current HighlightLayer
  48076. */
  48077. hasMesh(mesh: AbstractMesh): boolean;
  48078. /**
  48079. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  48080. * @param mesh The mesh to highlight
  48081. * @param color The color of the highlight
  48082. * @param glowEmissiveOnly Extract the glow from the emissive texture
  48083. */
  48084. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  48085. /**
  48086. * Remove a mesh from the highlight layer in order to make it stop glowing.
  48087. * @param mesh The mesh to highlight
  48088. */
  48089. removeMesh(mesh: Mesh): void;
  48090. /**
  48091. * Force the stencil to the normal expected value for none glowing parts
  48092. */
  48093. private _defaultStencilReference;
  48094. /**
  48095. * Free any resources and references associated to a mesh.
  48096. * Internal use
  48097. * @param mesh The mesh to free.
  48098. * @hidden
  48099. */
  48100. _disposeMesh(mesh: Mesh): void;
  48101. /**
  48102. * Dispose the highlight layer and free resources.
  48103. */
  48104. dispose(): void;
  48105. /**
  48106. * Gets the class name of the effect layer
  48107. * @returns the string with the class name of the effect layer
  48108. */
  48109. getClassName(): string;
  48110. /**
  48111. * Serializes this Highlight layer
  48112. * @returns a serialized Highlight layer object
  48113. */
  48114. serialize(): any;
  48115. /**
  48116. * Creates a Highlight layer from parsed Highlight layer data
  48117. * @param parsedHightlightLayer defines the Highlight layer data
  48118. * @param scene defines the current scene
  48119. * @param rootUrl defines the root URL containing the Highlight layer information
  48120. * @returns a parsed Highlight layer
  48121. */
  48122. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  48123. }
  48124. }
  48125. declare module "babylonjs/Layers/index" {
  48126. export * from "babylonjs/Layers/effectLayer";
  48127. export * from "babylonjs/Layers/effectLayerSceneComponent";
  48128. export * from "babylonjs/Layers/glowLayer";
  48129. export * from "babylonjs/Layers/highlightLayer";
  48130. export * from "babylonjs/Layers/layer";
  48131. export * from "babylonjs/Layers/layerSceneComponent";
  48132. }
  48133. declare module "babylonjs/Shaders/lensFlare.fragment" {
  48134. /** @hidden */
  48135. export var lensFlarePixelShader: {
  48136. name: string;
  48137. shader: string;
  48138. };
  48139. }
  48140. declare module "babylonjs/Shaders/lensFlare.vertex" {
  48141. /** @hidden */
  48142. export var lensFlareVertexShader: {
  48143. name: string;
  48144. shader: string;
  48145. };
  48146. }
  48147. declare module "babylonjs/LensFlares/lensFlareSystem" {
  48148. import { Scene } from "babylonjs/scene";
  48149. import { Vector3, Viewport } from "babylonjs/Maths/math";
  48150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48151. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  48152. import "babylonjs/Shaders/lensFlare.fragment";
  48153. import "babylonjs/Shaders/lensFlare.vertex";
  48154. /**
  48155. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48156. * It is usually composed of several `lensFlare`.
  48157. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48158. */
  48159. export class LensFlareSystem {
  48160. /**
  48161. * Define the name of the lens flare system
  48162. */
  48163. name: string;
  48164. /**
  48165. * List of lens flares used in this system.
  48166. */
  48167. lensFlares: LensFlare[];
  48168. /**
  48169. * Define a limit from the border the lens flare can be visible.
  48170. */
  48171. borderLimit: number;
  48172. /**
  48173. * Define a viewport border we do not want to see the lens flare in.
  48174. */
  48175. viewportBorder: number;
  48176. /**
  48177. * Define a predicate which could limit the list of meshes able to occlude the effect.
  48178. */
  48179. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48180. /**
  48181. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  48182. */
  48183. layerMask: number;
  48184. /**
  48185. * Define the id of the lens flare system in the scene.
  48186. * (equal to name by default)
  48187. */
  48188. id: string;
  48189. private _scene;
  48190. private _emitter;
  48191. private _vertexBuffers;
  48192. private _indexBuffer;
  48193. private _effect;
  48194. private _positionX;
  48195. private _positionY;
  48196. private _isEnabled;
  48197. /** @hidden */
  48198. static _SceneComponentInitialization: (scene: Scene) => void;
  48199. /**
  48200. * Instantiates a lens flare system.
  48201. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48202. * It is usually composed of several `lensFlare`.
  48203. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48204. * @param name Define the name of the lens flare system in the scene
  48205. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  48206. * @param scene Define the scene the lens flare system belongs to
  48207. */
  48208. constructor(
  48209. /**
  48210. * Define the name of the lens flare system
  48211. */
  48212. name: string, emitter: any, scene: Scene);
  48213. /**
  48214. * Define if the lens flare system is enabled.
  48215. */
  48216. isEnabled: boolean;
  48217. /**
  48218. * Get the scene the effects belongs to.
  48219. * @returns the scene holding the lens flare system
  48220. */
  48221. getScene(): Scene;
  48222. /**
  48223. * Get the emitter of the lens flare system.
  48224. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48225. * @returns the emitter of the lens flare system
  48226. */
  48227. getEmitter(): any;
  48228. /**
  48229. * Set the emitter of the lens flare system.
  48230. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48231. * @param newEmitter Define the new emitter of the system
  48232. */
  48233. setEmitter(newEmitter: any): void;
  48234. /**
  48235. * Get the lens flare system emitter position.
  48236. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  48237. * @returns the position
  48238. */
  48239. getEmitterPosition(): Vector3;
  48240. /**
  48241. * @hidden
  48242. */
  48243. computeEffectivePosition(globalViewport: Viewport): boolean;
  48244. /** @hidden */
  48245. _isVisible(): boolean;
  48246. /**
  48247. * @hidden
  48248. */
  48249. render(): boolean;
  48250. /**
  48251. * Dispose and release the lens flare with its associated resources.
  48252. */
  48253. dispose(): void;
  48254. /**
  48255. * Parse a lens flare system from a JSON repressentation
  48256. * @param parsedLensFlareSystem Define the JSON to parse
  48257. * @param scene Define the scene the parsed system should be instantiated in
  48258. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  48259. * @returns the parsed system
  48260. */
  48261. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  48262. /**
  48263. * Serialize the current Lens Flare System into a JSON representation.
  48264. * @returns the serialized JSON
  48265. */
  48266. serialize(): any;
  48267. }
  48268. }
  48269. declare module "babylonjs/LensFlares/lensFlare" {
  48270. import { Nullable } from "babylonjs/types";
  48271. import { Color3 } from "babylonjs/Maths/math";
  48272. import { Texture } from "babylonjs/Materials/Textures/texture";
  48273. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  48274. /**
  48275. * This represents one of the lens effect in a `lensFlareSystem`.
  48276. * It controls one of the indiviual texture used in the effect.
  48277. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48278. */
  48279. export class LensFlare {
  48280. /**
  48281. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  48282. */
  48283. size: number;
  48284. /**
  48285. * 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.
  48286. */
  48287. position: number;
  48288. /**
  48289. * Define the lens color.
  48290. */
  48291. color: Color3;
  48292. /**
  48293. * Define the lens texture.
  48294. */
  48295. texture: Nullable<Texture>;
  48296. /**
  48297. * Define the alpha mode to render this particular lens.
  48298. */
  48299. alphaMode: number;
  48300. private _system;
  48301. /**
  48302. * Creates a new Lens Flare.
  48303. * This represents one of the lens effect in a `lensFlareSystem`.
  48304. * It controls one of the indiviual texture used in the effect.
  48305. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48306. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  48307. * @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.
  48308. * @param color Define the lens color
  48309. * @param imgUrl Define the lens texture url
  48310. * @param system Define the `lensFlareSystem` this flare is part of
  48311. * @returns The newly created Lens Flare
  48312. */
  48313. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  48314. /**
  48315. * Instantiates a new Lens Flare.
  48316. * This represents one of the lens effect in a `lensFlareSystem`.
  48317. * It controls one of the indiviual texture used in the effect.
  48318. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48319. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  48320. * @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.
  48321. * @param color Define the lens color
  48322. * @param imgUrl Define the lens texture url
  48323. * @param system Define the `lensFlareSystem` this flare is part of
  48324. */
  48325. constructor(
  48326. /**
  48327. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  48328. */
  48329. size: number,
  48330. /**
  48331. * 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.
  48332. */
  48333. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  48334. /**
  48335. * Dispose and release the lens flare with its associated resources.
  48336. */
  48337. dispose(): void;
  48338. }
  48339. }
  48340. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  48341. import { Nullable } from "babylonjs/types";
  48342. import { Scene } from "babylonjs/scene";
  48343. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  48344. import { AbstractScene } from "babylonjs/abstractScene";
  48345. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  48346. module "babylonjs/abstractScene" {
  48347. interface AbstractScene {
  48348. /**
  48349. * The list of lens flare system added to the scene
  48350. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48351. */
  48352. lensFlareSystems: Array<LensFlareSystem>;
  48353. /**
  48354. * Removes the given lens flare system from this scene.
  48355. * @param toRemove The lens flare system to remove
  48356. * @returns The index of the removed lens flare system
  48357. */
  48358. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  48359. /**
  48360. * Adds the given lens flare system to this scene
  48361. * @param newLensFlareSystem The lens flare system to add
  48362. */
  48363. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  48364. /**
  48365. * Gets a lens flare system using its name
  48366. * @param name defines the name to look for
  48367. * @returns the lens flare system or null if not found
  48368. */
  48369. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  48370. /**
  48371. * Gets a lens flare system using its id
  48372. * @param id defines the id to look for
  48373. * @returns the lens flare system or null if not found
  48374. */
  48375. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  48376. }
  48377. }
  48378. /**
  48379. * Defines the lens flare scene component responsible to manage any lens flares
  48380. * in a given scene.
  48381. */
  48382. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  48383. /**
  48384. * The component name helpfull to identify the component in the list of scene components.
  48385. */
  48386. readonly name: string;
  48387. /**
  48388. * The scene the component belongs to.
  48389. */
  48390. scene: Scene;
  48391. /**
  48392. * Creates a new instance of the component for the given scene
  48393. * @param scene Defines the scene to register the component in
  48394. */
  48395. constructor(scene: Scene);
  48396. /**
  48397. * Registers the component in a given scene
  48398. */
  48399. register(): void;
  48400. /**
  48401. * Rebuilds the elements related to this component in case of
  48402. * context lost for instance.
  48403. */
  48404. rebuild(): void;
  48405. /**
  48406. * Adds all the element from the container to the scene
  48407. * @param container the container holding the elements
  48408. */
  48409. addFromContainer(container: AbstractScene): void;
  48410. /**
  48411. * Removes all the elements in the container from the scene
  48412. * @param container contains the elements to remove
  48413. */
  48414. removeFromContainer(container: AbstractScene): void;
  48415. /**
  48416. * Serializes the component data to the specified json object
  48417. * @param serializationObject The object to serialize to
  48418. */
  48419. serialize(serializationObject: any): void;
  48420. /**
  48421. * Disposes the component and the associated ressources.
  48422. */
  48423. dispose(): void;
  48424. private _draw;
  48425. }
  48426. }
  48427. declare module "babylonjs/LensFlares/index" {
  48428. export * from "babylonjs/LensFlares/lensFlare";
  48429. export * from "babylonjs/LensFlares/lensFlareSystem";
  48430. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  48431. }
  48432. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  48433. import { Scene } from "babylonjs/scene";
  48434. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  48435. import { AbstractScene } from "babylonjs/abstractScene";
  48436. /**
  48437. * Defines the shadow generator component responsible to manage any shadow generators
  48438. * in a given scene.
  48439. */
  48440. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  48441. /**
  48442. * The component name helpfull to identify the component in the list of scene components.
  48443. */
  48444. readonly name: string;
  48445. /**
  48446. * The scene the component belongs to.
  48447. */
  48448. scene: Scene;
  48449. /**
  48450. * Creates a new instance of the component for the given scene
  48451. * @param scene Defines the scene to register the component in
  48452. */
  48453. constructor(scene: Scene);
  48454. /**
  48455. * Registers the component in a given scene
  48456. */
  48457. register(): void;
  48458. /**
  48459. * Rebuilds the elements related to this component in case of
  48460. * context lost for instance.
  48461. */
  48462. rebuild(): void;
  48463. /**
  48464. * Serializes the component data to the specified json object
  48465. * @param serializationObject The object to serialize to
  48466. */
  48467. serialize(serializationObject: any): void;
  48468. /**
  48469. * Adds all the element from the container to the scene
  48470. * @param container the container holding the elements
  48471. */
  48472. addFromContainer(container: AbstractScene): void;
  48473. /**
  48474. * Removes all the elements in the container from the scene
  48475. * @param container contains the elements to remove
  48476. */
  48477. removeFromContainer(container: AbstractScene): void;
  48478. /**
  48479. * Rebuilds the elements related to this component in case of
  48480. * context lost for instance.
  48481. */
  48482. dispose(): void;
  48483. private _gatherRenderTargets;
  48484. }
  48485. }
  48486. declare module "babylonjs/Lights/Shadows/index" {
  48487. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  48488. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  48489. }
  48490. declare module "babylonjs/Lights/directionalLight" {
  48491. import { Camera } from "babylonjs/Cameras/camera";
  48492. import { Scene } from "babylonjs/scene";
  48493. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48494. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48495. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48496. import { Effect } from "babylonjs/Materials/effect";
  48497. /**
  48498. * A directional light is defined by a direction (what a surprise!).
  48499. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  48500. * 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.
  48501. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48502. */
  48503. export class DirectionalLight extends ShadowLight {
  48504. private _shadowFrustumSize;
  48505. /**
  48506. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  48507. */
  48508. /**
  48509. * Specifies a fix frustum size for the shadow generation.
  48510. */
  48511. shadowFrustumSize: number;
  48512. private _shadowOrthoScale;
  48513. /**
  48514. * Gets the shadow projection scale against the optimal computed one.
  48515. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48516. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48517. */
  48518. /**
  48519. * Sets the shadow projection scale against the optimal computed one.
  48520. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48521. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48522. */
  48523. shadowOrthoScale: number;
  48524. /**
  48525. * Automatically compute the projection matrix to best fit (including all the casters)
  48526. * on each frame.
  48527. */
  48528. autoUpdateExtends: boolean;
  48529. private _orthoLeft;
  48530. private _orthoRight;
  48531. private _orthoTop;
  48532. private _orthoBottom;
  48533. /**
  48534. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  48535. * The directional light is emitted from everywhere in the given direction.
  48536. * It can cast shadows.
  48537. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48538. * @param name The friendly name of the light
  48539. * @param direction The direction of the light
  48540. * @param scene The scene the light belongs to
  48541. */
  48542. constructor(name: string, direction: Vector3, scene: Scene);
  48543. /**
  48544. * Returns the string "DirectionalLight".
  48545. * @return The class name
  48546. */
  48547. getClassName(): string;
  48548. /**
  48549. * Returns the integer 1.
  48550. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48551. */
  48552. getTypeID(): number;
  48553. /**
  48554. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  48555. * Returns the DirectionalLight Shadow projection matrix.
  48556. */
  48557. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48558. /**
  48559. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48560. * Returns the DirectionalLight Shadow projection matrix.
  48561. */
  48562. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  48563. /**
  48564. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48565. * Returns the DirectionalLight Shadow projection matrix.
  48566. */
  48567. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48568. protected _buildUniformLayout(): void;
  48569. /**
  48570. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48571. * @param effect The effect to update
  48572. * @param lightIndex The index of the light in the effect to update
  48573. * @returns The directional light
  48574. */
  48575. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  48576. /**
  48577. * Gets the minZ used for shadow according to both the scene and the light.
  48578. *
  48579. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48580. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48581. * @param activeCamera The camera we are returning the min for
  48582. * @returns the depth min z
  48583. */
  48584. getDepthMinZ(activeCamera: Camera): number;
  48585. /**
  48586. * Gets the maxZ used for shadow according to both the scene and the light.
  48587. *
  48588. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48589. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48590. * @param activeCamera The camera we are returning the max for
  48591. * @returns the depth max z
  48592. */
  48593. getDepthMaxZ(activeCamera: Camera): number;
  48594. /**
  48595. * Prepares the list of defines specific to the light type.
  48596. * @param defines the list of defines
  48597. * @param lightIndex defines the index of the light for the effect
  48598. */
  48599. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48600. }
  48601. }
  48602. declare module "babylonjs/Lights/pointLight" {
  48603. import { Scene } from "babylonjs/scene";
  48604. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48605. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48606. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48607. import { Effect } from "babylonjs/Materials/effect";
  48608. /**
  48609. * A point light is a light defined by an unique point in world space.
  48610. * The light is emitted in every direction from this point.
  48611. * A good example of a point light is a standard light bulb.
  48612. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48613. */
  48614. export class PointLight extends ShadowLight {
  48615. private _shadowAngle;
  48616. /**
  48617. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48618. * This specifies what angle the shadow will use to be created.
  48619. *
  48620. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48621. */
  48622. /**
  48623. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48624. * This specifies what angle the shadow will use to be created.
  48625. *
  48626. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48627. */
  48628. shadowAngle: number;
  48629. /**
  48630. * Gets the direction if it has been set.
  48631. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48632. */
  48633. /**
  48634. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48635. */
  48636. direction: Vector3;
  48637. /**
  48638. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  48639. * A PointLight emits the light in every direction.
  48640. * It can cast shadows.
  48641. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  48642. * ```javascript
  48643. * var pointLight = new PointLight("pl", camera.position, scene);
  48644. * ```
  48645. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48646. * @param name The light friendly name
  48647. * @param position The position of the point light in the scene
  48648. * @param scene The scene the lights belongs to
  48649. */
  48650. constructor(name: string, position: Vector3, scene: Scene);
  48651. /**
  48652. * Returns the string "PointLight"
  48653. * @returns the class name
  48654. */
  48655. getClassName(): string;
  48656. /**
  48657. * Returns the integer 0.
  48658. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48659. */
  48660. getTypeID(): number;
  48661. /**
  48662. * Specifies wether or not the shadowmap should be a cube texture.
  48663. * @returns true if the shadowmap needs to be a cube texture.
  48664. */
  48665. needCube(): boolean;
  48666. /**
  48667. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  48668. * @param faceIndex The index of the face we are computed the direction to generate shadow
  48669. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  48670. */
  48671. getShadowDirection(faceIndex?: number): Vector3;
  48672. /**
  48673. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  48674. * - fov = PI / 2
  48675. * - aspect ratio : 1.0
  48676. * - z-near and far equal to the active camera minZ and maxZ.
  48677. * Returns the PointLight.
  48678. */
  48679. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48680. protected _buildUniformLayout(): void;
  48681. /**
  48682. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  48683. * @param effect The effect to update
  48684. * @param lightIndex The index of the light in the effect to update
  48685. * @returns The point light
  48686. */
  48687. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  48688. /**
  48689. * Prepares the list of defines specific to the light type.
  48690. * @param defines the list of defines
  48691. * @param lightIndex defines the index of the light for the effect
  48692. */
  48693. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48694. }
  48695. }
  48696. declare module "babylonjs/Lights/spotLight" {
  48697. import { Nullable } from "babylonjs/types";
  48698. import { Scene } from "babylonjs/scene";
  48699. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48700. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48701. import { Effect } from "babylonjs/Materials/effect";
  48702. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48703. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48704. /**
  48705. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48706. * These values define a cone of light starting from the position, emitting toward the direction.
  48707. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48708. * and the exponent defines the speed of the decay of the light with distance (reach).
  48709. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48710. */
  48711. export class SpotLight extends ShadowLight {
  48712. private _angle;
  48713. private _innerAngle;
  48714. private _cosHalfAngle;
  48715. private _lightAngleScale;
  48716. private _lightAngleOffset;
  48717. /**
  48718. * Gets the cone angle of the spot light in Radians.
  48719. */
  48720. /**
  48721. * Sets the cone angle of the spot light in Radians.
  48722. */
  48723. angle: number;
  48724. /**
  48725. * Only used in gltf falloff mode, this defines the angle where
  48726. * the directional falloff will start before cutting at angle which could be seen
  48727. * as outer angle.
  48728. */
  48729. /**
  48730. * Only used in gltf falloff mode, this defines the angle where
  48731. * the directional falloff will start before cutting at angle which could be seen
  48732. * as outer angle.
  48733. */
  48734. innerAngle: number;
  48735. private _shadowAngleScale;
  48736. /**
  48737. * Allows scaling the angle of the light for shadow generation only.
  48738. */
  48739. /**
  48740. * Allows scaling the angle of the light for shadow generation only.
  48741. */
  48742. shadowAngleScale: number;
  48743. /**
  48744. * The light decay speed with the distance from the emission spot.
  48745. */
  48746. exponent: number;
  48747. private _projectionTextureMatrix;
  48748. /**
  48749. * Allows reading the projecton texture
  48750. */
  48751. readonly projectionTextureMatrix: Matrix;
  48752. protected _projectionTextureLightNear: number;
  48753. /**
  48754. * Gets the near clip of the Spotlight for texture projection.
  48755. */
  48756. /**
  48757. * Sets the near clip of the Spotlight for texture projection.
  48758. */
  48759. projectionTextureLightNear: number;
  48760. protected _projectionTextureLightFar: number;
  48761. /**
  48762. * Gets the far clip of the Spotlight for texture projection.
  48763. */
  48764. /**
  48765. * Sets the far clip of the Spotlight for texture projection.
  48766. */
  48767. projectionTextureLightFar: number;
  48768. protected _projectionTextureUpDirection: Vector3;
  48769. /**
  48770. * Gets the Up vector of the Spotlight for texture projection.
  48771. */
  48772. /**
  48773. * Sets the Up vector of the Spotlight for texture projection.
  48774. */
  48775. projectionTextureUpDirection: Vector3;
  48776. private _projectionTexture;
  48777. /**
  48778. * Gets the projection texture of the light.
  48779. */
  48780. /**
  48781. * Sets the projection texture of the light.
  48782. */
  48783. projectionTexture: Nullable<BaseTexture>;
  48784. private _projectionTextureViewLightDirty;
  48785. private _projectionTextureProjectionLightDirty;
  48786. private _projectionTextureDirty;
  48787. private _projectionTextureViewTargetVector;
  48788. private _projectionTextureViewLightMatrix;
  48789. private _projectionTextureProjectionLightMatrix;
  48790. private _projectionTextureScalingMatrix;
  48791. /**
  48792. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48793. * It can cast shadows.
  48794. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48795. * @param name The light friendly name
  48796. * @param position The position of the spot light in the scene
  48797. * @param direction The direction of the light in the scene
  48798. * @param angle The cone angle of the light in Radians
  48799. * @param exponent The light decay speed with the distance from the emission spot
  48800. * @param scene The scene the lights belongs to
  48801. */
  48802. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  48803. /**
  48804. * Returns the string "SpotLight".
  48805. * @returns the class name
  48806. */
  48807. getClassName(): string;
  48808. /**
  48809. * Returns the integer 2.
  48810. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48811. */
  48812. getTypeID(): number;
  48813. /**
  48814. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48815. */
  48816. protected _setDirection(value: Vector3): void;
  48817. /**
  48818. * Overrides the position setter to recompute the projection texture view light Matrix.
  48819. */
  48820. protected _setPosition(value: Vector3): void;
  48821. /**
  48822. * 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.
  48823. * Returns the SpotLight.
  48824. */
  48825. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48826. protected _computeProjectionTextureViewLightMatrix(): void;
  48827. protected _computeProjectionTextureProjectionLightMatrix(): void;
  48828. /**
  48829. * Main function for light texture projection matrix computing.
  48830. */
  48831. protected _computeProjectionTextureMatrix(): void;
  48832. protected _buildUniformLayout(): void;
  48833. private _computeAngleValues;
  48834. /**
  48835. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48836. * @param effect The effect to update
  48837. * @param lightIndex The index of the light in the effect to update
  48838. * @returns The spot light
  48839. */
  48840. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  48841. /**
  48842. * Disposes the light and the associated resources.
  48843. */
  48844. dispose(): void;
  48845. /**
  48846. * Prepares the list of defines specific to the light type.
  48847. * @param defines the list of defines
  48848. * @param lightIndex defines the index of the light for the effect
  48849. */
  48850. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48851. }
  48852. }
  48853. declare module "babylonjs/Lights/index" {
  48854. export * from "babylonjs/Lights/light";
  48855. export * from "babylonjs/Lights/shadowLight";
  48856. export * from "babylonjs/Lights/Shadows/index";
  48857. export * from "babylonjs/Lights/directionalLight";
  48858. export * from "babylonjs/Lights/hemisphericLight";
  48859. export * from "babylonjs/Lights/pointLight";
  48860. export * from "babylonjs/Lights/spotLight";
  48861. }
  48862. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  48863. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  48864. /**
  48865. * Header information of HDR texture files.
  48866. */
  48867. export interface HDRInfo {
  48868. /**
  48869. * The height of the texture in pixels.
  48870. */
  48871. height: number;
  48872. /**
  48873. * The width of the texture in pixels.
  48874. */
  48875. width: number;
  48876. /**
  48877. * The index of the beginning of the data in the binary file.
  48878. */
  48879. dataPosition: number;
  48880. }
  48881. /**
  48882. * This groups tools to convert HDR texture to native colors array.
  48883. */
  48884. export class HDRTools {
  48885. private static Ldexp;
  48886. private static Rgbe2float;
  48887. private static readStringLine;
  48888. /**
  48889. * Reads header information from an RGBE texture stored in a native array.
  48890. * More information on this format are available here:
  48891. * https://en.wikipedia.org/wiki/RGBE_image_format
  48892. *
  48893. * @param uint8array The binary file stored in native array.
  48894. * @return The header information.
  48895. */
  48896. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  48897. /**
  48898. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  48899. * This RGBE texture needs to store the information as a panorama.
  48900. *
  48901. * More information on this format are available here:
  48902. * https://en.wikipedia.org/wiki/RGBE_image_format
  48903. *
  48904. * @param buffer The binary file stored in an array buffer.
  48905. * @param size The expected size of the extracted cubemap.
  48906. * @return The Cube Map information.
  48907. */
  48908. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  48909. /**
  48910. * Returns the pixels data extracted from an RGBE texture.
  48911. * This pixels will be stored left to right up to down in the R G B order in one array.
  48912. *
  48913. * More information on this format are available here:
  48914. * https://en.wikipedia.org/wiki/RGBE_image_format
  48915. *
  48916. * @param uint8array The binary file stored in an array buffer.
  48917. * @param hdrInfo The header information of the file.
  48918. * @return The pixels data in RGB right to left up to down order.
  48919. */
  48920. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  48921. private static RGBE_ReadPixels_RLE;
  48922. }
  48923. }
  48924. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  48925. import { Nullable } from "babylonjs/types";
  48926. import { Scene } from "babylonjs/scene";
  48927. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48928. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48929. /**
  48930. * This represents a texture coming from an HDR input.
  48931. *
  48932. * The only supported format is currently panorama picture stored in RGBE format.
  48933. * Example of such files can be found on HDRLib: http://hdrlib.com/
  48934. */
  48935. export class HDRCubeTexture extends BaseTexture {
  48936. private static _facesMapping;
  48937. private _generateHarmonics;
  48938. private _noMipmap;
  48939. private _textureMatrix;
  48940. private _size;
  48941. private _onLoad;
  48942. private _onError;
  48943. /**
  48944. * The texture URL.
  48945. */
  48946. url: string;
  48947. /**
  48948. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  48949. */
  48950. coordinatesMode: number;
  48951. protected _isBlocking: boolean;
  48952. /**
  48953. * Sets wether or not the texture is blocking during loading.
  48954. */
  48955. /**
  48956. * Gets wether or not the texture is blocking during loading.
  48957. */
  48958. isBlocking: boolean;
  48959. protected _rotationY: number;
  48960. /**
  48961. * Sets texture matrix rotation angle around Y axis in radians.
  48962. */
  48963. /**
  48964. * Gets texture matrix rotation angle around Y axis radians.
  48965. */
  48966. rotationY: number;
  48967. /**
  48968. * Gets or sets the center of the bounding box associated with the cube texture
  48969. * It must define where the camera used to render the texture was set
  48970. */
  48971. boundingBoxPosition: Vector3;
  48972. private _boundingBoxSize;
  48973. /**
  48974. * Gets or sets the size of the bounding box associated with the cube texture
  48975. * When defined, the cubemap will switch to local mode
  48976. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  48977. * @example https://www.babylonjs-playground.com/#RNASML
  48978. */
  48979. boundingBoxSize: Vector3;
  48980. /**
  48981. * Instantiates an HDRTexture from the following parameters.
  48982. *
  48983. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  48984. * @param scene The scene the texture will be used in
  48985. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48986. * @param noMipmap Forces to not generate the mipmap if true
  48987. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  48988. * @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)
  48989. * @param reserved Reserved flag for internal use.
  48990. */
  48991. 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>);
  48992. /**
  48993. * Get the current class name of the texture useful for serialization or dynamic coding.
  48994. * @returns "HDRCubeTexture"
  48995. */
  48996. getClassName(): string;
  48997. /**
  48998. * Occurs when the file is raw .hdr file.
  48999. */
  49000. private loadTexture;
  49001. clone(): HDRCubeTexture;
  49002. delayLoad(): void;
  49003. /**
  49004. * Get the texture reflection matrix used to rotate/transform the reflection.
  49005. * @returns the reflection matrix
  49006. */
  49007. getReflectionTextureMatrix(): Matrix;
  49008. /**
  49009. * Set the texture reflection matrix used to rotate/transform the reflection.
  49010. * @param value Define the reflection matrix to set
  49011. */
  49012. setReflectionTextureMatrix(value: Matrix): void;
  49013. /**
  49014. * Parses a JSON representation of an HDR Texture in order to create the texture
  49015. * @param parsedTexture Define the JSON representation
  49016. * @param scene Define the scene the texture should be created in
  49017. * @param rootUrl Define the root url in case we need to load relative dependencies
  49018. * @returns the newly created texture after parsing
  49019. */
  49020. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  49021. serialize(): any;
  49022. }
  49023. }
  49024. declare module "babylonjs/Physics/physicsEngine" {
  49025. import { Nullable } from "babylonjs/types";
  49026. import { Vector3 } from "babylonjs/Maths/math";
  49027. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  49028. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  49029. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  49030. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49031. /**
  49032. * Class used to control physics engine
  49033. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  49034. */
  49035. export class PhysicsEngine implements IPhysicsEngine {
  49036. private _physicsPlugin;
  49037. /**
  49038. * Global value used to control the smallest number supported by the simulation
  49039. */
  49040. static Epsilon: number;
  49041. private _impostors;
  49042. private _joints;
  49043. /**
  49044. * Gets the gravity vector used by the simulation
  49045. */
  49046. gravity: Vector3;
  49047. /**
  49048. * Factory used to create the default physics plugin.
  49049. * @returns The default physics plugin
  49050. */
  49051. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  49052. /**
  49053. * Creates a new Physics Engine
  49054. * @param gravity defines the gravity vector used by the simulation
  49055. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  49056. */
  49057. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  49058. /**
  49059. * Sets the gravity vector used by the simulation
  49060. * @param gravity defines the gravity vector to use
  49061. */
  49062. setGravity(gravity: Vector3): void;
  49063. /**
  49064. * Set the time step of the physics engine.
  49065. * Default is 1/60.
  49066. * To slow it down, enter 1/600 for example.
  49067. * To speed it up, 1/30
  49068. * @param newTimeStep defines the new timestep to apply to this world.
  49069. */
  49070. setTimeStep(newTimeStep?: number): void;
  49071. /**
  49072. * Get the time step of the physics engine.
  49073. * @returns the current time step
  49074. */
  49075. getTimeStep(): number;
  49076. /**
  49077. * Release all resources
  49078. */
  49079. dispose(): void;
  49080. /**
  49081. * Gets the name of the current physics plugin
  49082. * @returns the name of the plugin
  49083. */
  49084. getPhysicsPluginName(): string;
  49085. /**
  49086. * Adding a new impostor for the impostor tracking.
  49087. * This will be done by the impostor itself.
  49088. * @param impostor the impostor to add
  49089. */
  49090. addImpostor(impostor: PhysicsImpostor): void;
  49091. /**
  49092. * Remove an impostor from the engine.
  49093. * This impostor and its mesh will not longer be updated by the physics engine.
  49094. * @param impostor the impostor to remove
  49095. */
  49096. removeImpostor(impostor: PhysicsImpostor): void;
  49097. /**
  49098. * Add a joint to the physics engine
  49099. * @param mainImpostor defines the main impostor to which the joint is added.
  49100. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  49101. * @param joint defines the joint that will connect both impostors.
  49102. */
  49103. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49104. /**
  49105. * Removes a joint from the simulation
  49106. * @param mainImpostor defines the impostor used with the joint
  49107. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  49108. * @param joint defines the joint to remove
  49109. */
  49110. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49111. /**
  49112. * Called by the scene. No need to call it.
  49113. * @param delta defines the timespam between frames
  49114. */
  49115. _step(delta: number): void;
  49116. /**
  49117. * Gets the current plugin used to run the simulation
  49118. * @returns current plugin
  49119. */
  49120. getPhysicsPlugin(): IPhysicsEnginePlugin;
  49121. /**
  49122. * Gets the list of physic impostors
  49123. * @returns an array of PhysicsImpostor
  49124. */
  49125. getImpostors(): Array<PhysicsImpostor>;
  49126. /**
  49127. * Gets the impostor for a physics enabled object
  49128. * @param object defines the object impersonated by the impostor
  49129. * @returns the PhysicsImpostor or null if not found
  49130. */
  49131. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  49132. /**
  49133. * Gets the impostor for a physics body object
  49134. * @param body defines physics body used by the impostor
  49135. * @returns the PhysicsImpostor or null if not found
  49136. */
  49137. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  49138. /**
  49139. * Does a raycast in the physics world
  49140. * @param from when should the ray start?
  49141. * @param to when should the ray end?
  49142. * @returns PhysicsRaycastResult
  49143. */
  49144. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49145. }
  49146. }
  49147. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  49148. import { Nullable } from "babylonjs/types";
  49149. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  49150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49151. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  49152. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  49153. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  49154. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49155. /** @hidden */
  49156. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  49157. private _useDeltaForWorldStep;
  49158. world: any;
  49159. name: string;
  49160. private _physicsMaterials;
  49161. private _fixedTimeStep;
  49162. private _cannonRaycastResult;
  49163. private _raycastResult;
  49164. BJSCANNON: any;
  49165. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  49166. setGravity(gravity: Vector3): void;
  49167. setTimeStep(timeStep: number): void;
  49168. getTimeStep(): number;
  49169. executeStep(delta: number): void;
  49170. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49171. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49172. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49173. private _processChildMeshes;
  49174. removePhysicsBody(impostor: PhysicsImpostor): void;
  49175. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49176. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49177. private _addMaterial;
  49178. private _checkWithEpsilon;
  49179. private _createShape;
  49180. private _createHeightmap;
  49181. private _minus90X;
  49182. private _plus90X;
  49183. private _tmpPosition;
  49184. private _tmpDeltaPosition;
  49185. private _tmpUnityRotation;
  49186. private _updatePhysicsBodyTransformation;
  49187. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49188. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49189. isSupported(): boolean;
  49190. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49191. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49192. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49193. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49194. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49195. getBodyMass(impostor: PhysicsImpostor): number;
  49196. getBodyFriction(impostor: PhysicsImpostor): number;
  49197. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49198. getBodyRestitution(impostor: PhysicsImpostor): number;
  49199. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49200. sleepBody(impostor: PhysicsImpostor): void;
  49201. wakeUpBody(impostor: PhysicsImpostor): void;
  49202. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  49203. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49204. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49205. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49206. getRadius(impostor: PhysicsImpostor): number;
  49207. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49208. dispose(): void;
  49209. private _extendNamespace;
  49210. /**
  49211. * Does a raycast in the physics world
  49212. * @param from when should the ray start?
  49213. * @param to when should the ray end?
  49214. * @returns PhysicsRaycastResult
  49215. */
  49216. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49217. }
  49218. }
  49219. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  49220. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  49221. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  49222. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  49223. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49224. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  49225. import { Nullable } from "babylonjs/types";
  49226. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49227. /** @hidden */
  49228. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  49229. world: any;
  49230. name: string;
  49231. BJSOIMO: any;
  49232. private _raycastResult;
  49233. constructor(iterations?: number, oimoInjection?: any);
  49234. setGravity(gravity: Vector3): void;
  49235. setTimeStep(timeStep: number): void;
  49236. getTimeStep(): number;
  49237. private _tmpImpostorsArray;
  49238. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49239. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49240. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49241. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49242. private _tmpPositionVector;
  49243. removePhysicsBody(impostor: PhysicsImpostor): void;
  49244. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49245. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49246. isSupported(): boolean;
  49247. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49248. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49249. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49250. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49251. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49252. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49253. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49254. getBodyMass(impostor: PhysicsImpostor): number;
  49255. getBodyFriction(impostor: PhysicsImpostor): number;
  49256. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49257. getBodyRestitution(impostor: PhysicsImpostor): number;
  49258. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49259. sleepBody(impostor: PhysicsImpostor): void;
  49260. wakeUpBody(impostor: PhysicsImpostor): void;
  49261. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49262. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  49263. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  49264. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49265. getRadius(impostor: PhysicsImpostor): number;
  49266. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49267. dispose(): void;
  49268. /**
  49269. * Does a raycast in the physics world
  49270. * @param from when should the ray start?
  49271. * @param to when should the ray end?
  49272. * @returns PhysicsRaycastResult
  49273. */
  49274. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49275. }
  49276. }
  49277. declare module "babylonjs/Probes/reflectionProbe" {
  49278. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49279. import { Vector3 } from "babylonjs/Maths/math";
  49280. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49281. import { Nullable } from "babylonjs/types";
  49282. import { Scene } from "babylonjs/scene";
  49283. module "babylonjs/abstractScene" {
  49284. interface AbstractScene {
  49285. /**
  49286. * The list of reflection probes added to the scene
  49287. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49288. */
  49289. reflectionProbes: Array<ReflectionProbe>;
  49290. /**
  49291. * Removes the given reflection probe from this scene.
  49292. * @param toRemove The reflection probe to remove
  49293. * @returns The index of the removed reflection probe
  49294. */
  49295. removeReflectionProbe(toRemove: ReflectionProbe): number;
  49296. /**
  49297. * Adds the given reflection probe to this scene.
  49298. * @param newReflectionProbe The reflection probe to add
  49299. */
  49300. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  49301. }
  49302. }
  49303. /**
  49304. * Class used to generate realtime reflection / refraction cube textures
  49305. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49306. */
  49307. export class ReflectionProbe {
  49308. /** defines the name of the probe */
  49309. name: string;
  49310. private _scene;
  49311. private _renderTargetTexture;
  49312. private _projectionMatrix;
  49313. private _viewMatrix;
  49314. private _target;
  49315. private _add;
  49316. private _attachedMesh;
  49317. private _invertYAxis;
  49318. /** Gets or sets probe position (center of the cube map) */
  49319. position: Vector3;
  49320. /**
  49321. * Creates a new reflection probe
  49322. * @param name defines the name of the probe
  49323. * @param size defines the texture resolution (for each face)
  49324. * @param scene defines the hosting scene
  49325. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  49326. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  49327. */
  49328. constructor(
  49329. /** defines the name of the probe */
  49330. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  49331. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  49332. samples: number;
  49333. /** Gets or sets the refresh rate to use (on every frame by default) */
  49334. refreshRate: number;
  49335. /**
  49336. * Gets the hosting scene
  49337. * @returns a Scene
  49338. */
  49339. getScene(): Scene;
  49340. /** Gets the internal CubeTexture used to render to */
  49341. readonly cubeTexture: RenderTargetTexture;
  49342. /** Gets the list of meshes to render */
  49343. readonly renderList: Nullable<AbstractMesh[]>;
  49344. /**
  49345. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  49346. * @param mesh defines the mesh to attach to
  49347. */
  49348. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49349. /**
  49350. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  49351. * @param renderingGroupId The rendering group id corresponding to its index
  49352. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  49353. */
  49354. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  49355. /**
  49356. * Clean all associated resources
  49357. */
  49358. dispose(): void;
  49359. /**
  49360. * Converts the reflection probe information to a readable string for debug purpose.
  49361. * @param fullDetails Supports for multiple levels of logging within scene loading
  49362. * @returns the human readable reflection probe info
  49363. */
  49364. toString(fullDetails?: boolean): string;
  49365. /**
  49366. * Get the class name of the relfection probe.
  49367. * @returns "ReflectionProbe"
  49368. */
  49369. getClassName(): string;
  49370. /**
  49371. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  49372. * @returns The JSON representation of the texture
  49373. */
  49374. serialize(): any;
  49375. /**
  49376. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  49377. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  49378. * @param scene Define the scene the parsed reflection probe should be instantiated in
  49379. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  49380. * @returns The parsed reflection probe if successful
  49381. */
  49382. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  49383. }
  49384. }
  49385. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  49386. /** @hidden */
  49387. export var _BabylonLoaderRegistered: boolean;
  49388. }
  49389. declare module "babylonjs/Loading/Plugins/index" {
  49390. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  49391. }
  49392. declare module "babylonjs/Loading/index" {
  49393. export * from "babylonjs/Loading/loadingScreen";
  49394. export * from "babylonjs/Loading/Plugins/index";
  49395. export * from "babylonjs/Loading/sceneLoader";
  49396. export * from "babylonjs/Loading/sceneLoaderFlags";
  49397. }
  49398. declare module "babylonjs/Materials/Background/index" {
  49399. export * from "babylonjs/Materials/Background/backgroundMaterial";
  49400. }
  49401. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  49402. import { Scene } from "babylonjs/scene";
  49403. import { Color3 } from "babylonjs/Maths/math";
  49404. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  49405. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49406. /**
  49407. * The Physically based simple base material of BJS.
  49408. *
  49409. * This enables better naming and convention enforcements on top of the pbrMaterial.
  49410. * It is used as the base class for both the specGloss and metalRough conventions.
  49411. */
  49412. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  49413. /**
  49414. * Number of Simultaneous lights allowed on the material.
  49415. */
  49416. maxSimultaneousLights: number;
  49417. /**
  49418. * If sets to true, disables all the lights affecting the material.
  49419. */
  49420. disableLighting: boolean;
  49421. /**
  49422. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  49423. */
  49424. environmentTexture: BaseTexture;
  49425. /**
  49426. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49427. */
  49428. invertNormalMapX: boolean;
  49429. /**
  49430. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49431. */
  49432. invertNormalMapY: boolean;
  49433. /**
  49434. * Normal map used in the model.
  49435. */
  49436. normalTexture: BaseTexture;
  49437. /**
  49438. * Emissivie color used to self-illuminate the model.
  49439. */
  49440. emissiveColor: Color3;
  49441. /**
  49442. * Emissivie texture used to self-illuminate the model.
  49443. */
  49444. emissiveTexture: BaseTexture;
  49445. /**
  49446. * Occlusion Channel Strenght.
  49447. */
  49448. occlusionStrength: number;
  49449. /**
  49450. * Occlusion Texture of the material (adding extra occlusion effects).
  49451. */
  49452. occlusionTexture: BaseTexture;
  49453. /**
  49454. * Defines the alpha limits in alpha test mode.
  49455. */
  49456. alphaCutOff: number;
  49457. /**
  49458. * Gets the current double sided mode.
  49459. */
  49460. /**
  49461. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49462. */
  49463. doubleSided: boolean;
  49464. /**
  49465. * Stores the pre-calculated light information of a mesh in a texture.
  49466. */
  49467. lightmapTexture: BaseTexture;
  49468. /**
  49469. * If true, the light map contains occlusion information instead of lighting info.
  49470. */
  49471. useLightmapAsShadowmap: boolean;
  49472. /**
  49473. * Instantiates a new PBRMaterial instance.
  49474. *
  49475. * @param name The material name
  49476. * @param scene The scene the material will be use in.
  49477. */
  49478. constructor(name: string, scene: Scene);
  49479. getClassName(): string;
  49480. }
  49481. }
  49482. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  49483. import { Scene } from "babylonjs/scene";
  49484. import { Color3 } from "babylonjs/Maths/math";
  49485. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49486. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  49487. /**
  49488. * The PBR material of BJS following the metal roughness convention.
  49489. *
  49490. * This fits to the PBR convention in the GLTF definition:
  49491. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  49492. */
  49493. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  49494. /**
  49495. * The base color has two different interpretations depending on the value of metalness.
  49496. * When the material is a metal, the base color is the specific measured reflectance value
  49497. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  49498. * of the material.
  49499. */
  49500. baseColor: Color3;
  49501. /**
  49502. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  49503. * well as opacity information in the alpha channel.
  49504. */
  49505. baseTexture: BaseTexture;
  49506. /**
  49507. * Specifies the metallic scalar value of the material.
  49508. * Can also be used to scale the metalness values of the metallic texture.
  49509. */
  49510. metallic: number;
  49511. /**
  49512. * Specifies the roughness scalar value of the material.
  49513. * Can also be used to scale the roughness values of the metallic texture.
  49514. */
  49515. roughness: number;
  49516. /**
  49517. * Texture containing both the metallic value in the B channel and the
  49518. * roughness value in the G channel to keep better precision.
  49519. */
  49520. metallicRoughnessTexture: BaseTexture;
  49521. /**
  49522. * Instantiates a new PBRMetalRoughnessMaterial instance.
  49523. *
  49524. * @param name The material name
  49525. * @param scene The scene the material will be use in.
  49526. */
  49527. constructor(name: string, scene: Scene);
  49528. /**
  49529. * Return the currrent class name of the material.
  49530. */
  49531. getClassName(): string;
  49532. /**
  49533. * Makes a duplicate of the current material.
  49534. * @param name - name to use for the new material.
  49535. */
  49536. clone(name: string): PBRMetallicRoughnessMaterial;
  49537. /**
  49538. * Serialize the material to a parsable JSON object.
  49539. */
  49540. serialize(): any;
  49541. /**
  49542. * Parses a JSON object correponding to the serialize function.
  49543. */
  49544. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  49545. }
  49546. }
  49547. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  49548. import { Scene } from "babylonjs/scene";
  49549. import { Color3 } from "babylonjs/Maths/math";
  49550. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49551. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  49552. /**
  49553. * The PBR material of BJS following the specular glossiness convention.
  49554. *
  49555. * This fits to the PBR convention in the GLTF definition:
  49556. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  49557. */
  49558. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  49559. /**
  49560. * Specifies the diffuse color of the material.
  49561. */
  49562. diffuseColor: Color3;
  49563. /**
  49564. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  49565. * channel.
  49566. */
  49567. diffuseTexture: BaseTexture;
  49568. /**
  49569. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  49570. */
  49571. specularColor: Color3;
  49572. /**
  49573. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  49574. */
  49575. glossiness: number;
  49576. /**
  49577. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  49578. */
  49579. specularGlossinessTexture: BaseTexture;
  49580. /**
  49581. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  49582. *
  49583. * @param name The material name
  49584. * @param scene The scene the material will be use in.
  49585. */
  49586. constructor(name: string, scene: Scene);
  49587. /**
  49588. * Return the currrent class name of the material.
  49589. */
  49590. getClassName(): string;
  49591. /**
  49592. * Makes a duplicate of the current material.
  49593. * @param name - name to use for the new material.
  49594. */
  49595. clone(name: string): PBRSpecularGlossinessMaterial;
  49596. /**
  49597. * Serialize the material to a parsable JSON object.
  49598. */
  49599. serialize(): any;
  49600. /**
  49601. * Parses a JSON object correponding to the serialize function.
  49602. */
  49603. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  49604. }
  49605. }
  49606. declare module "babylonjs/Materials/PBR/index" {
  49607. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  49608. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  49609. export * from "babylonjs/Materials/PBR/pbrMaterial";
  49610. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  49611. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  49612. }
  49613. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  49614. import { Nullable } from "babylonjs/types";
  49615. import { Scene } from "babylonjs/scene";
  49616. import { Matrix } from "babylonjs/Maths/math";
  49617. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49618. /**
  49619. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  49620. * It can help converting any input color in a desired output one. This can then be used to create effects
  49621. * from sepia, black and white to sixties or futuristic rendering...
  49622. *
  49623. * The only supported format is currently 3dl.
  49624. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  49625. */
  49626. export class ColorGradingTexture extends BaseTexture {
  49627. /**
  49628. * The current texture matrix. (will always be identity in color grading texture)
  49629. */
  49630. private _textureMatrix;
  49631. /**
  49632. * The texture URL.
  49633. */
  49634. url: string;
  49635. /**
  49636. * Empty line regex stored for GC.
  49637. */
  49638. private static _noneEmptyLineRegex;
  49639. private _engine;
  49640. /**
  49641. * Instantiates a ColorGradingTexture from the following parameters.
  49642. *
  49643. * @param url The location of the color gradind data (currently only supporting 3dl)
  49644. * @param scene The scene the texture will be used in
  49645. */
  49646. constructor(url: string, scene: Scene);
  49647. /**
  49648. * Returns the texture matrix used in most of the material.
  49649. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  49650. */
  49651. getTextureMatrix(): Matrix;
  49652. /**
  49653. * Occurs when the file being loaded is a .3dl LUT file.
  49654. */
  49655. private load3dlTexture;
  49656. /**
  49657. * Starts the loading process of the texture.
  49658. */
  49659. private loadTexture;
  49660. /**
  49661. * Clones the color gradind texture.
  49662. */
  49663. clone(): ColorGradingTexture;
  49664. /**
  49665. * Called during delayed load for textures.
  49666. */
  49667. delayLoad(): void;
  49668. /**
  49669. * Parses a color grading texture serialized by Babylon.
  49670. * @param parsedTexture The texture information being parsedTexture
  49671. * @param scene The scene to load the texture in
  49672. * @param rootUrl The root url of the data assets to load
  49673. * @return A color gradind texture
  49674. */
  49675. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  49676. /**
  49677. * Serializes the LUT texture to json format.
  49678. */
  49679. serialize(): any;
  49680. }
  49681. }
  49682. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  49683. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49684. import { Scene } from "babylonjs/scene";
  49685. import { Nullable } from "babylonjs/types";
  49686. /**
  49687. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  49688. */
  49689. export class EquiRectangularCubeTexture extends BaseTexture {
  49690. /** The six faces of the cube. */
  49691. private static _FacesMapping;
  49692. private _noMipmap;
  49693. private _onLoad;
  49694. private _onError;
  49695. /** The size of the cubemap. */
  49696. private _size;
  49697. /** The buffer of the image. */
  49698. private _buffer;
  49699. /** The width of the input image. */
  49700. private _width;
  49701. /** The height of the input image. */
  49702. private _height;
  49703. /** The URL to the image. */
  49704. url: string;
  49705. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  49706. coordinatesMode: number;
  49707. /**
  49708. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  49709. * @param url The location of the image
  49710. * @param scene The scene the texture will be used in
  49711. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49712. * @param noMipmap Forces to not generate the mipmap if true
  49713. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  49714. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  49715. * @param onLoad — defines a callback called when texture is loaded
  49716. * @param onError — defines a callback called if there is an error
  49717. */
  49718. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  49719. /**
  49720. * Load the image data, by putting the image on a canvas and extracting its buffer.
  49721. */
  49722. private loadImage;
  49723. /**
  49724. * Convert the image buffer into a cubemap and create a CubeTexture.
  49725. */
  49726. private loadTexture;
  49727. /**
  49728. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  49729. * @param buffer The ArrayBuffer that should be converted.
  49730. * @returns The buffer as Float32Array.
  49731. */
  49732. private getFloat32ArrayFromArrayBuffer;
  49733. /**
  49734. * Get the current class name of the texture useful for serialization or dynamic coding.
  49735. * @returns "EquiRectangularCubeTexture"
  49736. */
  49737. getClassName(): string;
  49738. /**
  49739. * Create a clone of the current EquiRectangularCubeTexture and return it.
  49740. * @returns A clone of the current EquiRectangularCubeTexture.
  49741. */
  49742. clone(): EquiRectangularCubeTexture;
  49743. }
  49744. }
  49745. declare module "babylonjs/Misc/tga" {
  49746. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49747. /**
  49748. * Based on jsTGALoader - Javascript loader for TGA file
  49749. * By Vincent Thibault
  49750. * @see http://blog.robrowser.com/javascript-tga-loader.html
  49751. */
  49752. export class TGATools {
  49753. private static _TYPE_INDEXED;
  49754. private static _TYPE_RGB;
  49755. private static _TYPE_GREY;
  49756. private static _TYPE_RLE_INDEXED;
  49757. private static _TYPE_RLE_RGB;
  49758. private static _TYPE_RLE_GREY;
  49759. private static _ORIGIN_MASK;
  49760. private static _ORIGIN_SHIFT;
  49761. private static _ORIGIN_BL;
  49762. private static _ORIGIN_BR;
  49763. private static _ORIGIN_UL;
  49764. private static _ORIGIN_UR;
  49765. /**
  49766. * Gets the header of a TGA file
  49767. * @param data defines the TGA data
  49768. * @returns the header
  49769. */
  49770. static GetTGAHeader(data: Uint8Array): any;
  49771. /**
  49772. * Uploads TGA content to a Babylon Texture
  49773. * @hidden
  49774. */
  49775. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  49776. /** @hidden */
  49777. 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;
  49778. /** @hidden */
  49779. 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;
  49780. /** @hidden */
  49781. 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;
  49782. /** @hidden */
  49783. 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;
  49784. /** @hidden */
  49785. 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;
  49786. /** @hidden */
  49787. 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;
  49788. }
  49789. }
  49790. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  49791. import { Nullable } from "babylonjs/types";
  49792. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49793. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49794. /**
  49795. * Implementation of the TGA Texture Loader.
  49796. * @hidden
  49797. */
  49798. export class _TGATextureLoader implements IInternalTextureLoader {
  49799. /**
  49800. * Defines wether the loader supports cascade loading the different faces.
  49801. */
  49802. readonly supportCascades: boolean;
  49803. /**
  49804. * This returns if the loader support the current file information.
  49805. * @param extension defines the file extension of the file being loaded
  49806. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49807. * @param fallback defines the fallback internal texture if any
  49808. * @param isBase64 defines whether the texture is encoded as a base64
  49809. * @param isBuffer defines whether the texture data are stored as a buffer
  49810. * @returns true if the loader can load the specified file
  49811. */
  49812. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49813. /**
  49814. * Transform the url before loading if required.
  49815. * @param rootUrl the url of the texture
  49816. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49817. * @returns the transformed texture
  49818. */
  49819. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49820. /**
  49821. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49822. * @param rootUrl the url of the texture
  49823. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49824. * @returns the fallback texture
  49825. */
  49826. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49827. /**
  49828. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49829. * @param data contains the texture data
  49830. * @param texture defines the BabylonJS internal texture
  49831. * @param createPolynomials will be true if polynomials have been requested
  49832. * @param onLoad defines the callback to trigger once the texture is ready
  49833. * @param onError defines the callback to trigger in case of error
  49834. */
  49835. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49836. /**
  49837. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49838. * @param data contains the texture data
  49839. * @param texture defines the BabylonJS internal texture
  49840. * @param callback defines the method to call once ready to upload
  49841. */
  49842. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49843. }
  49844. }
  49845. declare module "babylonjs/Materials/Textures/Loaders/index" {
  49846. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  49847. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  49848. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  49849. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  49850. }
  49851. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  49852. import { Scene } from "babylonjs/scene";
  49853. import { Texture } from "babylonjs/Materials/Textures/texture";
  49854. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49855. /**
  49856. * 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.
  49857. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49858. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49859. */
  49860. export class CustomProceduralTexture extends ProceduralTexture {
  49861. private _animate;
  49862. private _time;
  49863. private _config;
  49864. private _texturePath;
  49865. /**
  49866. * Instantiates a new Custom Procedural Texture.
  49867. * 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.
  49868. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49869. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49870. * @param name Define the name of the texture
  49871. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  49872. * @param size Define the size of the texture to create
  49873. * @param scene Define the scene the texture belongs to
  49874. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49875. * @param generateMipMaps Define if the texture should creates mip maps or not
  49876. */
  49877. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49878. private _loadJson;
  49879. /**
  49880. * Is the texture ready to be used ? (rendered at least once)
  49881. * @returns true if ready, otherwise, false.
  49882. */
  49883. isReady(): boolean;
  49884. /**
  49885. * Render the texture to its associated render target.
  49886. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49887. */
  49888. render(useCameraPostProcess?: boolean): void;
  49889. /**
  49890. * Update the list of dependant textures samplers in the shader.
  49891. */
  49892. updateTextures(): void;
  49893. /**
  49894. * Update the uniform values of the procedural texture in the shader.
  49895. */
  49896. updateShaderUniforms(): void;
  49897. /**
  49898. * Define if the texture animates or not.
  49899. */
  49900. animate: boolean;
  49901. }
  49902. }
  49903. declare module "babylonjs/Shaders/noise.fragment" {
  49904. /** @hidden */
  49905. export var noisePixelShader: {
  49906. name: string;
  49907. shader: string;
  49908. };
  49909. }
  49910. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  49911. import { Nullable } from "babylonjs/types";
  49912. import { Scene } from "babylonjs/scene";
  49913. import { Texture } from "babylonjs/Materials/Textures/texture";
  49914. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49915. import "babylonjs/Shaders/noise.fragment";
  49916. /**
  49917. * Class used to generate noise procedural textures
  49918. */
  49919. export class NoiseProceduralTexture extends ProceduralTexture {
  49920. private _time;
  49921. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  49922. brightness: number;
  49923. /** Defines the number of octaves to process */
  49924. octaves: number;
  49925. /** Defines the level of persistence (0.8 by default) */
  49926. persistence: number;
  49927. /** Gets or sets animation speed factor (default is 1) */
  49928. animationSpeedFactor: number;
  49929. /**
  49930. * Creates a new NoiseProceduralTexture
  49931. * @param name defines the name fo the texture
  49932. * @param size defines the size of the texture (default is 256)
  49933. * @param scene defines the hosting scene
  49934. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  49935. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  49936. */
  49937. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49938. private _updateShaderUniforms;
  49939. protected _getDefines(): string;
  49940. /** Generate the current state of the procedural texture */
  49941. render(useCameraPostProcess?: boolean): void;
  49942. /**
  49943. * Serializes this noise procedural texture
  49944. * @returns a serialized noise procedural texture object
  49945. */
  49946. serialize(): any;
  49947. /**
  49948. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49949. * @param parsedTexture defines parsed texture data
  49950. * @param scene defines the current scene
  49951. * @param rootUrl defines the root URL containing noise procedural texture information
  49952. * @returns a parsed NoiseProceduralTexture
  49953. */
  49954. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  49955. }
  49956. }
  49957. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  49958. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  49959. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  49960. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49961. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  49962. }
  49963. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  49964. import { Nullable } from "babylonjs/types";
  49965. import { Scene } from "babylonjs/scene";
  49966. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49967. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49968. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49969. /**
  49970. * Raw cube texture where the raw buffers are passed in
  49971. */
  49972. export class RawCubeTexture extends CubeTexture {
  49973. /**
  49974. * Creates a cube texture where the raw buffers are passed in.
  49975. * @param scene defines the scene the texture is attached to
  49976. * @param data defines the array of data to use to create each face
  49977. * @param size defines the size of the textures
  49978. * @param format defines the format of the data
  49979. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  49980. * @param generateMipMaps defines if the engine should generate the mip levels
  49981. * @param invertY defines if data must be stored with Y axis inverted
  49982. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  49983. * @param compression defines the compression used (null by default)
  49984. */
  49985. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  49986. /**
  49987. * Updates the raw cube texture.
  49988. * @param data defines the data to store
  49989. * @param format defines the data format
  49990. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  49991. * @param invertY defines if data must be stored with Y axis inverted
  49992. * @param compression defines the compression used (null by default)
  49993. * @param level defines which level of the texture to update
  49994. */
  49995. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  49996. /**
  49997. * Updates a raw cube texture with RGBD encoded data.
  49998. * @param data defines the array of data [mipmap][face] to use to create each face
  49999. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  50000. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  50001. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  50002. * @returns a promsie that resolves when the operation is complete
  50003. */
  50004. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  50005. /**
  50006. * Clones the raw cube texture.
  50007. * @return a new cube texture
  50008. */
  50009. clone(): CubeTexture;
  50010. /** @hidden */
  50011. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  50012. }
  50013. }
  50014. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  50015. import { Scene } from "babylonjs/scene";
  50016. import { Texture } from "babylonjs/Materials/Textures/texture";
  50017. /**
  50018. * Class used to store 3D textures containing user data
  50019. */
  50020. export class RawTexture3D extends Texture {
  50021. /** Gets or sets the texture format to use */
  50022. format: number;
  50023. private _engine;
  50024. /**
  50025. * Create a new RawTexture3D
  50026. * @param data defines the data of the texture
  50027. * @param width defines the width of the texture
  50028. * @param height defines the height of the texture
  50029. * @param depth defines the depth of the texture
  50030. * @param format defines the texture format to use
  50031. * @param scene defines the hosting scene
  50032. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  50033. * @param invertY defines if texture must be stored with Y axis inverted
  50034. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  50035. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  50036. */
  50037. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  50038. /** Gets or sets the texture format to use */
  50039. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  50040. /**
  50041. * Update the texture with new data
  50042. * @param data defines the data to store in the texture
  50043. */
  50044. update(data: ArrayBufferView): void;
  50045. }
  50046. }
  50047. declare module "babylonjs/Materials/Textures/refractionTexture" {
  50048. import { Scene } from "babylonjs/scene";
  50049. import { Plane } from "babylonjs/Maths/math";
  50050. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50051. /**
  50052. * Creates a refraction texture used by refraction channel of the standard material.
  50053. * It is like a mirror but to see through a material.
  50054. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50055. */
  50056. export class RefractionTexture extends RenderTargetTexture {
  50057. /**
  50058. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  50059. * 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.
  50060. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50061. */
  50062. refractionPlane: Plane;
  50063. /**
  50064. * Define how deep under the surface we should see.
  50065. */
  50066. depth: number;
  50067. /**
  50068. * Creates a refraction texture used by refraction channel of the standard material.
  50069. * It is like a mirror but to see through a material.
  50070. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50071. * @param name Define the texture name
  50072. * @param size Define the size of the underlying texture
  50073. * @param scene Define the scene the refraction belongs to
  50074. * @param generateMipMaps Define if we need to generate mips level for the refraction
  50075. */
  50076. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  50077. /**
  50078. * Clone the refraction texture.
  50079. * @returns the cloned texture
  50080. */
  50081. clone(): RefractionTexture;
  50082. /**
  50083. * Serialize the texture to a JSON representation you could use in Parse later on
  50084. * @returns the serialized JSON representation
  50085. */
  50086. serialize(): any;
  50087. }
  50088. }
  50089. declare module "babylonjs/Materials/Textures/index" {
  50090. export * from "babylonjs/Materials/Textures/baseTexture";
  50091. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  50092. export * from "babylonjs/Materials/Textures/cubeTexture";
  50093. export * from "babylonjs/Materials/Textures/dynamicTexture";
  50094. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  50095. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  50096. export * from "babylonjs/Materials/Textures/internalTexture";
  50097. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  50098. export * from "babylonjs/Materials/Textures/internalTextureTracker";
  50099. export * from "babylonjs/Materials/Textures/Loaders/index";
  50100. export * from "babylonjs/Materials/Textures/mirrorTexture";
  50101. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  50102. export * from "babylonjs/Materials/Textures/Procedurals/index";
  50103. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  50104. export * from "babylonjs/Materials/Textures/rawTexture";
  50105. export * from "babylonjs/Materials/Textures/rawTexture3D";
  50106. export * from "babylonjs/Materials/Textures/refractionTexture";
  50107. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  50108. export * from "babylonjs/Materials/Textures/texture";
  50109. export * from "babylonjs/Materials/Textures/videoTexture";
  50110. }
  50111. declare module "babylonjs/Materials/index" {
  50112. export * from "babylonjs/Materials/Background/index";
  50113. export * from "babylonjs/Materials/colorCurves";
  50114. export * from "babylonjs/Materials/effect";
  50115. export * from "babylonjs/Materials/fresnelParameters";
  50116. export * from "babylonjs/Materials/imageProcessingConfiguration";
  50117. export * from "babylonjs/Materials/material";
  50118. export * from "babylonjs/Materials/materialDefines";
  50119. export * from "babylonjs/Materials/materialHelper";
  50120. export * from "babylonjs/Materials/multiMaterial";
  50121. export * from "babylonjs/Materials/PBR/index";
  50122. export * from "babylonjs/Materials/pushMaterial";
  50123. export * from "babylonjs/Materials/shaderMaterial";
  50124. export * from "babylonjs/Materials/standardMaterial";
  50125. export * from "babylonjs/Materials/Textures/index";
  50126. export * from "babylonjs/Materials/uniformBuffer";
  50127. export * from "babylonjs/Materials/materialFlags";
  50128. }
  50129. declare module "babylonjs/Maths/index" {
  50130. export * from "babylonjs/Maths/math.scalar";
  50131. export * from "babylonjs/Maths/math";
  50132. export * from "babylonjs/Maths/sphericalPolynomial";
  50133. }
  50134. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  50135. import { IDisposable } from "babylonjs/scene";
  50136. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  50137. /**
  50138. * Configuration for Draco compression
  50139. */
  50140. export interface IDracoCompressionConfiguration {
  50141. /**
  50142. * Configuration for the decoder.
  50143. */
  50144. decoder?: {
  50145. /**
  50146. * The url to the WebAssembly module.
  50147. */
  50148. wasmUrl?: string;
  50149. /**
  50150. * The url to the WebAssembly binary.
  50151. */
  50152. wasmBinaryUrl?: string;
  50153. /**
  50154. * The url to the fallback JavaScript module.
  50155. */
  50156. fallbackUrl?: string;
  50157. };
  50158. }
  50159. /**
  50160. * Draco compression (https://google.github.io/draco/)
  50161. *
  50162. * This class wraps the Draco module.
  50163. *
  50164. * **Encoder**
  50165. *
  50166. * The encoder is not currently implemented.
  50167. *
  50168. * **Decoder**
  50169. *
  50170. * 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.
  50171. *
  50172. * To update the configuration, use the following code:
  50173. * ```javascript
  50174. * DracoCompression.Configuration = {
  50175. * decoder: {
  50176. * wasmUrl: "<url to the WebAssembly library>",
  50177. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  50178. * fallbackUrl: "<url to the fallback JavaScript library>",
  50179. * }
  50180. * };
  50181. * ```
  50182. *
  50183. * 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.
  50184. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  50185. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  50186. *
  50187. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  50188. * ```javascript
  50189. * var dracoCompression = new DracoCompression();
  50190. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  50191. * [VertexBuffer.PositionKind]: 0
  50192. * });
  50193. * ```
  50194. *
  50195. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  50196. */
  50197. export class DracoCompression implements IDisposable {
  50198. private static _DecoderModulePromise;
  50199. /**
  50200. * The configuration. Defaults to the following urls:
  50201. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  50202. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  50203. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  50204. */
  50205. static Configuration: IDracoCompressionConfiguration;
  50206. /**
  50207. * Returns true if the decoder is available.
  50208. */
  50209. static readonly DecoderAvailable: boolean;
  50210. /**
  50211. * Constructor
  50212. */
  50213. constructor();
  50214. /**
  50215. * Stop all async operations and release resources.
  50216. */
  50217. dispose(): void;
  50218. /**
  50219. * Decode Draco compressed mesh data to vertex data.
  50220. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  50221. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  50222. * @returns A promise that resolves with the decoded vertex data
  50223. */
  50224. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  50225. [kind: string]: number;
  50226. }): Promise<VertexData>;
  50227. private static _GetDecoderModule;
  50228. private static _LoadScriptAsync;
  50229. private static _LoadFileAsync;
  50230. }
  50231. }
  50232. declare module "babylonjs/Meshes/Compression/index" {
  50233. export * from "babylonjs/Meshes/Compression/dracoCompression";
  50234. }
  50235. declare module "babylonjs/Meshes/csg" {
  50236. import { Nullable } from "babylonjs/types";
  50237. import { Scene } from "babylonjs/scene";
  50238. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  50239. import { Mesh } from "babylonjs/Meshes/mesh";
  50240. import { Material } from "babylonjs/Materials/material";
  50241. /**
  50242. * Class for building Constructive Solid Geometry
  50243. */
  50244. export class CSG {
  50245. private polygons;
  50246. /**
  50247. * The world matrix
  50248. */
  50249. matrix: Matrix;
  50250. /**
  50251. * Stores the position
  50252. */
  50253. position: Vector3;
  50254. /**
  50255. * Stores the rotation
  50256. */
  50257. rotation: Vector3;
  50258. /**
  50259. * Stores the rotation quaternion
  50260. */
  50261. rotationQuaternion: Nullable<Quaternion>;
  50262. /**
  50263. * Stores the scaling vector
  50264. */
  50265. scaling: Vector3;
  50266. /**
  50267. * Convert the Mesh to CSG
  50268. * @param mesh The Mesh to convert to CSG
  50269. * @returns A new CSG from the Mesh
  50270. */
  50271. static FromMesh(mesh: Mesh): CSG;
  50272. /**
  50273. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  50274. * @param polygons Polygons used to construct a CSG solid
  50275. */
  50276. private static FromPolygons;
  50277. /**
  50278. * Clones, or makes a deep copy, of the CSG
  50279. * @returns A new CSG
  50280. */
  50281. clone(): CSG;
  50282. /**
  50283. * Unions this CSG with another CSG
  50284. * @param csg The CSG to union against this CSG
  50285. * @returns The unioned CSG
  50286. */
  50287. union(csg: CSG): CSG;
  50288. /**
  50289. * Unions this CSG with another CSG in place
  50290. * @param csg The CSG to union against this CSG
  50291. */
  50292. unionInPlace(csg: CSG): void;
  50293. /**
  50294. * Subtracts this CSG with another CSG
  50295. * @param csg The CSG to subtract against this CSG
  50296. * @returns A new CSG
  50297. */
  50298. subtract(csg: CSG): CSG;
  50299. /**
  50300. * Subtracts this CSG with another CSG in place
  50301. * @param csg The CSG to subtact against this CSG
  50302. */
  50303. subtractInPlace(csg: CSG): void;
  50304. /**
  50305. * Intersect this CSG with another CSG
  50306. * @param csg The CSG to intersect against this CSG
  50307. * @returns A new CSG
  50308. */
  50309. intersect(csg: CSG): CSG;
  50310. /**
  50311. * Intersects this CSG with another CSG in place
  50312. * @param csg The CSG to intersect against this CSG
  50313. */
  50314. intersectInPlace(csg: CSG): void;
  50315. /**
  50316. * Return a new CSG solid with solid and empty space switched. This solid is
  50317. * not modified.
  50318. * @returns A new CSG solid with solid and empty space switched
  50319. */
  50320. inverse(): CSG;
  50321. /**
  50322. * Inverses the CSG in place
  50323. */
  50324. inverseInPlace(): void;
  50325. /**
  50326. * This is used to keep meshes transformations so they can be restored
  50327. * when we build back a Babylon Mesh
  50328. * NB : All CSG operations are performed in world coordinates
  50329. * @param csg The CSG to copy the transform attributes from
  50330. * @returns This CSG
  50331. */
  50332. copyTransformAttributes(csg: CSG): CSG;
  50333. /**
  50334. * Build Raw mesh from CSG
  50335. * Coordinates here are in world space
  50336. * @param name The name of the mesh geometry
  50337. * @param scene The Scene
  50338. * @param keepSubMeshes Specifies if the submeshes should be kept
  50339. * @returns A new Mesh
  50340. */
  50341. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  50342. /**
  50343. * Build Mesh from CSG taking material and transforms into account
  50344. * @param name The name of the Mesh
  50345. * @param material The material of the Mesh
  50346. * @param scene The Scene
  50347. * @param keepSubMeshes Specifies if submeshes should be kept
  50348. * @returns The new Mesh
  50349. */
  50350. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  50351. }
  50352. }
  50353. declare module "babylonjs/Meshes/trailMesh" {
  50354. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50355. import { Mesh } from "babylonjs/Meshes/mesh";
  50356. import { Scene } from "babylonjs/scene";
  50357. /**
  50358. * Class used to create a trail following a mesh
  50359. */
  50360. export class TrailMesh extends Mesh {
  50361. private _generator;
  50362. private _autoStart;
  50363. private _running;
  50364. private _diameter;
  50365. private _length;
  50366. private _sectionPolygonPointsCount;
  50367. private _sectionVectors;
  50368. private _sectionNormalVectors;
  50369. private _beforeRenderObserver;
  50370. /**
  50371. * @constructor
  50372. * @param name The value used by scene.getMeshByName() to do a lookup.
  50373. * @param generator The mesh to generate a trail.
  50374. * @param scene The scene to add this mesh to.
  50375. * @param diameter Diameter of trailing mesh. Default is 1.
  50376. * @param length Length of trailing mesh. Default is 60.
  50377. * @param autoStart Automatically start trailing mesh. Default true.
  50378. */
  50379. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  50380. /**
  50381. * "TrailMesh"
  50382. * @returns "TrailMesh"
  50383. */
  50384. getClassName(): string;
  50385. private _createMesh;
  50386. /**
  50387. * Start trailing mesh.
  50388. */
  50389. start(): void;
  50390. /**
  50391. * Stop trailing mesh.
  50392. */
  50393. stop(): void;
  50394. /**
  50395. * Update trailing mesh geometry.
  50396. */
  50397. update(): void;
  50398. /**
  50399. * Returns a new TrailMesh object.
  50400. * @param name is a string, the name given to the new mesh
  50401. * @param newGenerator use new generator object for cloned trail mesh
  50402. * @returns a new mesh
  50403. */
  50404. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  50405. /**
  50406. * Serializes this trail mesh
  50407. * @param serializationObject object to write serialization to
  50408. */
  50409. serialize(serializationObject: any): void;
  50410. /**
  50411. * Parses a serialized trail mesh
  50412. * @param parsedMesh the serialized mesh
  50413. * @param scene the scene to create the trail mesh in
  50414. * @returns the created trail mesh
  50415. */
  50416. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  50417. }
  50418. }
  50419. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  50420. import { Nullable } from "babylonjs/types";
  50421. import { Scene } from "babylonjs/scene";
  50422. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  50423. import { Mesh } from "babylonjs/Meshes/mesh";
  50424. /**
  50425. * Class containing static functions to help procedurally build meshes
  50426. */
  50427. export class RibbonBuilder {
  50428. /**
  50429. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50430. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50431. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50432. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50433. * * 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
  50434. * * 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
  50435. * * 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
  50436. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50437. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50438. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50439. * * 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
  50440. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50441. * * 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
  50442. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50444. * @param name defines the name of the mesh
  50445. * @param options defines the options used to create the mesh
  50446. * @param scene defines the hosting scene
  50447. * @returns the ribbon mesh
  50448. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50449. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50450. */
  50451. static CreateRibbon(name: string, options: {
  50452. pathArray: Vector3[][];
  50453. closeArray?: boolean;
  50454. closePath?: boolean;
  50455. offset?: number;
  50456. updatable?: boolean;
  50457. sideOrientation?: number;
  50458. frontUVs?: Vector4;
  50459. backUVs?: Vector4;
  50460. instance?: Mesh;
  50461. invertUV?: boolean;
  50462. uvs?: Vector2[];
  50463. colors?: Color4[];
  50464. }, scene?: Nullable<Scene>): Mesh;
  50465. }
  50466. }
  50467. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  50468. import { Vector4 } from "babylonjs/Maths/math";
  50469. import { Mesh } from "babylonjs/Meshes/mesh";
  50470. /**
  50471. * Class containing static functions to help procedurally build meshes
  50472. */
  50473. export class TorusKnotBuilder {
  50474. /**
  50475. * Creates a torus knot mesh
  50476. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  50477. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  50478. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  50479. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  50480. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50481. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50482. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50483. * @param name defines the name of the mesh
  50484. * @param options defines the options used to create the mesh
  50485. * @param scene defines the hosting scene
  50486. * @returns the torus knot mesh
  50487. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  50488. */
  50489. static CreateTorusKnot(name: string, options: {
  50490. radius?: number;
  50491. tube?: number;
  50492. radialSegments?: number;
  50493. tubularSegments?: number;
  50494. p?: number;
  50495. q?: number;
  50496. updatable?: boolean;
  50497. sideOrientation?: number;
  50498. frontUVs?: Vector4;
  50499. backUVs?: Vector4;
  50500. }, scene: any): Mesh;
  50501. }
  50502. }
  50503. declare module "babylonjs/Meshes/polygonMesh" {
  50504. import { Scene } from "babylonjs/scene";
  50505. import { Vector2, Path2 } from "babylonjs/Maths/math";
  50506. import { Mesh } from "babylonjs/Meshes/mesh";
  50507. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  50508. /**
  50509. * Polygon
  50510. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  50511. */
  50512. export class Polygon {
  50513. /**
  50514. * Creates a rectangle
  50515. * @param xmin bottom X coord
  50516. * @param ymin bottom Y coord
  50517. * @param xmax top X coord
  50518. * @param ymax top Y coord
  50519. * @returns points that make the resulting rectation
  50520. */
  50521. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  50522. /**
  50523. * Creates a circle
  50524. * @param radius radius of circle
  50525. * @param cx scale in x
  50526. * @param cy scale in y
  50527. * @param numberOfSides number of sides that make up the circle
  50528. * @returns points that make the resulting circle
  50529. */
  50530. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  50531. /**
  50532. * Creates a polygon from input string
  50533. * @param input Input polygon data
  50534. * @returns the parsed points
  50535. */
  50536. static Parse(input: string): Vector2[];
  50537. /**
  50538. * Starts building a polygon from x and y coordinates
  50539. * @param x x coordinate
  50540. * @param y y coordinate
  50541. * @returns the started path2
  50542. */
  50543. static StartingAt(x: number, y: number): Path2;
  50544. }
  50545. /**
  50546. * Builds a polygon
  50547. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  50548. */
  50549. export class PolygonMeshBuilder {
  50550. private _points;
  50551. private _outlinepoints;
  50552. private _holes;
  50553. private _name;
  50554. private _scene;
  50555. private _epoints;
  50556. private _eholes;
  50557. private _addToepoint;
  50558. /**
  50559. * Babylon reference to the earcut plugin.
  50560. */
  50561. bjsEarcut: any;
  50562. /**
  50563. * Creates a PolygonMeshBuilder
  50564. * @param name name of the builder
  50565. * @param contours Path of the polygon
  50566. * @param scene scene to add to when creating the mesh
  50567. * @param earcutInjection can be used to inject your own earcut reference
  50568. */
  50569. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  50570. /**
  50571. * Adds a whole within the polygon
  50572. * @param hole Array of points defining the hole
  50573. * @returns this
  50574. */
  50575. addHole(hole: Vector2[]): PolygonMeshBuilder;
  50576. /**
  50577. * Creates the polygon
  50578. * @param updatable If the mesh should be updatable
  50579. * @param depth The depth of the mesh created
  50580. * @returns the created mesh
  50581. */
  50582. build(updatable?: boolean, depth?: number): Mesh;
  50583. /**
  50584. * Creates the polygon
  50585. * @param depth The depth of the mesh created
  50586. * @returns the created VertexData
  50587. */
  50588. buildVertexData(depth?: number): VertexData;
  50589. /**
  50590. * Adds a side to the polygon
  50591. * @param positions points that make the polygon
  50592. * @param normals normals of the polygon
  50593. * @param uvs uvs of the polygon
  50594. * @param indices indices of the polygon
  50595. * @param bounds bounds of the polygon
  50596. * @param points points of the polygon
  50597. * @param depth depth of the polygon
  50598. * @param flip flip of the polygon
  50599. */
  50600. private addSide;
  50601. }
  50602. }
  50603. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  50604. import { Scene } from "babylonjs/scene";
  50605. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  50606. import { Mesh } from "babylonjs/Meshes/mesh";
  50607. /**
  50608. * Class containing static functions to help procedurally build meshes
  50609. */
  50610. export class PolygonBuilder {
  50611. /**
  50612. * Creates a polygon mesh
  50613. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50614. * * 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
  50615. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50616. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50617. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  50618. * * Remember you can only change the shape positions, not their number when updating a polygon
  50619. * @param name defines the name of the mesh
  50620. * @param options defines the options used to create the mesh
  50621. * @param scene defines the hosting scene
  50622. * @param earcutInjection can be used to inject your own earcut reference
  50623. * @returns the polygon mesh
  50624. */
  50625. static CreatePolygon(name: string, options: {
  50626. shape: Vector3[];
  50627. holes?: Vector3[][];
  50628. depth?: number;
  50629. faceUV?: Vector4[];
  50630. faceColors?: Color4[];
  50631. updatable?: boolean;
  50632. sideOrientation?: number;
  50633. frontUVs?: Vector4;
  50634. backUVs?: Vector4;
  50635. }, scene: Scene, earcutInjection?: any): Mesh;
  50636. /**
  50637. * Creates an extruded polygon mesh, with depth in the Y direction.
  50638. * * 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)
  50639. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50640. * @param name defines the name of the mesh
  50641. * @param options defines the options used to create the mesh
  50642. * @param scene defines the hosting scene
  50643. * @param earcutInjection can be used to inject your own earcut reference
  50644. * @returns the polygon mesh
  50645. */
  50646. static ExtrudePolygon(name: string, options: {
  50647. shape: Vector3[];
  50648. holes?: Vector3[][];
  50649. depth?: number;
  50650. faceUV?: Vector4[];
  50651. faceColors?: Color4[];
  50652. updatable?: boolean;
  50653. sideOrientation?: number;
  50654. frontUVs?: Vector4;
  50655. backUVs?: Vector4;
  50656. }, scene: Scene, earcutInjection?: any): Mesh;
  50657. }
  50658. }
  50659. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  50660. import { Nullable } from "babylonjs/types";
  50661. import { Scene } from "babylonjs/scene";
  50662. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50663. import { Mesh } from "babylonjs/Meshes/mesh";
  50664. /**
  50665. * Class containing static functions to help procedurally build meshes
  50666. */
  50667. export class ShapeBuilder {
  50668. /**
  50669. * 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.
  50670. * * 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.
  50671. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50672. * * 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.
  50673. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50674. * * 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
  50675. * * 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
  50676. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50677. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50678. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50679. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50680. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50681. * @param name defines the name of the mesh
  50682. * @param options defines the options used to create the mesh
  50683. * @param scene defines the hosting scene
  50684. * @returns the extruded shape mesh
  50685. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50686. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50687. */
  50688. static ExtrudeShape(name: string, options: {
  50689. shape: Vector3[];
  50690. path: Vector3[];
  50691. scale?: number;
  50692. rotation?: number;
  50693. cap?: number;
  50694. updatable?: boolean;
  50695. sideOrientation?: number;
  50696. frontUVs?: Vector4;
  50697. backUVs?: Vector4;
  50698. instance?: Mesh;
  50699. invertUV?: boolean;
  50700. }, scene?: Nullable<Scene>): Mesh;
  50701. /**
  50702. * Creates an custom extruded shape mesh.
  50703. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50704. * * 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.
  50705. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50706. * * 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
  50707. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50708. * * 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
  50709. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50710. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50711. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50712. * * 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
  50713. * * 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
  50714. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50715. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50716. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50717. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50718. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50719. * @param name defines the name of the mesh
  50720. * @param options defines the options used to create the mesh
  50721. * @param scene defines the hosting scene
  50722. * @returns the custom extruded shape mesh
  50723. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50724. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50725. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50726. */
  50727. static ExtrudeShapeCustom(name: string, options: {
  50728. shape: Vector3[];
  50729. path: Vector3[];
  50730. scaleFunction?: any;
  50731. rotationFunction?: any;
  50732. ribbonCloseArray?: boolean;
  50733. ribbonClosePath?: boolean;
  50734. cap?: number;
  50735. updatable?: boolean;
  50736. sideOrientation?: number;
  50737. frontUVs?: Vector4;
  50738. backUVs?: Vector4;
  50739. instance?: Mesh;
  50740. invertUV?: boolean;
  50741. }, scene: Scene): Mesh;
  50742. private static _ExtrudeShapeGeneric;
  50743. }
  50744. }
  50745. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  50746. import { Scene } from "babylonjs/scene";
  50747. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50748. import { Mesh } from "babylonjs/Meshes/mesh";
  50749. /**
  50750. * Class containing static functions to help procedurally build meshes
  50751. */
  50752. export class LatheBuilder {
  50753. /**
  50754. * Creates lathe mesh.
  50755. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50756. * * 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
  50757. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50758. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50759. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50760. * * 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
  50761. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50762. * * 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
  50763. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50764. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50765. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50767. * @param name defines the name of the mesh
  50768. * @param options defines the options used to create the mesh
  50769. * @param scene defines the hosting scene
  50770. * @returns the lathe mesh
  50771. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50772. */
  50773. static CreateLathe(name: string, options: {
  50774. shape: Vector3[];
  50775. radius?: number;
  50776. tessellation?: number;
  50777. clip?: number;
  50778. arc?: number;
  50779. closed?: boolean;
  50780. updatable?: boolean;
  50781. sideOrientation?: number;
  50782. frontUVs?: Vector4;
  50783. backUVs?: Vector4;
  50784. cap?: number;
  50785. invertUV?: boolean;
  50786. }, scene: Scene): Mesh;
  50787. }
  50788. }
  50789. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  50790. import { Scene } from "babylonjs/scene";
  50791. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50792. import { Mesh } from "babylonjs/Meshes/mesh";
  50793. /**
  50794. * Class containing static functions to help procedurally build meshes
  50795. */
  50796. export class TubeBuilder {
  50797. /**
  50798. * Creates a tube mesh.
  50799. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50800. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50801. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50802. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50803. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50804. * * 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)
  50805. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50806. * * 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
  50807. * * 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
  50808. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50809. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50810. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50811. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50812. * @param name defines the name of the mesh
  50813. * @param options defines the options used to create the mesh
  50814. * @param scene defines the hosting scene
  50815. * @returns the tube mesh
  50816. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50817. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50818. */
  50819. static CreateTube(name: string, options: {
  50820. path: Vector3[];
  50821. radius?: number;
  50822. tessellation?: number;
  50823. radiusFunction?: {
  50824. (i: number, distance: number): number;
  50825. };
  50826. cap?: number;
  50827. arc?: number;
  50828. updatable?: boolean;
  50829. sideOrientation?: number;
  50830. frontUVs?: Vector4;
  50831. backUVs?: Vector4;
  50832. instance?: Mesh;
  50833. invertUV?: boolean;
  50834. }, scene: Scene): Mesh;
  50835. }
  50836. }
  50837. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  50838. import { Scene } from "babylonjs/scene";
  50839. import { Vector4 } from "babylonjs/Maths/math";
  50840. import { Mesh } from "babylonjs/Meshes/mesh";
  50841. /**
  50842. * Class containing static functions to help procedurally build meshes
  50843. */
  50844. export class IcoSphereBuilder {
  50845. /**
  50846. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50847. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50848. * * 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`)
  50849. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50850. * * 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
  50851. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50852. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50853. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50854. * @param name defines the name of the mesh
  50855. * @param options defines the options used to create the mesh
  50856. * @param scene defines the hosting scene
  50857. * @returns the icosahedron mesh
  50858. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50859. */
  50860. static CreateIcoSphere(name: string, options: {
  50861. radius?: number;
  50862. radiusX?: number;
  50863. radiusY?: number;
  50864. radiusZ?: number;
  50865. flat?: boolean;
  50866. subdivisions?: number;
  50867. sideOrientation?: number;
  50868. frontUVs?: Vector4;
  50869. backUVs?: Vector4;
  50870. updatable?: boolean;
  50871. }, scene: Scene): Mesh;
  50872. }
  50873. }
  50874. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  50875. import { Vector3 } from "babylonjs/Maths/math";
  50876. import { Mesh } from "babylonjs/Meshes/mesh";
  50877. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50878. /**
  50879. * Class containing static functions to help procedurally build meshes
  50880. */
  50881. export class DecalBuilder {
  50882. /**
  50883. * Creates a decal mesh.
  50884. * 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
  50885. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50886. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50887. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50888. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50889. * @param name defines the name of the mesh
  50890. * @param sourceMesh defines the mesh where the decal must be applied
  50891. * @param options defines the options used to create the mesh
  50892. * @param scene defines the hosting scene
  50893. * @returns the decal mesh
  50894. * @see https://doc.babylonjs.com/how_to/decals
  50895. */
  50896. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50897. position?: Vector3;
  50898. normal?: Vector3;
  50899. size?: Vector3;
  50900. angle?: number;
  50901. }): Mesh;
  50902. }
  50903. }
  50904. declare module "babylonjs/Meshes/meshBuilder" {
  50905. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  50906. import { Nullable } from "babylonjs/types";
  50907. import { Scene } from "babylonjs/scene";
  50908. import { Mesh } from "babylonjs/Meshes/mesh";
  50909. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  50910. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  50911. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50912. /**
  50913. * Class containing static functions to help procedurally build meshes
  50914. */
  50915. export class MeshBuilder {
  50916. /**
  50917. * Creates a box mesh
  50918. * * The parameter `size` sets the size (float) of each box side (default 1)
  50919. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50920. * * 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)
  50921. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50922. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50923. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50924. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50925. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50926. * @param name defines the name of the mesh
  50927. * @param options defines the options used to create the mesh
  50928. * @param scene defines the hosting scene
  50929. * @returns the box mesh
  50930. */
  50931. static CreateBox(name: string, options: {
  50932. size?: number;
  50933. width?: number;
  50934. height?: number;
  50935. depth?: number;
  50936. faceUV?: Vector4[];
  50937. faceColors?: Color4[];
  50938. sideOrientation?: number;
  50939. frontUVs?: Vector4;
  50940. backUVs?: Vector4;
  50941. updatable?: boolean;
  50942. }, scene?: Nullable<Scene>): Mesh;
  50943. /**
  50944. * Creates a sphere mesh
  50945. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50946. * * 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`)
  50947. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50948. * * 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
  50949. * * 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)
  50950. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50951. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50952. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50953. * @param name defines the name of the mesh
  50954. * @param options defines the options used to create the mesh
  50955. * @param scene defines the hosting scene
  50956. * @returns the sphere mesh
  50957. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50958. */
  50959. static CreateSphere(name: string, options: {
  50960. segments?: number;
  50961. diameter?: number;
  50962. diameterX?: number;
  50963. diameterY?: number;
  50964. diameterZ?: number;
  50965. arc?: number;
  50966. slice?: number;
  50967. sideOrientation?: number;
  50968. frontUVs?: Vector4;
  50969. backUVs?: Vector4;
  50970. updatable?: boolean;
  50971. }, scene: any): Mesh;
  50972. /**
  50973. * Creates a plane polygonal mesh. By default, this is a disc
  50974. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  50975. * * 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
  50976. * * 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
  50977. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50978. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50979. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50980. * @param name defines the name of the mesh
  50981. * @param options defines the options used to create the mesh
  50982. * @param scene defines the hosting scene
  50983. * @returns the plane polygonal mesh
  50984. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  50985. */
  50986. static CreateDisc(name: string, options: {
  50987. radius?: number;
  50988. tessellation?: number;
  50989. arc?: number;
  50990. updatable?: boolean;
  50991. sideOrientation?: number;
  50992. frontUVs?: Vector4;
  50993. backUVs?: Vector4;
  50994. }, scene?: Nullable<Scene>): Mesh;
  50995. /**
  50996. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50997. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50998. * * 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`)
  50999. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  51000. * * 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
  51001. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51002. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51003. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51004. * @param name defines the name of the mesh
  51005. * @param options defines the options used to create the mesh
  51006. * @param scene defines the hosting scene
  51007. * @returns the icosahedron mesh
  51008. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  51009. */
  51010. static CreateIcoSphere(name: string, options: {
  51011. radius?: number;
  51012. radiusX?: number;
  51013. radiusY?: number;
  51014. radiusZ?: number;
  51015. flat?: boolean;
  51016. subdivisions?: number;
  51017. sideOrientation?: number;
  51018. frontUVs?: Vector4;
  51019. backUVs?: Vector4;
  51020. updatable?: boolean;
  51021. }, scene: Scene): Mesh;
  51022. /**
  51023. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51024. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51025. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51026. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51027. * * 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
  51028. * * 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
  51029. * * 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
  51030. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51031. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51032. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51033. * * 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
  51034. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51035. * * 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
  51036. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51037. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51038. * @param name defines the name of the mesh
  51039. * @param options defines the options used to create the mesh
  51040. * @param scene defines the hosting scene
  51041. * @returns the ribbon mesh
  51042. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51043. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51044. */
  51045. static CreateRibbon(name: string, options: {
  51046. pathArray: Vector3[][];
  51047. closeArray?: boolean;
  51048. closePath?: boolean;
  51049. offset?: number;
  51050. updatable?: boolean;
  51051. sideOrientation?: number;
  51052. frontUVs?: Vector4;
  51053. backUVs?: Vector4;
  51054. instance?: Mesh;
  51055. invertUV?: boolean;
  51056. uvs?: Vector2[];
  51057. colors?: Color4[];
  51058. }, scene?: Nullable<Scene>): Mesh;
  51059. /**
  51060. * Creates a cylinder or a cone mesh
  51061. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  51062. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  51063. * * 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.
  51064. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  51065. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  51066. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  51067. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  51068. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  51069. * * 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).
  51070. * * 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
  51071. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  51072. * * 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
  51073. * * 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.
  51074. * * If `enclose` is false, a ring surface is one element.
  51075. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  51076. * * 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
  51077. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51078. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51079. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51080. * @param name defines the name of the mesh
  51081. * @param options defines the options used to create the mesh
  51082. * @param scene defines the hosting scene
  51083. * @returns the cylinder mesh
  51084. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  51085. */
  51086. static CreateCylinder(name: string, options: {
  51087. height?: number;
  51088. diameterTop?: number;
  51089. diameterBottom?: number;
  51090. diameter?: number;
  51091. tessellation?: number;
  51092. subdivisions?: number;
  51093. arc?: number;
  51094. faceColors?: Color4[];
  51095. faceUV?: Vector4[];
  51096. updatable?: boolean;
  51097. hasRings?: boolean;
  51098. enclose?: boolean;
  51099. sideOrientation?: number;
  51100. frontUVs?: Vector4;
  51101. backUVs?: Vector4;
  51102. }, scene: any): Mesh;
  51103. /**
  51104. * Creates a torus mesh
  51105. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  51106. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  51107. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  51108. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51109. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51110. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51111. * @param name defines the name of the mesh
  51112. * @param options defines the options used to create the mesh
  51113. * @param scene defines the hosting scene
  51114. * @returns the torus mesh
  51115. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  51116. */
  51117. static CreateTorus(name: string, options: {
  51118. diameter?: number;
  51119. thickness?: number;
  51120. tessellation?: number;
  51121. updatable?: boolean;
  51122. sideOrientation?: number;
  51123. frontUVs?: Vector4;
  51124. backUVs?: Vector4;
  51125. }, scene: any): Mesh;
  51126. /**
  51127. * Creates a torus knot mesh
  51128. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  51129. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  51130. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  51131. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  51132. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51133. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51134. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51135. * @param name defines the name of the mesh
  51136. * @param options defines the options used to create the mesh
  51137. * @param scene defines the hosting scene
  51138. * @returns the torus knot mesh
  51139. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  51140. */
  51141. static CreateTorusKnot(name: string, options: {
  51142. radius?: number;
  51143. tube?: number;
  51144. radialSegments?: number;
  51145. tubularSegments?: number;
  51146. p?: number;
  51147. q?: number;
  51148. updatable?: boolean;
  51149. sideOrientation?: number;
  51150. frontUVs?: Vector4;
  51151. backUVs?: Vector4;
  51152. }, scene: any): Mesh;
  51153. /**
  51154. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  51155. * * 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
  51156. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  51157. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  51158. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  51159. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  51160. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  51161. * * 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
  51162. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  51163. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51164. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  51165. * @param name defines the name of the new line system
  51166. * @param options defines the options used to create the line system
  51167. * @param scene defines the hosting scene
  51168. * @returns a new line system mesh
  51169. */
  51170. static CreateLineSystem(name: string, options: {
  51171. lines: Vector3[][];
  51172. updatable?: boolean;
  51173. instance?: Nullable<LinesMesh>;
  51174. colors?: Nullable<Color4[][]>;
  51175. useVertexAlpha?: boolean;
  51176. }, scene: Nullable<Scene>): LinesMesh;
  51177. /**
  51178. * Creates a line mesh
  51179. * 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
  51180. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  51181. * * The parameter `points` is an array successive Vector3
  51182. * * 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
  51183. * * The optional parameter `colors` is an array of successive Color4, one per line point
  51184. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  51185. * * When updating an instance, remember that only point positions can change, not the number of points
  51186. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51187. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  51188. * @param name defines the name of the new line system
  51189. * @param options defines the options used to create the line system
  51190. * @param scene defines the hosting scene
  51191. * @returns a new line mesh
  51192. */
  51193. static CreateLines(name: string, options: {
  51194. points: Vector3[];
  51195. updatable?: boolean;
  51196. instance?: Nullable<LinesMesh>;
  51197. colors?: Color4[];
  51198. useVertexAlpha?: boolean;
  51199. }, scene?: Nullable<Scene>): LinesMesh;
  51200. /**
  51201. * Creates a dashed line mesh
  51202. * * 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
  51203. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  51204. * * The parameter `points` is an array successive Vector3
  51205. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  51206. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  51207. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  51208. * * 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
  51209. * * When updating an instance, remember that only point positions can change, not the number of points
  51210. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51211. * @param name defines the name of the mesh
  51212. * @param options defines the options used to create the mesh
  51213. * @param scene defines the hosting scene
  51214. * @returns the dashed line mesh
  51215. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  51216. */
  51217. static CreateDashedLines(name: string, options: {
  51218. points: Vector3[];
  51219. dashSize?: number;
  51220. gapSize?: number;
  51221. dashNb?: number;
  51222. updatable?: boolean;
  51223. instance?: LinesMesh;
  51224. }, scene?: Nullable<Scene>): LinesMesh;
  51225. /**
  51226. * 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.
  51227. * * 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.
  51228. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51229. * * 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.
  51230. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51231. * * 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
  51232. * * 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
  51233. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51234. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51235. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51236. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51237. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51238. * @param name defines the name of the mesh
  51239. * @param options defines the options used to create the mesh
  51240. * @param scene defines the hosting scene
  51241. * @returns the extruded shape mesh
  51242. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51243. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51244. */
  51245. static ExtrudeShape(name: string, options: {
  51246. shape: Vector3[];
  51247. path: Vector3[];
  51248. scale?: number;
  51249. rotation?: number;
  51250. cap?: number;
  51251. updatable?: boolean;
  51252. sideOrientation?: number;
  51253. frontUVs?: Vector4;
  51254. backUVs?: Vector4;
  51255. instance?: Mesh;
  51256. invertUV?: boolean;
  51257. }, scene?: Nullable<Scene>): Mesh;
  51258. /**
  51259. * Creates an custom extruded shape mesh.
  51260. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51261. * * 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.
  51262. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51263. * * 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
  51264. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51265. * * 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
  51266. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51267. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51268. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51269. * * 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
  51270. * * 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
  51271. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51272. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51273. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51274. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51276. * @param name defines the name of the mesh
  51277. * @param options defines the options used to create the mesh
  51278. * @param scene defines the hosting scene
  51279. * @returns the custom extruded shape mesh
  51280. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51281. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51282. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51283. */
  51284. static ExtrudeShapeCustom(name: string, options: {
  51285. shape: Vector3[];
  51286. path: Vector3[];
  51287. scaleFunction?: any;
  51288. rotationFunction?: any;
  51289. ribbonCloseArray?: boolean;
  51290. ribbonClosePath?: boolean;
  51291. cap?: number;
  51292. updatable?: boolean;
  51293. sideOrientation?: number;
  51294. frontUVs?: Vector4;
  51295. backUVs?: Vector4;
  51296. instance?: Mesh;
  51297. invertUV?: boolean;
  51298. }, scene: Scene): Mesh;
  51299. /**
  51300. * Creates lathe mesh.
  51301. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  51302. * * 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
  51303. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  51304. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  51305. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  51306. * * 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
  51307. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  51308. * * 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
  51309. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51310. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51311. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51312. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51313. * @param name defines the name of the mesh
  51314. * @param options defines the options used to create the mesh
  51315. * @param scene defines the hosting scene
  51316. * @returns the lathe mesh
  51317. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  51318. */
  51319. static CreateLathe(name: string, options: {
  51320. shape: Vector3[];
  51321. radius?: number;
  51322. tessellation?: number;
  51323. clip?: number;
  51324. arc?: number;
  51325. closed?: boolean;
  51326. updatable?: boolean;
  51327. sideOrientation?: number;
  51328. frontUVs?: Vector4;
  51329. backUVs?: Vector4;
  51330. cap?: number;
  51331. invertUV?: boolean;
  51332. }, scene: Scene): Mesh;
  51333. /**
  51334. * Creates a plane mesh
  51335. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  51336. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  51337. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  51338. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51339. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51341. * @param name defines the name of the mesh
  51342. * @param options defines the options used to create the mesh
  51343. * @param scene defines the hosting scene
  51344. * @returns the plane mesh
  51345. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  51346. */
  51347. static CreatePlane(name: string, options: {
  51348. size?: number;
  51349. width?: number;
  51350. height?: number;
  51351. sideOrientation?: number;
  51352. frontUVs?: Vector4;
  51353. backUVs?: Vector4;
  51354. updatable?: boolean;
  51355. sourcePlane?: Plane;
  51356. }, scene: Scene): Mesh;
  51357. /**
  51358. * Creates a ground mesh
  51359. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  51360. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  51361. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51362. * @param name defines the name of the mesh
  51363. * @param options defines the options used to create the mesh
  51364. * @param scene defines the hosting scene
  51365. * @returns the ground mesh
  51366. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  51367. */
  51368. static CreateGround(name: string, options: {
  51369. width?: number;
  51370. height?: number;
  51371. subdivisions?: number;
  51372. subdivisionsX?: number;
  51373. subdivisionsY?: number;
  51374. updatable?: boolean;
  51375. }, scene: any): Mesh;
  51376. /**
  51377. * Creates a tiled ground mesh
  51378. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  51379. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  51380. * * 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
  51381. * * 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
  51382. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51383. * @param name defines the name of the mesh
  51384. * @param options defines the options used to create the mesh
  51385. * @param scene defines the hosting scene
  51386. * @returns the tiled ground mesh
  51387. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  51388. */
  51389. static CreateTiledGround(name: string, options: {
  51390. xmin: number;
  51391. zmin: number;
  51392. xmax: number;
  51393. zmax: number;
  51394. subdivisions?: {
  51395. w: number;
  51396. h: number;
  51397. };
  51398. precision?: {
  51399. w: number;
  51400. h: number;
  51401. };
  51402. updatable?: boolean;
  51403. }, scene: Scene): Mesh;
  51404. /**
  51405. * Creates a ground mesh from a height map
  51406. * * The parameter `url` sets the URL of the height map image resource.
  51407. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  51408. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  51409. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  51410. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  51411. * * 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.
  51412. * * 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).
  51413. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  51414. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51415. * @param name defines the name of the mesh
  51416. * @param url defines the url to the height map
  51417. * @param options defines the options used to create the mesh
  51418. * @param scene defines the hosting scene
  51419. * @returns the ground mesh
  51420. * @see https://doc.babylonjs.com/babylon101/height_map
  51421. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  51422. */
  51423. static CreateGroundFromHeightMap(name: string, url: string, options: {
  51424. width?: number;
  51425. height?: number;
  51426. subdivisions?: number;
  51427. minHeight?: number;
  51428. maxHeight?: number;
  51429. colorFilter?: Color3;
  51430. alphaFilter?: number;
  51431. updatable?: boolean;
  51432. onReady?: (mesh: GroundMesh) => void;
  51433. }, scene: Scene): GroundMesh;
  51434. /**
  51435. * Creates a polygon mesh
  51436. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  51437. * * 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
  51438. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  51439. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51440. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  51441. * * Remember you can only change the shape positions, not their number when updating a polygon
  51442. * @param name defines the name of the mesh
  51443. * @param options defines the options used to create the mesh
  51444. * @param scene defines the hosting scene
  51445. * @param earcutInjection can be used to inject your own earcut reference
  51446. * @returns the polygon mesh
  51447. */
  51448. static CreatePolygon(name: string, options: {
  51449. shape: Vector3[];
  51450. holes?: Vector3[][];
  51451. depth?: number;
  51452. faceUV?: Vector4[];
  51453. faceColors?: Color4[];
  51454. updatable?: boolean;
  51455. sideOrientation?: number;
  51456. frontUVs?: Vector4;
  51457. backUVs?: Vector4;
  51458. }, scene: Scene, earcutInjection?: any): Mesh;
  51459. /**
  51460. * Creates an extruded polygon mesh, with depth in the Y direction.
  51461. * * 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)
  51462. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51463. * @param name defines the name of the mesh
  51464. * @param options defines the options used to create the mesh
  51465. * @param scene defines the hosting scene
  51466. * @param earcutInjection can be used to inject your own earcut reference
  51467. * @returns the polygon mesh
  51468. */
  51469. static ExtrudePolygon(name: string, options: {
  51470. shape: Vector3[];
  51471. holes?: Vector3[][];
  51472. depth?: number;
  51473. faceUV?: Vector4[];
  51474. faceColors?: Color4[];
  51475. updatable?: boolean;
  51476. sideOrientation?: number;
  51477. frontUVs?: Vector4;
  51478. backUVs?: Vector4;
  51479. }, scene: Scene, earcutInjection?: any): Mesh;
  51480. /**
  51481. * Creates a tube mesh.
  51482. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51483. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  51484. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  51485. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  51486. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  51487. * * 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)
  51488. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  51489. * * 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
  51490. * * 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
  51491. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51492. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51493. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51494. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51495. * @param name defines the name of the mesh
  51496. * @param options defines the options used to create the mesh
  51497. * @param scene defines the hosting scene
  51498. * @returns the tube mesh
  51499. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51500. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  51501. */
  51502. static CreateTube(name: string, options: {
  51503. path: Vector3[];
  51504. radius?: number;
  51505. tessellation?: number;
  51506. radiusFunction?: {
  51507. (i: number, distance: number): number;
  51508. };
  51509. cap?: number;
  51510. arc?: number;
  51511. updatable?: boolean;
  51512. sideOrientation?: number;
  51513. frontUVs?: Vector4;
  51514. backUVs?: Vector4;
  51515. instance?: Mesh;
  51516. invertUV?: boolean;
  51517. }, scene: Scene): Mesh;
  51518. /**
  51519. * Creates a polyhedron mesh
  51520. * * 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
  51521. * * The parameter `size` (positive float, default 1) sets the polygon size
  51522. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  51523. * * 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`
  51524. * * 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
  51525. * * 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)`)
  51526. * * 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
  51527. * * 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
  51528. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51529. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51530. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51531. * @param name defines the name of the mesh
  51532. * @param options defines the options used to create the mesh
  51533. * @param scene defines the hosting scene
  51534. * @returns the polyhedron mesh
  51535. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  51536. */
  51537. static CreatePolyhedron(name: string, options: {
  51538. type?: number;
  51539. size?: number;
  51540. sizeX?: number;
  51541. sizeY?: number;
  51542. sizeZ?: number;
  51543. custom?: any;
  51544. faceUV?: Vector4[];
  51545. faceColors?: Color4[];
  51546. flat?: boolean;
  51547. updatable?: boolean;
  51548. sideOrientation?: number;
  51549. frontUVs?: Vector4;
  51550. backUVs?: Vector4;
  51551. }, scene: Scene): Mesh;
  51552. /**
  51553. * Creates a decal mesh.
  51554. * 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
  51555. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  51556. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  51557. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  51558. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  51559. * @param name defines the name of the mesh
  51560. * @param sourceMesh defines the mesh where the decal must be applied
  51561. * @param options defines the options used to create the mesh
  51562. * @param scene defines the hosting scene
  51563. * @returns the decal mesh
  51564. * @see https://doc.babylonjs.com/how_to/decals
  51565. */
  51566. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  51567. position?: Vector3;
  51568. normal?: Vector3;
  51569. size?: Vector3;
  51570. angle?: number;
  51571. }): Mesh;
  51572. }
  51573. }
  51574. declare module "babylonjs/Meshes/meshSimplification" {
  51575. import { Mesh } from "babylonjs/Meshes/mesh";
  51576. /**
  51577. * A simplifier interface for future simplification implementations
  51578. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51579. */
  51580. export interface ISimplifier {
  51581. /**
  51582. * Simplification of a given mesh according to the given settings.
  51583. * Since this requires computation, it is assumed that the function runs async.
  51584. * @param settings The settings of the simplification, including quality and distance
  51585. * @param successCallback A callback that will be called after the mesh was simplified.
  51586. * @param errorCallback in case of an error, this callback will be called. optional.
  51587. */
  51588. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  51589. }
  51590. /**
  51591. * Expected simplification settings.
  51592. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  51593. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51594. */
  51595. export interface ISimplificationSettings {
  51596. /**
  51597. * Gets or sets the expected quality
  51598. */
  51599. quality: number;
  51600. /**
  51601. * Gets or sets the distance when this optimized version should be used
  51602. */
  51603. distance: number;
  51604. /**
  51605. * Gets an already optimized mesh
  51606. */
  51607. optimizeMesh?: boolean;
  51608. }
  51609. /**
  51610. * Class used to specify simplification options
  51611. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51612. */
  51613. export class SimplificationSettings implements ISimplificationSettings {
  51614. /** expected quality */
  51615. quality: number;
  51616. /** distance when this optimized version should be used */
  51617. distance: number;
  51618. /** already optimized mesh */
  51619. optimizeMesh?: boolean | undefined;
  51620. /**
  51621. * Creates a SimplificationSettings
  51622. * @param quality expected quality
  51623. * @param distance distance when this optimized version should be used
  51624. * @param optimizeMesh already optimized mesh
  51625. */
  51626. constructor(
  51627. /** expected quality */
  51628. quality: number,
  51629. /** distance when this optimized version should be used */
  51630. distance: number,
  51631. /** already optimized mesh */
  51632. optimizeMesh?: boolean | undefined);
  51633. }
  51634. /**
  51635. * Interface used to define a simplification task
  51636. */
  51637. export interface ISimplificationTask {
  51638. /**
  51639. * Array of settings
  51640. */
  51641. settings: Array<ISimplificationSettings>;
  51642. /**
  51643. * Simplification type
  51644. */
  51645. simplificationType: SimplificationType;
  51646. /**
  51647. * Mesh to simplify
  51648. */
  51649. mesh: Mesh;
  51650. /**
  51651. * Callback called on success
  51652. */
  51653. successCallback?: () => void;
  51654. /**
  51655. * Defines if parallel processing can be used
  51656. */
  51657. parallelProcessing: boolean;
  51658. }
  51659. /**
  51660. * Queue used to order the simplification tasks
  51661. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51662. */
  51663. export class SimplificationQueue {
  51664. private _simplificationArray;
  51665. /**
  51666. * Gets a boolean indicating that the process is still running
  51667. */
  51668. running: boolean;
  51669. /**
  51670. * Creates a new queue
  51671. */
  51672. constructor();
  51673. /**
  51674. * Adds a new simplification task
  51675. * @param task defines a task to add
  51676. */
  51677. addTask(task: ISimplificationTask): void;
  51678. /**
  51679. * Execute next task
  51680. */
  51681. executeNext(): void;
  51682. /**
  51683. * Execute a simplification task
  51684. * @param task defines the task to run
  51685. */
  51686. runSimplification(task: ISimplificationTask): void;
  51687. private getSimplifier;
  51688. }
  51689. /**
  51690. * The implemented types of simplification
  51691. * At the moment only Quadratic Error Decimation is implemented
  51692. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51693. */
  51694. export enum SimplificationType {
  51695. /** Quadratic error decimation */
  51696. QUADRATIC = 0
  51697. }
  51698. }
  51699. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  51700. import { Scene } from "babylonjs/scene";
  51701. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  51702. import { ISceneComponent } from "babylonjs/sceneComponent";
  51703. module "babylonjs/scene" {
  51704. interface Scene {
  51705. /** @hidden (Backing field) */
  51706. _simplificationQueue: SimplificationQueue;
  51707. /**
  51708. * Gets or sets the simplification queue attached to the scene
  51709. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51710. */
  51711. simplificationQueue: SimplificationQueue;
  51712. }
  51713. }
  51714. module "babylonjs/Meshes/mesh" {
  51715. interface Mesh {
  51716. /**
  51717. * Simplify the mesh according to the given array of settings.
  51718. * Function will return immediately and will simplify async
  51719. * @param settings a collection of simplification settings
  51720. * @param parallelProcessing should all levels calculate parallel or one after the other
  51721. * @param simplificationType the type of simplification to run
  51722. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  51723. * @returns the current mesh
  51724. */
  51725. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  51726. }
  51727. }
  51728. /**
  51729. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  51730. * created in a scene
  51731. */
  51732. export class SimplicationQueueSceneComponent implements ISceneComponent {
  51733. /**
  51734. * The component name helpfull to identify the component in the list of scene components.
  51735. */
  51736. readonly name: string;
  51737. /**
  51738. * The scene the component belongs to.
  51739. */
  51740. scene: Scene;
  51741. /**
  51742. * Creates a new instance of the component for the given scene
  51743. * @param scene Defines the scene to register the component in
  51744. */
  51745. constructor(scene: Scene);
  51746. /**
  51747. * Registers the component in a given scene
  51748. */
  51749. register(): void;
  51750. /**
  51751. * Rebuilds the elements related to this component in case of
  51752. * context lost for instance.
  51753. */
  51754. rebuild(): void;
  51755. /**
  51756. * Disposes the component and the associated ressources
  51757. */
  51758. dispose(): void;
  51759. private _beforeCameraUpdate;
  51760. }
  51761. }
  51762. declare module "babylonjs/Meshes/Builders/index" {
  51763. export * from "babylonjs/Meshes/Builders/boxBuilder";
  51764. export * from "babylonjs/Meshes/Builders/discBuilder";
  51765. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  51766. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  51767. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  51768. export * from "babylonjs/Meshes/Builders/torusBuilder";
  51769. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  51770. export * from "babylonjs/Meshes/Builders/linesBuilder";
  51771. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  51772. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  51773. export * from "babylonjs/Meshes/Builders/latheBuilder";
  51774. export * from "babylonjs/Meshes/Builders/planeBuilder";
  51775. export * from "babylonjs/Meshes/Builders/groundBuilder";
  51776. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  51777. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  51778. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  51779. export * from "babylonjs/Meshes/Builders/decalBuilder";
  51780. }
  51781. declare module "babylonjs/Meshes/index" {
  51782. export * from "babylonjs/Meshes/abstractMesh";
  51783. export * from "babylonjs/Meshes/buffer";
  51784. export * from "babylonjs/Meshes/Compression/index";
  51785. export * from "babylonjs/Meshes/csg";
  51786. export * from "babylonjs/Meshes/geometry";
  51787. export * from "babylonjs/Meshes/groundMesh";
  51788. export * from "babylonjs/Meshes/trailMesh";
  51789. export * from "babylonjs/Meshes/instancedMesh";
  51790. export * from "babylonjs/Meshes/linesMesh";
  51791. export * from "babylonjs/Meshes/mesh";
  51792. export * from "babylonjs/Meshes/mesh.vertexData";
  51793. export * from "babylonjs/Meshes/meshBuilder";
  51794. export * from "babylonjs/Meshes/meshSimplification";
  51795. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  51796. export * from "babylonjs/Meshes/polygonMesh";
  51797. export * from "babylonjs/Meshes/subMesh";
  51798. export * from "babylonjs/Meshes/transformNode";
  51799. export * from "babylonjs/Meshes/Builders/index";
  51800. }
  51801. declare module "babylonjs/Morph/index" {
  51802. export * from "babylonjs/Morph/morphTarget";
  51803. export * from "babylonjs/Morph/morphTargetManager";
  51804. }
  51805. declare module "babylonjs/Offline/database" {
  51806. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  51807. /**
  51808. * Class used to enable access to IndexedDB
  51809. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  51810. */
  51811. export class Database implements IOfflineProvider {
  51812. private _callbackManifestChecked;
  51813. private _currentSceneUrl;
  51814. private _db;
  51815. private _enableSceneOffline;
  51816. private _enableTexturesOffline;
  51817. private _manifestVersionFound;
  51818. private _mustUpdateRessources;
  51819. private _hasReachedQuota;
  51820. private _isSupported;
  51821. private _idbFactory;
  51822. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  51823. private static IsUASupportingBlobStorage;
  51824. /**
  51825. * Gets a boolean indicating if Database storate is enabled (off by default)
  51826. */
  51827. static IDBStorageEnabled: boolean;
  51828. /**
  51829. * Gets a boolean indicating if scene must be saved in the database
  51830. */
  51831. readonly enableSceneOffline: boolean;
  51832. /**
  51833. * Gets a boolean indicating if textures must be saved in the database
  51834. */
  51835. readonly enableTexturesOffline: boolean;
  51836. /**
  51837. * Creates a new Database
  51838. * @param urlToScene defines the url to load the scene
  51839. * @param callbackManifestChecked defines the callback to use when manifest is checked
  51840. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  51841. */
  51842. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  51843. private static _ParseURL;
  51844. private static _ReturnFullUrlLocation;
  51845. private _checkManifestFile;
  51846. /**
  51847. * Open the database and make it available
  51848. * @param successCallback defines the callback to call on success
  51849. * @param errorCallback defines the callback to call on error
  51850. */
  51851. open(successCallback: () => void, errorCallback: () => void): void;
  51852. /**
  51853. * Loads an image from the database
  51854. * @param url defines the url to load from
  51855. * @param image defines the target DOM image
  51856. */
  51857. loadImage(url: string, image: HTMLImageElement): void;
  51858. private _loadImageFromDBAsync;
  51859. private _saveImageIntoDBAsync;
  51860. private _checkVersionFromDB;
  51861. private _loadVersionFromDBAsync;
  51862. private _saveVersionIntoDBAsync;
  51863. /**
  51864. * Loads a file from database
  51865. * @param url defines the URL to load from
  51866. * @param sceneLoaded defines a callback to call on success
  51867. * @param progressCallBack defines a callback to call when progress changed
  51868. * @param errorCallback defines a callback to call on error
  51869. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  51870. */
  51871. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  51872. private _loadFileAsync;
  51873. private _saveFileAsync;
  51874. /**
  51875. * Validates if xhr data is correct
  51876. * @param xhr defines the request to validate
  51877. * @param dataType defines the expected data type
  51878. * @returns true if data is correct
  51879. */
  51880. private static _ValidateXHRData;
  51881. }
  51882. }
  51883. declare module "babylonjs/Offline/index" {
  51884. export * from "babylonjs/Offline/database";
  51885. export * from "babylonjs/Offline/IOfflineProvider";
  51886. }
  51887. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  51888. /** @hidden */
  51889. export var gpuUpdateParticlesPixelShader: {
  51890. name: string;
  51891. shader: string;
  51892. };
  51893. }
  51894. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  51895. /** @hidden */
  51896. export var gpuUpdateParticlesVertexShader: {
  51897. name: string;
  51898. shader: string;
  51899. };
  51900. }
  51901. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  51902. /** @hidden */
  51903. export var clipPlaneFragmentDeclaration2: {
  51904. name: string;
  51905. shader: string;
  51906. };
  51907. }
  51908. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  51909. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  51910. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51911. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51912. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51913. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51914. /** @hidden */
  51915. export var gpuRenderParticlesPixelShader: {
  51916. name: string;
  51917. shader: string;
  51918. };
  51919. }
  51920. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  51921. /** @hidden */
  51922. export var clipPlaneVertexDeclaration2: {
  51923. name: string;
  51924. shader: string;
  51925. };
  51926. }
  51927. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  51928. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  51929. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51930. /** @hidden */
  51931. export var gpuRenderParticlesVertexShader: {
  51932. name: string;
  51933. shader: string;
  51934. };
  51935. }
  51936. declare module "babylonjs/Particles/gpuParticleSystem" {
  51937. import { Nullable } from "babylonjs/types";
  51938. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  51939. import { Observable } from "babylonjs/Misc/observable";
  51940. import { Color4, Color3 } from "babylonjs/Maths/math";
  51941. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51942. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  51943. import { Scene, IDisposable } from "babylonjs/scene";
  51944. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  51945. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  51946. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  51947. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  51948. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  51949. /**
  51950. * This represents a GPU particle system in Babylon
  51951. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  51952. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  51953. */
  51954. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  51955. /**
  51956. * The layer mask we are rendering the particles through.
  51957. */
  51958. layerMask: number;
  51959. private _capacity;
  51960. private _activeCount;
  51961. private _currentActiveCount;
  51962. private _accumulatedCount;
  51963. private _renderEffect;
  51964. private _updateEffect;
  51965. private _buffer0;
  51966. private _buffer1;
  51967. private _spriteBuffer;
  51968. private _updateVAO;
  51969. private _renderVAO;
  51970. private _targetIndex;
  51971. private _sourceBuffer;
  51972. private _targetBuffer;
  51973. private _engine;
  51974. private _currentRenderId;
  51975. private _started;
  51976. private _stopped;
  51977. private _timeDelta;
  51978. private _randomTexture;
  51979. private _randomTexture2;
  51980. private _attributesStrideSize;
  51981. private _updateEffectOptions;
  51982. private _randomTextureSize;
  51983. private _actualFrame;
  51984. private readonly _rawTextureWidth;
  51985. /**
  51986. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  51987. */
  51988. static readonly IsSupported: boolean;
  51989. /**
  51990. * An event triggered when the system is disposed.
  51991. */
  51992. onDisposeObservable: Observable<GPUParticleSystem>;
  51993. /**
  51994. * Gets the maximum number of particles active at the same time.
  51995. * @returns The max number of active particles.
  51996. */
  51997. getCapacity(): number;
  51998. /**
  51999. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  52000. * to override the particles.
  52001. */
  52002. forceDepthWrite: boolean;
  52003. /**
  52004. * Gets or set the number of active particles
  52005. */
  52006. activeParticleCount: number;
  52007. private _preWarmDone;
  52008. /**
  52009. * Is this system ready to be used/rendered
  52010. * @return true if the system is ready
  52011. */
  52012. isReady(): boolean;
  52013. /**
  52014. * Gets if the system has been started. (Note: this will still be true after stop is called)
  52015. * @returns True if it has been started, otherwise false.
  52016. */
  52017. isStarted(): boolean;
  52018. /**
  52019. * Starts the particle system and begins to emit
  52020. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  52021. */
  52022. start(delay?: number): void;
  52023. /**
  52024. * Stops the particle system.
  52025. */
  52026. stop(): void;
  52027. /**
  52028. * Remove all active particles
  52029. */
  52030. reset(): void;
  52031. /**
  52032. * Returns the string "GPUParticleSystem"
  52033. * @returns a string containing the class name
  52034. */
  52035. getClassName(): string;
  52036. private _colorGradientsTexture;
  52037. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  52038. /**
  52039. * Adds a new color gradient
  52040. * @param gradient defines the gradient to use (between 0 and 1)
  52041. * @param color1 defines the color to affect to the specified gradient
  52042. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  52043. * @returns the current particle system
  52044. */
  52045. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  52046. /**
  52047. * Remove a specific color gradient
  52048. * @param gradient defines the gradient to remove
  52049. * @returns the current particle system
  52050. */
  52051. removeColorGradient(gradient: number): GPUParticleSystem;
  52052. private _angularSpeedGradientsTexture;
  52053. private _sizeGradientsTexture;
  52054. private _velocityGradientsTexture;
  52055. private _limitVelocityGradientsTexture;
  52056. private _dragGradientsTexture;
  52057. private _addFactorGradient;
  52058. /**
  52059. * Adds a new size gradient
  52060. * @param gradient defines the gradient to use (between 0 and 1)
  52061. * @param factor defines the size factor to affect to the specified gradient
  52062. * @returns the current particle system
  52063. */
  52064. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  52065. /**
  52066. * Remove a specific size gradient
  52067. * @param gradient defines the gradient to remove
  52068. * @returns the current particle system
  52069. */
  52070. removeSizeGradient(gradient: number): GPUParticleSystem;
  52071. /**
  52072. * Adds a new angular speed gradient
  52073. * @param gradient defines the gradient to use (between 0 and 1)
  52074. * @param factor defines the angular speed to affect to the specified gradient
  52075. * @returns the current particle system
  52076. */
  52077. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  52078. /**
  52079. * Remove a specific angular speed gradient
  52080. * @param gradient defines the gradient to remove
  52081. * @returns the current particle system
  52082. */
  52083. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  52084. /**
  52085. * Adds a new velocity gradient
  52086. * @param gradient defines the gradient to use (between 0 and 1)
  52087. * @param factor defines the velocity to affect to the specified gradient
  52088. * @returns the current particle system
  52089. */
  52090. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  52091. /**
  52092. * Remove a specific velocity gradient
  52093. * @param gradient defines the gradient to remove
  52094. * @returns the current particle system
  52095. */
  52096. removeVelocityGradient(gradient: number): GPUParticleSystem;
  52097. /**
  52098. * Adds a new limit velocity gradient
  52099. * @param gradient defines the gradient to use (between 0 and 1)
  52100. * @param factor defines the limit velocity value to affect to the specified gradient
  52101. * @returns the current particle system
  52102. */
  52103. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  52104. /**
  52105. * Remove a specific limit velocity gradient
  52106. * @param gradient defines the gradient to remove
  52107. * @returns the current particle system
  52108. */
  52109. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  52110. /**
  52111. * Adds a new drag gradient
  52112. * @param gradient defines the gradient to use (between 0 and 1)
  52113. * @param factor defines the drag value to affect to the specified gradient
  52114. * @returns the current particle system
  52115. */
  52116. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  52117. /**
  52118. * Remove a specific drag gradient
  52119. * @param gradient defines the gradient to remove
  52120. * @returns the current particle system
  52121. */
  52122. removeDragGradient(gradient: number): GPUParticleSystem;
  52123. /**
  52124. * Not supported by GPUParticleSystem
  52125. * @param gradient defines the gradient to use (between 0 and 1)
  52126. * @param factor defines the emit rate value to affect to the specified gradient
  52127. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  52128. * @returns the current particle system
  52129. */
  52130. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  52131. /**
  52132. * Not supported by GPUParticleSystem
  52133. * @param gradient defines the gradient to remove
  52134. * @returns the current particle system
  52135. */
  52136. removeEmitRateGradient(gradient: number): IParticleSystem;
  52137. /**
  52138. * Not supported by GPUParticleSystem
  52139. * @param gradient defines the gradient to use (between 0 and 1)
  52140. * @param factor defines the start size value to affect to the specified gradient
  52141. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  52142. * @returns the current particle system
  52143. */
  52144. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  52145. /**
  52146. * Not supported by GPUParticleSystem
  52147. * @param gradient defines the gradient to remove
  52148. * @returns the current particle system
  52149. */
  52150. removeStartSizeGradient(gradient: number): IParticleSystem;
  52151. /**
  52152. * Not supported by GPUParticleSystem
  52153. * @param gradient defines the gradient to use (between 0 and 1)
  52154. * @param min defines the color remap minimal range
  52155. * @param max defines the color remap maximal range
  52156. * @returns the current particle system
  52157. */
  52158. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  52159. /**
  52160. * Not supported by GPUParticleSystem
  52161. * @param gradient defines the gradient to remove
  52162. * @returns the current particle system
  52163. */
  52164. removeColorRemapGradient(): IParticleSystem;
  52165. /**
  52166. * Not supported by GPUParticleSystem
  52167. * @param gradient defines the gradient to use (between 0 and 1)
  52168. * @param min defines the alpha remap minimal range
  52169. * @param max defines the alpha remap maximal range
  52170. * @returns the current particle system
  52171. */
  52172. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  52173. /**
  52174. * Not supported by GPUParticleSystem
  52175. * @param gradient defines the gradient to remove
  52176. * @returns the current particle system
  52177. */
  52178. removeAlphaRemapGradient(): IParticleSystem;
  52179. /**
  52180. * Not supported by GPUParticleSystem
  52181. * @param gradient defines the gradient to use (between 0 and 1)
  52182. * @param color defines the color to affect to the specified gradient
  52183. * @returns the current particle system
  52184. */
  52185. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  52186. /**
  52187. * Not supported by GPUParticleSystem
  52188. * @param gradient defines the gradient to remove
  52189. * @returns the current particle system
  52190. */
  52191. removeRampGradient(): IParticleSystem;
  52192. /**
  52193. * Not supported by GPUParticleSystem
  52194. * @returns the list of ramp gradients
  52195. */
  52196. getRampGradients(): Nullable<Array<Color3Gradient>>;
  52197. /**
  52198. * Not supported by GPUParticleSystem
  52199. * Gets or sets a boolean indicating that ramp gradients must be used
  52200. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  52201. */
  52202. useRampGradients: boolean;
  52203. /**
  52204. * Not supported by GPUParticleSystem
  52205. * @param gradient defines the gradient to use (between 0 and 1)
  52206. * @param factor defines the life time factor to affect to the specified gradient
  52207. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  52208. * @returns the current particle system
  52209. */
  52210. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  52211. /**
  52212. * Not supported by GPUParticleSystem
  52213. * @param gradient defines the gradient to remove
  52214. * @returns the current particle system
  52215. */
  52216. removeLifeTimeGradient(gradient: number): IParticleSystem;
  52217. /**
  52218. * Instantiates a GPU particle system.
  52219. * 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.
  52220. * @param name The name of the particle system
  52221. * @param options The options used to create the system
  52222. * @param scene The scene the particle system belongs to
  52223. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  52224. */
  52225. constructor(name: string, options: Partial<{
  52226. capacity: number;
  52227. randomTextureSize: number;
  52228. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  52229. protected _reset(): void;
  52230. private _createUpdateVAO;
  52231. private _createRenderVAO;
  52232. private _initialize;
  52233. /** @hidden */
  52234. _recreateUpdateEffect(): void;
  52235. /** @hidden */
  52236. _recreateRenderEffect(): void;
  52237. /**
  52238. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  52239. * @param preWarm defines if we are in the pre-warmimg phase
  52240. */
  52241. animate(preWarm?: boolean): void;
  52242. private _createFactorGradientTexture;
  52243. private _createSizeGradientTexture;
  52244. private _createAngularSpeedGradientTexture;
  52245. private _createVelocityGradientTexture;
  52246. private _createLimitVelocityGradientTexture;
  52247. private _createDragGradientTexture;
  52248. private _createColorGradientTexture;
  52249. /**
  52250. * Renders the particle system in its current state
  52251. * @param preWarm defines if the system should only update the particles but not render them
  52252. * @returns the current number of particles
  52253. */
  52254. render(preWarm?: boolean): number;
  52255. /**
  52256. * Rebuilds the particle system
  52257. */
  52258. rebuild(): void;
  52259. private _releaseBuffers;
  52260. private _releaseVAOs;
  52261. /**
  52262. * Disposes the particle system and free the associated resources
  52263. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  52264. */
  52265. dispose(disposeTexture?: boolean): void;
  52266. /**
  52267. * Clones the particle system.
  52268. * @param name The name of the cloned object
  52269. * @param newEmitter The new emitter to use
  52270. * @returns the cloned particle system
  52271. */
  52272. clone(name: string, newEmitter: any): GPUParticleSystem;
  52273. /**
  52274. * Serializes the particle system to a JSON object.
  52275. * @returns the JSON object
  52276. */
  52277. serialize(): any;
  52278. /**
  52279. * Parses a JSON object to create a GPU particle system.
  52280. * @param parsedParticleSystem The JSON object to parse
  52281. * @param scene The scene to create the particle system in
  52282. * @param rootUrl The root url to use to load external dependencies like texture
  52283. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  52284. * @returns the parsed GPU particle system
  52285. */
  52286. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  52287. }
  52288. }
  52289. declare module "babylonjs/Particles/particleSystemSet" {
  52290. import { Nullable } from "babylonjs/types";
  52291. import { Color3 } from "babylonjs/Maths/math";
  52292. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52293. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52294. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  52295. import { Scene, IDisposable } from "babylonjs/scene";
  52296. /**
  52297. * Represents a set of particle systems working together to create a specific effect
  52298. */
  52299. export class ParticleSystemSet implements IDisposable {
  52300. private _emitterCreationOptions;
  52301. private _emitterNode;
  52302. /**
  52303. * Gets the particle system list
  52304. */
  52305. systems: IParticleSystem[];
  52306. /**
  52307. * Gets the emitter node used with this set
  52308. */
  52309. readonly emitterNode: Nullable<TransformNode>;
  52310. /**
  52311. * Creates a new emitter mesh as a sphere
  52312. * @param options defines the options used to create the sphere
  52313. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  52314. * @param scene defines the hosting scene
  52315. */
  52316. setEmitterAsSphere(options: {
  52317. diameter: number;
  52318. segments: number;
  52319. color: Color3;
  52320. }, renderingGroupId: number, scene: Scene): void;
  52321. /**
  52322. * Starts all particle systems of the set
  52323. * @param emitter defines an optional mesh to use as emitter for the particle systems
  52324. */
  52325. start(emitter?: AbstractMesh): void;
  52326. /**
  52327. * Release all associated resources
  52328. */
  52329. dispose(): void;
  52330. /**
  52331. * Serialize the set into a JSON compatible object
  52332. * @returns a JSON compatible representation of the set
  52333. */
  52334. serialize(): any;
  52335. /**
  52336. * Parse a new ParticleSystemSet from a serialized source
  52337. * @param data defines a JSON compatible representation of the set
  52338. * @param scene defines the hosting scene
  52339. * @param gpu defines if we want GPU particles or CPU particles
  52340. * @returns a new ParticleSystemSet
  52341. */
  52342. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  52343. }
  52344. }
  52345. declare module "babylonjs/Particles/particleHelper" {
  52346. import { Nullable } from "babylonjs/types";
  52347. import { Scene } from "babylonjs/scene";
  52348. import { Vector3 } from "babylonjs/Maths/math";
  52349. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52350. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  52351. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  52352. /**
  52353. * This class is made for on one-liner static method to help creating particle system set.
  52354. */
  52355. export class ParticleHelper {
  52356. /**
  52357. * Gets or sets base Assets URL
  52358. */
  52359. static BaseAssetsUrl: string;
  52360. /**
  52361. * Create a default particle system that you can tweak
  52362. * @param emitter defines the emitter to use
  52363. * @param capacity defines the system capacity (default is 500 particles)
  52364. * @param scene defines the hosting scene
  52365. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  52366. * @returns the new Particle system
  52367. */
  52368. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  52369. /**
  52370. * This is the main static method (one-liner) of this helper to create different particle systems
  52371. * @param type This string represents the type to the particle system to create
  52372. * @param scene The scene where the particle system should live
  52373. * @param gpu If the system will use gpu
  52374. * @returns the ParticleSystemSet created
  52375. */
  52376. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  52377. /**
  52378. * Static function used to export a particle system to a ParticleSystemSet variable.
  52379. * Please note that the emitter shape is not exported
  52380. * @param systems defines the particle systems to export
  52381. * @returns the created particle system set
  52382. */
  52383. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  52384. }
  52385. }
  52386. declare module "babylonjs/Particles/particleSystemComponent" {
  52387. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  52388. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  52389. import "babylonjs/Shaders/particles.vertex";
  52390. module "babylonjs/Engines/engine" {
  52391. interface Engine {
  52392. /**
  52393. * Create an effect to use with particle systems.
  52394. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  52395. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  52396. * @param uniformsNames defines a list of attribute names
  52397. * @param samplers defines an array of string used to represent textures
  52398. * @param defines defines the string containing the defines to use to compile the shaders
  52399. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  52400. * @param onCompiled defines a function to call when the effect creation is successful
  52401. * @param onError defines a function to call when the effect creation has failed
  52402. * @returns the new Effect
  52403. */
  52404. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  52405. }
  52406. }
  52407. module "babylonjs/Meshes/mesh" {
  52408. interface Mesh {
  52409. /**
  52410. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  52411. * @returns an array of IParticleSystem
  52412. */
  52413. getEmittedParticleSystems(): IParticleSystem[];
  52414. /**
  52415. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  52416. * @returns an array of IParticleSystem
  52417. */
  52418. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  52419. }
  52420. }
  52421. /**
  52422. * @hidden
  52423. */
  52424. export var _IDoNeedToBeInTheBuild: number;
  52425. }
  52426. declare module "babylonjs/Particles/index" {
  52427. export * from "babylonjs/Particles/baseParticleSystem";
  52428. export * from "babylonjs/Particles/EmitterTypes/index";
  52429. export * from "babylonjs/Particles/gpuParticleSystem";
  52430. export * from "babylonjs/Particles/IParticleSystem";
  52431. export * from "babylonjs/Particles/particle";
  52432. export * from "babylonjs/Particles/particleHelper";
  52433. export * from "babylonjs/Particles/particleSystem";
  52434. export * from "babylonjs/Particles/particleSystemComponent";
  52435. export * from "babylonjs/Particles/particleSystemSet";
  52436. export * from "babylonjs/Particles/solidParticle";
  52437. export * from "babylonjs/Particles/solidParticleSystem";
  52438. export * from "babylonjs/Particles/subEmitter";
  52439. }
  52440. declare module "babylonjs/Physics/physicsEngineComponent" {
  52441. import { Nullable } from "babylonjs/types";
  52442. import { Observable, Observer } from "babylonjs/Misc/observable";
  52443. import { Vector3 } from "babylonjs/Maths/math";
  52444. import { Mesh } from "babylonjs/Meshes/mesh";
  52445. import { ISceneComponent } from "babylonjs/sceneComponent";
  52446. import { Scene } from "babylonjs/scene";
  52447. import { Node } from "babylonjs/node";
  52448. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  52449. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52450. module "babylonjs/scene" {
  52451. interface Scene {
  52452. /** @hidden (Backing field) */
  52453. _physicsEngine: Nullable<IPhysicsEngine>;
  52454. /**
  52455. * Gets the current physics engine
  52456. * @returns a IPhysicsEngine or null if none attached
  52457. */
  52458. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  52459. /**
  52460. * Enables physics to the current scene
  52461. * @param gravity defines the scene's gravity for the physics engine
  52462. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  52463. * @return a boolean indicating if the physics engine was initialized
  52464. */
  52465. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  52466. /**
  52467. * Disables and disposes the physics engine associated with the scene
  52468. */
  52469. disablePhysicsEngine(): void;
  52470. /**
  52471. * Gets a boolean indicating if there is an active physics engine
  52472. * @returns a boolean indicating if there is an active physics engine
  52473. */
  52474. isPhysicsEnabled(): boolean;
  52475. /**
  52476. * Deletes a physics compound impostor
  52477. * @param compound defines the compound to delete
  52478. */
  52479. deleteCompoundImpostor(compound: any): void;
  52480. /**
  52481. * An event triggered when physic simulation is about to be run
  52482. */
  52483. onBeforePhysicsObservable: Observable<Scene>;
  52484. /**
  52485. * An event triggered when physic simulation has been done
  52486. */
  52487. onAfterPhysicsObservable: Observable<Scene>;
  52488. }
  52489. }
  52490. module "babylonjs/Meshes/abstractMesh" {
  52491. interface AbstractMesh {
  52492. /** @hidden */
  52493. _physicsImpostor: Nullable<PhysicsImpostor>;
  52494. /**
  52495. * Gets or sets impostor used for physic simulation
  52496. * @see http://doc.babylonjs.com/features/physics_engine
  52497. */
  52498. physicsImpostor: Nullable<PhysicsImpostor>;
  52499. /**
  52500. * Gets the current physics impostor
  52501. * @see http://doc.babylonjs.com/features/physics_engine
  52502. * @returns a physics impostor or null
  52503. */
  52504. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  52505. /** Apply a physic impulse to the mesh
  52506. * @param force defines the force to apply
  52507. * @param contactPoint defines where to apply the force
  52508. * @returns the current mesh
  52509. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  52510. */
  52511. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  52512. /**
  52513. * Creates a physic joint between two meshes
  52514. * @param otherMesh defines the other mesh to use
  52515. * @param pivot1 defines the pivot to use on this mesh
  52516. * @param pivot2 defines the pivot to use on the other mesh
  52517. * @param options defines additional options (can be plugin dependent)
  52518. * @returns the current mesh
  52519. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  52520. */
  52521. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  52522. /** @hidden */
  52523. _disposePhysicsObserver: Nullable<Observer<Node>>;
  52524. }
  52525. }
  52526. /**
  52527. * Defines the physics engine scene component responsible to manage a physics engine
  52528. */
  52529. export class PhysicsEngineSceneComponent implements ISceneComponent {
  52530. /**
  52531. * The component name helpful to identify the component in the list of scene components.
  52532. */
  52533. readonly name: string;
  52534. /**
  52535. * The scene the component belongs to.
  52536. */
  52537. scene: Scene;
  52538. /**
  52539. * Creates a new instance of the component for the given scene
  52540. * @param scene Defines the scene to register the component in
  52541. */
  52542. constructor(scene: Scene);
  52543. /**
  52544. * Registers the component in a given scene
  52545. */
  52546. register(): void;
  52547. /**
  52548. * Rebuilds the elements related to this component in case of
  52549. * context lost for instance.
  52550. */
  52551. rebuild(): void;
  52552. /**
  52553. * Disposes the component and the associated ressources
  52554. */
  52555. dispose(): void;
  52556. }
  52557. }
  52558. declare module "babylonjs/Physics/physicsHelper" {
  52559. import { Nullable } from "babylonjs/types";
  52560. import { Vector3 } from "babylonjs/Maths/math";
  52561. import { Mesh } from "babylonjs/Meshes/mesh";
  52562. import { Scene } from "babylonjs/scene";
  52563. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52564. /**
  52565. * A helper for physics simulations
  52566. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52567. */
  52568. export class PhysicsHelper {
  52569. private _scene;
  52570. private _physicsEngine;
  52571. /**
  52572. * Initializes the Physics helper
  52573. * @param scene Babylon.js scene
  52574. */
  52575. constructor(scene: Scene);
  52576. /**
  52577. * Applies a radial explosion impulse
  52578. * @param origin the origin of the explosion
  52579. * @param radiusOrEventOptions the radius or the options of radial explosion
  52580. * @param strength the explosion strength
  52581. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52582. * @returns A physics radial explosion event, or null
  52583. */
  52584. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  52585. /**
  52586. * Applies a radial explosion force
  52587. * @param origin the origin of the explosion
  52588. * @param radiusOrEventOptions the radius or the options of radial explosion
  52589. * @param strength the explosion strength
  52590. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52591. * @returns A physics radial explosion event, or null
  52592. */
  52593. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  52594. /**
  52595. * Creates a gravitational field
  52596. * @param origin the origin of the explosion
  52597. * @param radiusOrEventOptions the radius or the options of radial explosion
  52598. * @param strength the explosion strength
  52599. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52600. * @returns A physics gravitational field event, or null
  52601. */
  52602. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  52603. /**
  52604. * Creates a physics updraft event
  52605. * @param origin the origin of the updraft
  52606. * @param radiusOrEventOptions the radius or the options of the updraft
  52607. * @param strength the strength of the updraft
  52608. * @param height the height of the updraft
  52609. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  52610. * @returns A physics updraft event, or null
  52611. */
  52612. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  52613. /**
  52614. * Creates a physics vortex event
  52615. * @param origin the of the vortex
  52616. * @param radiusOrEventOptions the radius or the options of the vortex
  52617. * @param strength the strength of the vortex
  52618. * @param height the height of the vortex
  52619. * @returns a Physics vortex event, or null
  52620. * A physics vortex event or null
  52621. */
  52622. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  52623. }
  52624. /**
  52625. * Represents a physics radial explosion event
  52626. */
  52627. class PhysicsRadialExplosionEvent {
  52628. private _scene;
  52629. private _options;
  52630. private _sphere;
  52631. private _dataFetched;
  52632. /**
  52633. * Initializes a radial explosioin event
  52634. * @param _scene BabylonJS scene
  52635. * @param _options The options for the vortex event
  52636. */
  52637. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  52638. /**
  52639. * Returns the data related to the radial explosion event (sphere).
  52640. * @returns The radial explosion event data
  52641. */
  52642. getData(): PhysicsRadialExplosionEventData;
  52643. /**
  52644. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  52645. * @param impostor A physics imposter
  52646. * @param origin the origin of the explosion
  52647. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  52648. */
  52649. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsForceAndContactPoint>;
  52650. /**
  52651. * Disposes the sphere.
  52652. * @param force Specifies if the sphere should be disposed by force
  52653. */
  52654. dispose(force?: boolean): void;
  52655. /*** Helpers ***/
  52656. private _prepareSphere;
  52657. private _intersectsWithSphere;
  52658. }
  52659. /**
  52660. * Represents a gravitational field event
  52661. */
  52662. class PhysicsGravitationalFieldEvent {
  52663. private _physicsHelper;
  52664. private _scene;
  52665. private _origin;
  52666. private _options;
  52667. private _tickCallback;
  52668. private _sphere;
  52669. private _dataFetched;
  52670. /**
  52671. * Initializes the physics gravitational field event
  52672. * @param _physicsHelper A physics helper
  52673. * @param _scene BabylonJS scene
  52674. * @param _origin The origin position of the gravitational field event
  52675. * @param _options The options for the vortex event
  52676. */
  52677. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  52678. /**
  52679. * Returns the data related to the gravitational field event (sphere).
  52680. * @returns A gravitational field event
  52681. */
  52682. getData(): PhysicsGravitationalFieldEventData;
  52683. /**
  52684. * Enables the gravitational field.
  52685. */
  52686. enable(): void;
  52687. /**
  52688. * Disables the gravitational field.
  52689. */
  52690. disable(): void;
  52691. /**
  52692. * Disposes the sphere.
  52693. * @param force The force to dispose from the gravitational field event
  52694. */
  52695. dispose(force?: boolean): void;
  52696. private _tick;
  52697. }
  52698. /**
  52699. * Represents a physics updraft event
  52700. */
  52701. class PhysicsUpdraftEvent {
  52702. private _scene;
  52703. private _origin;
  52704. private _options;
  52705. private _physicsEngine;
  52706. private _originTop;
  52707. private _originDirection;
  52708. private _tickCallback;
  52709. private _cylinder;
  52710. private _cylinderPosition;
  52711. private _dataFetched;
  52712. /**
  52713. * Initializes the physics updraft event
  52714. * @param _scene BabylonJS scene
  52715. * @param _origin The origin position of the updraft
  52716. * @param _options The options for the updraft event
  52717. */
  52718. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  52719. /**
  52720. * Returns the data related to the updraft event (cylinder).
  52721. * @returns A physics updraft event
  52722. */
  52723. getData(): PhysicsUpdraftEventData;
  52724. /**
  52725. * Enables the updraft.
  52726. */
  52727. enable(): void;
  52728. /**
  52729. * Disables the updraft.
  52730. */
  52731. disable(): void;
  52732. /**
  52733. * Disposes the cylinder.
  52734. * @param force Specifies if the updraft should be disposed by force
  52735. */
  52736. dispose(force?: boolean): void;
  52737. private getImpostorForceAndContactPoint;
  52738. private _tick;
  52739. /*** Helpers ***/
  52740. private _prepareCylinder;
  52741. private _intersectsWithCylinder;
  52742. }
  52743. /**
  52744. * Represents a physics vortex event
  52745. */
  52746. class PhysicsVortexEvent {
  52747. private _scene;
  52748. private _origin;
  52749. private _options;
  52750. private _physicsEngine;
  52751. private _originTop;
  52752. private _tickCallback;
  52753. private _cylinder;
  52754. private _cylinderPosition;
  52755. private _dataFetched;
  52756. /**
  52757. * Initializes the physics vortex event
  52758. * @param _scene The BabylonJS scene
  52759. * @param _origin The origin position of the vortex
  52760. * @param _options The options for the vortex event
  52761. */
  52762. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  52763. /**
  52764. * Returns the data related to the vortex event (cylinder).
  52765. * @returns The physics vortex event data
  52766. */
  52767. getData(): PhysicsVortexEventData;
  52768. /**
  52769. * Enables the vortex.
  52770. */
  52771. enable(): void;
  52772. /**
  52773. * Disables the cortex.
  52774. */
  52775. disable(): void;
  52776. /**
  52777. * Disposes the sphere.
  52778. * @param force
  52779. */
  52780. dispose(force?: boolean): void;
  52781. private getImpostorForceAndContactPoint;
  52782. private _tick;
  52783. /*** Helpers ***/
  52784. private _prepareCylinder;
  52785. private _intersectsWithCylinder;
  52786. }
  52787. /**
  52788. * Options fot the radial explosion event
  52789. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52790. */
  52791. export class PhysicsRadialExplosionEventOptions {
  52792. /**
  52793. * The radius of the sphere for the radial explosion.
  52794. */
  52795. radius: number;
  52796. /**
  52797. * The strenth of the explosion.
  52798. */
  52799. strength: number;
  52800. /**
  52801. * The strenght of the force in correspondence to the distance of the affected object
  52802. */
  52803. falloff: PhysicsRadialImpulseFalloff;
  52804. /**
  52805. * Sphere options for the radial explosion.
  52806. */
  52807. sphere: {
  52808. segments: number;
  52809. diameter: number;
  52810. };
  52811. }
  52812. /**
  52813. * Options fot the updraft event
  52814. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52815. */
  52816. export class PhysicsUpdraftEventOptions {
  52817. /**
  52818. * The radius of the cylinder for the vortex
  52819. */
  52820. radius: number;
  52821. /**
  52822. * The strenth of the updraft.
  52823. */
  52824. strength: number;
  52825. /**
  52826. * The height of the cylinder for the updraft.
  52827. */
  52828. height: number;
  52829. /**
  52830. * The mode for the the updraft.
  52831. */
  52832. updraftMode: PhysicsUpdraftMode;
  52833. }
  52834. /**
  52835. * Options fot the vortex event
  52836. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52837. */
  52838. export class PhysicsVortexEventOptions {
  52839. /**
  52840. * The radius of the cylinder for the vortex
  52841. */
  52842. radius: number;
  52843. /**
  52844. * The strenth of the vortex.
  52845. */
  52846. strength: number;
  52847. /**
  52848. * The height of the cylinder for the vortex.
  52849. */
  52850. height: number;
  52851. /**
  52852. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  52853. */
  52854. centripetalForceThreshold: number;
  52855. /**
  52856. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  52857. */
  52858. centripetalForceMultiplier: number;
  52859. /**
  52860. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  52861. */
  52862. centrifugalForceMultiplier: number;
  52863. /**
  52864. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  52865. */
  52866. updraftForceMultiplier: number;
  52867. }
  52868. /**
  52869. * The strenght of the force in correspondence to the distance of the affected object
  52870. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52871. */
  52872. export enum PhysicsRadialImpulseFalloff {
  52873. /** Defines that impulse is constant in strength across it's whole radius */
  52874. Constant = 0,
  52875. /** Defines that impulse gets weaker if it's further from the origin */
  52876. Linear = 1
  52877. }
  52878. /**
  52879. * The strength of the force in correspondence to the distance of the affected object
  52880. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52881. */
  52882. export enum PhysicsUpdraftMode {
  52883. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  52884. Center = 0,
  52885. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  52886. Perpendicular = 1
  52887. }
  52888. /**
  52889. * Interface for a physics force and contact point
  52890. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52891. */
  52892. export interface PhysicsForceAndContactPoint {
  52893. /**
  52894. * The force applied at the contact point
  52895. */
  52896. force: Vector3;
  52897. /**
  52898. * The contact point
  52899. */
  52900. contactPoint: Vector3;
  52901. }
  52902. /**
  52903. * Interface for radial explosion event data
  52904. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52905. */
  52906. export interface PhysicsRadialExplosionEventData {
  52907. /**
  52908. * A sphere used for the radial explosion event
  52909. */
  52910. sphere: Mesh;
  52911. }
  52912. /**
  52913. * Interface for gravitational field event data
  52914. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52915. */
  52916. export interface PhysicsGravitationalFieldEventData {
  52917. /**
  52918. * A sphere mesh used for the gravitational field event
  52919. */
  52920. sphere: Mesh;
  52921. }
  52922. /**
  52923. * Interface for updraft event data
  52924. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52925. */
  52926. export interface PhysicsUpdraftEventData {
  52927. /**
  52928. * A cylinder used for the updraft event
  52929. */
  52930. cylinder: Mesh;
  52931. }
  52932. /**
  52933. * Interface for vortex event data
  52934. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52935. */
  52936. export interface PhysicsVortexEventData {
  52937. /**
  52938. * A cylinder used for the vortex event
  52939. */
  52940. cylinder: Mesh;
  52941. }
  52942. }
  52943. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  52944. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  52945. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52946. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52947. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52948. import { Nullable } from "babylonjs/types";
  52949. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52950. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52951. /**
  52952. * AmmoJS Physics plugin
  52953. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52954. * @see https://github.com/kripken/ammo.js/
  52955. */
  52956. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52957. private _useDeltaForWorldStep;
  52958. /**
  52959. * Reference to the Ammo library
  52960. */
  52961. bjsAMMO: any;
  52962. /**
  52963. * Created ammoJS world which physics bodies are added to
  52964. */
  52965. world: any;
  52966. /**
  52967. * Name of the plugin
  52968. */
  52969. name: string;
  52970. private _timeStep;
  52971. private _fixedTimeStep;
  52972. private _maxSteps;
  52973. private _tmpQuaternion;
  52974. private _tmpAmmoTransform;
  52975. private _tmpAmmoQuaternion;
  52976. private _tmpAmmoConcreteContactResultCallback;
  52977. private _collisionConfiguration;
  52978. private _dispatcher;
  52979. private _overlappingPairCache;
  52980. private _solver;
  52981. private _softBodySolver;
  52982. private _tmpAmmoVectorA;
  52983. private _tmpAmmoVectorB;
  52984. private _tmpAmmoVectorC;
  52985. private _tmpAmmoVectorD;
  52986. private _tmpContactCallbackResult;
  52987. private _tmpAmmoVectorRCA;
  52988. private _tmpAmmoVectorRCB;
  52989. private _raycastResult;
  52990. private static readonly DISABLE_COLLISION_FLAG;
  52991. private static readonly KINEMATIC_FLAG;
  52992. private static readonly DISABLE_DEACTIVATION_FLAG;
  52993. /**
  52994. * Initializes the ammoJS plugin
  52995. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  52996. * @param ammoInjection can be used to inject your own ammo reference
  52997. */
  52998. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  52999. /**
  53000. * Sets the gravity of the physics world (m/(s^2))
  53001. * @param gravity Gravity to set
  53002. */
  53003. setGravity(gravity: Vector3): void;
  53004. /**
  53005. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  53006. * @param timeStep timestep to use in seconds
  53007. */
  53008. setTimeStep(timeStep: number): void;
  53009. /**
  53010. * 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)
  53011. * @param fixedTimeStep fixedTimeStep to use in seconds
  53012. */
  53013. setFixedTimeStep(fixedTimeStep: number): void;
  53014. /**
  53015. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  53016. * @param maxSteps the maximum number of steps by the physics engine per frame
  53017. */
  53018. setMaxSteps(maxSteps: number): void;
  53019. /**
  53020. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  53021. * @returns the current timestep in seconds
  53022. */
  53023. getTimeStep(): number;
  53024. private _isImpostorInContact;
  53025. private _isImpostorPairInContact;
  53026. private _stepSimulation;
  53027. /**
  53028. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  53029. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  53030. * After the step the babylon meshes are set to the position of the physics imposters
  53031. * @param delta amount of time to step forward
  53032. * @param impostors array of imposters to update before/after the step
  53033. */
  53034. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53035. /**
  53036. * Update babylon mesh vertices vertices to match physics world object
  53037. * @param impostor imposter to match
  53038. */
  53039. afterSoftStep(impostor: PhysicsImpostor): void;
  53040. private _tmpVector;
  53041. private _tmpMatrix;
  53042. /**
  53043. * Applies an impulse on the imposter
  53044. * @param impostor imposter to apply impulse to
  53045. * @param force amount of force to be applied to the imposter
  53046. * @param contactPoint the location to apply the impulse on the imposter
  53047. */
  53048. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53049. /**
  53050. * Applies a force on the imposter
  53051. * @param impostor imposter to apply force
  53052. * @param force amount of force to be applied to the imposter
  53053. * @param contactPoint the location to apply the force on the imposter
  53054. */
  53055. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53056. /**
  53057. * Creates a physics body using the plugin
  53058. * @param impostor the imposter to create the physics body on
  53059. */
  53060. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53061. /**
  53062. * Removes the physics body from the imposter and disposes of the body's memory
  53063. * @param impostor imposter to remove the physics body from
  53064. */
  53065. removePhysicsBody(impostor: PhysicsImpostor): void;
  53066. /**
  53067. * Generates a joint
  53068. * @param impostorJoint the imposter joint to create the joint with
  53069. */
  53070. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53071. /**
  53072. * Removes a joint
  53073. * @param impostorJoint the imposter joint to remove the joint from
  53074. */
  53075. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53076. private _addMeshVerts;
  53077. /**
  53078. * Initialise the soft body vertices to match its object's (mesh) vertices
  53079. * Softbody vertices (nodes) are in world space and to match this
  53080. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53081. * @param impostor to create the softbody for
  53082. */
  53083. private _softVertexData;
  53084. /**
  53085. * Create an impostor's soft body
  53086. * @param impostor to create the softbody for
  53087. */
  53088. private _createSoftbody;
  53089. /**
  53090. * Create cloth for an impostor
  53091. * @param impostor to create the softbody for
  53092. */
  53093. private _createCloth;
  53094. private _addHullVerts;
  53095. private _createShape;
  53096. /**
  53097. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53098. * @param impostor imposter containing the physics body and babylon object
  53099. */
  53100. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53101. /**
  53102. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53103. * @param impostor imposter containing the physics body and babylon object
  53104. * @param newPosition new position
  53105. * @param newRotation new rotation
  53106. */
  53107. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53108. /**
  53109. * If this plugin is supported
  53110. * @returns true if its supported
  53111. */
  53112. isSupported(): boolean;
  53113. /**
  53114. * Sets the linear velocity of the physics body
  53115. * @param impostor imposter to set the velocity on
  53116. * @param velocity velocity to set
  53117. */
  53118. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53119. /**
  53120. * Sets the angular velocity of the physics body
  53121. * @param impostor imposter to set the velocity on
  53122. * @param velocity velocity to set
  53123. */
  53124. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53125. /**
  53126. * gets the linear velocity
  53127. * @param impostor imposter to get linear velocity from
  53128. * @returns linear velocity
  53129. */
  53130. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53131. /**
  53132. * gets the angular velocity
  53133. * @param impostor imposter to get angular velocity from
  53134. * @returns angular velocity
  53135. */
  53136. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53137. /**
  53138. * Sets the mass of physics body
  53139. * @param impostor imposter to set the mass on
  53140. * @param mass mass to set
  53141. */
  53142. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53143. /**
  53144. * Gets the mass of the physics body
  53145. * @param impostor imposter to get the mass from
  53146. * @returns mass
  53147. */
  53148. getBodyMass(impostor: PhysicsImpostor): number;
  53149. /**
  53150. * Gets friction of the impostor
  53151. * @param impostor impostor to get friction from
  53152. * @returns friction value
  53153. */
  53154. getBodyFriction(impostor: PhysicsImpostor): number;
  53155. /**
  53156. * Sets friction of the impostor
  53157. * @param impostor impostor to set friction on
  53158. * @param friction friction value
  53159. */
  53160. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53161. /**
  53162. * Gets restitution of the impostor
  53163. * @param impostor impostor to get restitution from
  53164. * @returns restitution value
  53165. */
  53166. getBodyRestitution(impostor: PhysicsImpostor): number;
  53167. /**
  53168. * Sets resitution of the impostor
  53169. * @param impostor impostor to set resitution on
  53170. * @param restitution resitution value
  53171. */
  53172. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53173. /**
  53174. * Gets pressure inside the impostor
  53175. * @param impostor impostor to get pressure from
  53176. * @returns pressure value
  53177. */
  53178. getBodyPressure(impostor: PhysicsImpostor): number;
  53179. /**
  53180. * Sets pressure inside a soft body impostor
  53181. * Cloth and rope must remain 0 pressure
  53182. * @param impostor impostor to set pressure on
  53183. * @param pressure pressure value
  53184. */
  53185. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53186. /**
  53187. * Gets stiffness of the impostor
  53188. * @param impostor impostor to get stiffness from
  53189. * @returns pressure value
  53190. */
  53191. getBodyStiffness(impostor: PhysicsImpostor): number;
  53192. /**
  53193. * Sets stiffness of the impostor
  53194. * @param impostor impostor to set stiffness on
  53195. * @param stiffness stiffness value from 0 to 1
  53196. */
  53197. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53198. /**
  53199. * Gets velocityIterations of the impostor
  53200. * @param impostor impostor to get velocity iterations from
  53201. * @returns velocityIterations value
  53202. */
  53203. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53204. /**
  53205. * Sets velocityIterations of the impostor
  53206. * @param impostor impostor to set velocity iterations on
  53207. * @param velocityIterations velocityIterations value
  53208. */
  53209. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53210. /**
  53211. * Gets positionIterations of the impostor
  53212. * @param impostor impostor to get position iterations from
  53213. * @returns positionIterations value
  53214. */
  53215. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  53216. /**
  53217. * Sets positionIterations of the impostor
  53218. * @param impostor impostor to set position on
  53219. * @param positionIterations positionIterations value
  53220. */
  53221. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  53222. /**
  53223. * Append an anchor to a soft object
  53224. * @param impostor soft impostor to add anchor to
  53225. * @param otherImpostor rigid impostor as the anchor
  53226. * @param width ratio across width from 0 to 1
  53227. * @param height ratio up height from 0 to 1
  53228. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, no strech
  53229. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53230. */
  53231. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53232. /**
  53233. * Sleeps the physics body and stops it from being active
  53234. * @param impostor impostor to sleep
  53235. */
  53236. sleepBody(impostor: PhysicsImpostor): void;
  53237. /**
  53238. * Activates the physics body
  53239. * @param impostor impostor to activate
  53240. */
  53241. wakeUpBody(impostor: PhysicsImpostor): void;
  53242. /**
  53243. * Updates the distance parameters of the joint
  53244. * @param joint joint to update
  53245. * @param maxDistance maximum distance of the joint
  53246. * @param minDistance minimum distance of the joint
  53247. */
  53248. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53249. /**
  53250. * Sets a motor on the joint
  53251. * @param joint joint to set motor on
  53252. * @param speed speed of the motor
  53253. * @param maxForce maximum force of the motor
  53254. * @param motorIndex index of the motor
  53255. */
  53256. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53257. /**
  53258. * Sets the motors limit
  53259. * @param joint joint to set limit on
  53260. * @param upperLimit upper limit
  53261. * @param lowerLimit lower limit
  53262. */
  53263. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53264. /**
  53265. * Syncs the position and rotation of a mesh with the impostor
  53266. * @param mesh mesh to sync
  53267. * @param impostor impostor to update the mesh with
  53268. */
  53269. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53270. /**
  53271. * Gets the radius of the impostor
  53272. * @param impostor impostor to get radius from
  53273. * @returns the radius
  53274. */
  53275. getRadius(impostor: PhysicsImpostor): number;
  53276. /**
  53277. * Gets the box size of the impostor
  53278. * @param impostor impostor to get box size from
  53279. * @param result the resulting box size
  53280. */
  53281. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53282. /**
  53283. * Disposes of the impostor
  53284. */
  53285. dispose(): void;
  53286. /**
  53287. * Does a raycast in the physics world
  53288. * @param from when should the ray start?
  53289. * @param to when should the ray end?
  53290. * @returns PhysicsRaycastResult
  53291. */
  53292. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53293. }
  53294. }
  53295. declare module "babylonjs/Physics/Plugins/index" {
  53296. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  53297. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  53298. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  53299. }
  53300. declare module "babylonjs/Physics/index" {
  53301. export * from "babylonjs/Physics/IPhysicsEngine";
  53302. export * from "babylonjs/Physics/physicsEngine";
  53303. export * from "babylonjs/Physics/physicsEngineComponent";
  53304. export * from "babylonjs/Physics/physicsHelper";
  53305. export * from "babylonjs/Physics/physicsImpostor";
  53306. export * from "babylonjs/Physics/physicsJoint";
  53307. export * from "babylonjs/Physics/Plugins/index";
  53308. }
  53309. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  53310. /** @hidden */
  53311. export var blackAndWhitePixelShader: {
  53312. name: string;
  53313. shader: string;
  53314. };
  53315. }
  53316. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  53317. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53318. import { Camera } from "babylonjs/Cameras/camera";
  53319. import { Engine } from "babylonjs/Engines/engine";
  53320. import "babylonjs/Shaders/blackAndWhite.fragment";
  53321. /**
  53322. * Post process used to render in black and white
  53323. */
  53324. export class BlackAndWhitePostProcess extends PostProcess {
  53325. /**
  53326. * Linear about to convert he result to black and white (default: 1)
  53327. */
  53328. degree: number;
  53329. /**
  53330. * Creates a black and white post process
  53331. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  53332. * @param name The name of the effect.
  53333. * @param options The required width/height ratio to downsize to before computing the render pass.
  53334. * @param camera The camera to apply the render pass to.
  53335. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53336. * @param engine The engine which the post process will be applied. (default: current engine)
  53337. * @param reusable If the post process can be reused on the same frame. (default: false)
  53338. */
  53339. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53340. }
  53341. }
  53342. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  53343. import { Nullable } from "babylonjs/types";
  53344. import { Camera } from "babylonjs/Cameras/camera";
  53345. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53346. import { Engine } from "babylonjs/Engines/engine";
  53347. /**
  53348. * This represents a set of one or more post processes in Babylon.
  53349. * A post process can be used to apply a shader to a texture after it is rendered.
  53350. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53351. */
  53352. export class PostProcessRenderEffect {
  53353. private _postProcesses;
  53354. private _getPostProcesses;
  53355. private _singleInstance;
  53356. private _cameras;
  53357. private _indicesForCamera;
  53358. /**
  53359. * Name of the effect
  53360. * @hidden
  53361. */
  53362. _name: string;
  53363. /**
  53364. * Instantiates a post process render effect.
  53365. * A post process can be used to apply a shader to a texture after it is rendered.
  53366. * @param engine The engine the effect is tied to
  53367. * @param name The name of the effect
  53368. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  53369. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  53370. */
  53371. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  53372. /**
  53373. * Checks if all the post processes in the effect are supported.
  53374. */
  53375. readonly isSupported: boolean;
  53376. /**
  53377. * Updates the current state of the effect
  53378. * @hidden
  53379. */
  53380. _update(): void;
  53381. /**
  53382. * Attaches the effect on cameras
  53383. * @param cameras The camera to attach to.
  53384. * @hidden
  53385. */
  53386. _attachCameras(cameras: Camera): void;
  53387. /**
  53388. * Attaches the effect on cameras
  53389. * @param cameras The camera to attach to.
  53390. * @hidden
  53391. */
  53392. _attachCameras(cameras: Camera[]): void;
  53393. /**
  53394. * Detatches the effect on cameras
  53395. * @param cameras The camera to detatch from.
  53396. * @hidden
  53397. */
  53398. _detachCameras(cameras: Camera): void;
  53399. /**
  53400. * Detatches the effect on cameras
  53401. * @param cameras The camera to detatch from.
  53402. * @hidden
  53403. */
  53404. _detachCameras(cameras: Camera[]): void;
  53405. /**
  53406. * Enables the effect on given cameras
  53407. * @param cameras The camera to enable.
  53408. * @hidden
  53409. */
  53410. _enable(cameras: Camera): void;
  53411. /**
  53412. * Enables the effect on given cameras
  53413. * @param cameras The camera to enable.
  53414. * @hidden
  53415. */
  53416. _enable(cameras: Nullable<Camera[]>): void;
  53417. /**
  53418. * Disables the effect on the given cameras
  53419. * @param cameras The camera to disable.
  53420. * @hidden
  53421. */
  53422. _disable(cameras: Camera): void;
  53423. /**
  53424. * Disables the effect on the given cameras
  53425. * @param cameras The camera to disable.
  53426. * @hidden
  53427. */
  53428. _disable(cameras: Nullable<Camera[]>): void;
  53429. /**
  53430. * Gets a list of the post processes contained in the effect.
  53431. * @param camera The camera to get the post processes on.
  53432. * @returns The list of the post processes in the effect.
  53433. */
  53434. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  53435. }
  53436. }
  53437. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  53438. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53439. /** @hidden */
  53440. export var extractHighlightsPixelShader: {
  53441. name: string;
  53442. shader: string;
  53443. };
  53444. }
  53445. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  53446. import { Nullable } from "babylonjs/types";
  53447. import { Camera } from "babylonjs/Cameras/camera";
  53448. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53449. import { Engine } from "babylonjs/Engines/engine";
  53450. import "babylonjs/Shaders/extractHighlights.fragment";
  53451. /**
  53452. * 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.
  53453. */
  53454. export class ExtractHighlightsPostProcess extends PostProcess {
  53455. /**
  53456. * The luminance threshold, pixels below this value will be set to black.
  53457. */
  53458. threshold: number;
  53459. /** @hidden */
  53460. _exposure: number;
  53461. /**
  53462. * Post process which has the input texture to be used when performing highlight extraction
  53463. * @hidden
  53464. */
  53465. _inputPostProcess: Nullable<PostProcess>;
  53466. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53467. }
  53468. }
  53469. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  53470. /** @hidden */
  53471. export var bloomMergePixelShader: {
  53472. name: string;
  53473. shader: string;
  53474. };
  53475. }
  53476. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  53477. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53478. import { Nullable } from "babylonjs/types";
  53479. import { Engine } from "babylonjs/Engines/engine";
  53480. import { Camera } from "babylonjs/Cameras/camera";
  53481. import "babylonjs/Shaders/bloomMerge.fragment";
  53482. /**
  53483. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  53484. */
  53485. export class BloomMergePostProcess extends PostProcess {
  53486. /** Weight of the bloom to be added to the original input. */
  53487. weight: number;
  53488. /**
  53489. * Creates a new instance of @see BloomMergePostProcess
  53490. * @param name The name of the effect.
  53491. * @param originalFromInput Post process which's input will be used for the merge.
  53492. * @param blurred Blurred highlights post process which's output will be used.
  53493. * @param weight Weight of the bloom to be added to the original input.
  53494. * @param options The required width/height ratio to downsize to before computing the render pass.
  53495. * @param camera The camera to apply the render pass to.
  53496. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53497. * @param engine The engine which the post process will be applied. (default: current engine)
  53498. * @param reusable If the post process can be reused on the same frame. (default: false)
  53499. * @param textureType Type of textures used when performing the post process. (default: 0)
  53500. * @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)
  53501. */
  53502. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  53503. /** Weight of the bloom to be added to the original input. */
  53504. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53505. }
  53506. }
  53507. declare module "babylonjs/PostProcesses/bloomEffect" {
  53508. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  53509. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53510. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  53511. import { Camera } from "babylonjs/Cameras/camera";
  53512. import { Scene } from "babylonjs/scene";
  53513. /**
  53514. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  53515. */
  53516. export class BloomEffect extends PostProcessRenderEffect {
  53517. private bloomScale;
  53518. /**
  53519. * @hidden Internal
  53520. */
  53521. _effects: Array<PostProcess>;
  53522. /**
  53523. * @hidden Internal
  53524. */
  53525. _downscale: ExtractHighlightsPostProcess;
  53526. private _blurX;
  53527. private _blurY;
  53528. private _merge;
  53529. /**
  53530. * The luminance threshold to find bright areas of the image to bloom.
  53531. */
  53532. threshold: number;
  53533. /**
  53534. * The strength of the bloom.
  53535. */
  53536. weight: number;
  53537. /**
  53538. * Specifies the size of the bloom blur kernel, relative to the final output size
  53539. */
  53540. kernel: number;
  53541. /**
  53542. * Creates a new instance of @see BloomEffect
  53543. * @param scene The scene the effect belongs to.
  53544. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  53545. * @param bloomKernel The size of the kernel to be used when applying the blur.
  53546. * @param bloomWeight The the strength of bloom.
  53547. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  53548. * @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)
  53549. */
  53550. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  53551. /**
  53552. * Disposes each of the internal effects for a given camera.
  53553. * @param camera The camera to dispose the effect on.
  53554. */
  53555. disposeEffects(camera: Camera): void;
  53556. /**
  53557. * @hidden Internal
  53558. */
  53559. _updateEffects(): void;
  53560. /**
  53561. * Internal
  53562. * @returns if all the contained post processes are ready.
  53563. * @hidden
  53564. */
  53565. _isReady(): boolean;
  53566. }
  53567. }
  53568. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  53569. /** @hidden */
  53570. export var chromaticAberrationPixelShader: {
  53571. name: string;
  53572. shader: string;
  53573. };
  53574. }
  53575. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  53576. import { Vector2 } from "babylonjs/Maths/math";
  53577. import { Nullable } from "babylonjs/types";
  53578. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53579. import { Camera } from "babylonjs/Cameras/camera";
  53580. import { Engine } from "babylonjs/Engines/engine";
  53581. import "babylonjs/Shaders/chromaticAberration.fragment";
  53582. /**
  53583. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  53584. */
  53585. export class ChromaticAberrationPostProcess extends PostProcess {
  53586. /**
  53587. * The amount of seperation of rgb channels (default: 30)
  53588. */
  53589. aberrationAmount: number;
  53590. /**
  53591. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  53592. */
  53593. radialIntensity: number;
  53594. /**
  53595. * 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))
  53596. */
  53597. direction: Vector2;
  53598. /**
  53599. * 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))
  53600. */
  53601. centerPosition: Vector2;
  53602. /**
  53603. * Creates a new instance ChromaticAberrationPostProcess
  53604. * @param name The name of the effect.
  53605. * @param screenWidth The width of the screen to apply the effect on.
  53606. * @param screenHeight The height of the screen to apply the effect on.
  53607. * @param options The required width/height ratio to downsize to before computing the render pass.
  53608. * @param camera The camera to apply the render pass to.
  53609. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53610. * @param engine The engine which the post process will be applied. (default: current engine)
  53611. * @param reusable If the post process can be reused on the same frame. (default: false)
  53612. * @param textureType Type of textures used when performing the post process. (default: 0)
  53613. * @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)
  53614. */
  53615. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53616. }
  53617. }
  53618. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  53619. /** @hidden */
  53620. export var circleOfConfusionPixelShader: {
  53621. name: string;
  53622. shader: string;
  53623. };
  53624. }
  53625. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  53626. import { Nullable } from "babylonjs/types";
  53627. import { Engine } from "babylonjs/Engines/engine";
  53628. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53629. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53630. import { Camera } from "babylonjs/Cameras/camera";
  53631. import "babylonjs/Shaders/circleOfConfusion.fragment";
  53632. /**
  53633. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  53634. */
  53635. export class CircleOfConfusionPostProcess extends PostProcess {
  53636. /**
  53637. * 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.
  53638. */
  53639. lensSize: number;
  53640. /**
  53641. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  53642. */
  53643. fStop: number;
  53644. /**
  53645. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  53646. */
  53647. focusDistance: number;
  53648. /**
  53649. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  53650. */
  53651. focalLength: number;
  53652. private _depthTexture;
  53653. /**
  53654. * Creates a new instance CircleOfConfusionPostProcess
  53655. * @param name The name of the effect.
  53656. * @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.
  53657. * @param options The required width/height ratio to downsize to before computing the render pass.
  53658. * @param camera The camera to apply the render pass to.
  53659. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53660. * @param engine The engine which the post process will be applied. (default: current engine)
  53661. * @param reusable If the post process can be reused on the same frame. (default: false)
  53662. * @param textureType Type of textures used when performing the post process. (default: 0)
  53663. * @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)
  53664. */
  53665. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53666. /**
  53667. * 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.
  53668. */
  53669. depthTexture: RenderTargetTexture;
  53670. }
  53671. }
  53672. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  53673. /** @hidden */
  53674. export var colorCorrectionPixelShader: {
  53675. name: string;
  53676. shader: string;
  53677. };
  53678. }
  53679. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  53680. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53681. import { Engine } from "babylonjs/Engines/engine";
  53682. import { Camera } from "babylonjs/Cameras/camera";
  53683. import "babylonjs/Shaders/colorCorrection.fragment";
  53684. /**
  53685. *
  53686. * This post-process allows the modification of rendered colors by using
  53687. * a 'look-up table' (LUT). This effect is also called Color Grading.
  53688. *
  53689. * The object needs to be provided an url to a texture containing the color
  53690. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  53691. * Use an image editing software to tweak the LUT to match your needs.
  53692. *
  53693. * For an example of a color LUT, see here:
  53694. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  53695. * For explanations on color grading, see here:
  53696. * @see http://udn.epicgames.com/Three/ColorGrading.html
  53697. *
  53698. */
  53699. export class ColorCorrectionPostProcess extends PostProcess {
  53700. private _colorTableTexture;
  53701. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53702. }
  53703. }
  53704. declare module "babylonjs/Shaders/convolution.fragment" {
  53705. /** @hidden */
  53706. export var convolutionPixelShader: {
  53707. name: string;
  53708. shader: string;
  53709. };
  53710. }
  53711. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  53712. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53713. import { Nullable } from "babylonjs/types";
  53714. import { Camera } from "babylonjs/Cameras/camera";
  53715. import { Engine } from "babylonjs/Engines/engine";
  53716. import "babylonjs/Shaders/convolution.fragment";
  53717. /**
  53718. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  53719. * input texture to perform effects such as edge detection or sharpening
  53720. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  53721. */
  53722. export class ConvolutionPostProcess extends PostProcess {
  53723. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  53724. kernel: number[];
  53725. /**
  53726. * Creates a new instance ConvolutionPostProcess
  53727. * @param name The name of the effect.
  53728. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  53729. * @param options The required width/height ratio to downsize to before computing the render pass.
  53730. * @param camera The camera to apply the render pass to.
  53731. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53732. * @param engine The engine which the post process will be applied. (default: current engine)
  53733. * @param reusable If the post process can be reused on the same frame. (default: false)
  53734. * @param textureType Type of textures used when performing the post process. (default: 0)
  53735. */
  53736. constructor(name: string,
  53737. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  53738. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53739. /**
  53740. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53741. */
  53742. static EdgeDetect0Kernel: number[];
  53743. /**
  53744. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53745. */
  53746. static EdgeDetect1Kernel: number[];
  53747. /**
  53748. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53749. */
  53750. static EdgeDetect2Kernel: number[];
  53751. /**
  53752. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53753. */
  53754. static SharpenKernel: number[];
  53755. /**
  53756. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53757. */
  53758. static EmbossKernel: number[];
  53759. /**
  53760. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53761. */
  53762. static GaussianKernel: number[];
  53763. }
  53764. }
  53765. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  53766. import { Nullable } from "babylonjs/types";
  53767. import { Vector2 } from "babylonjs/Maths/math";
  53768. import { Camera } from "babylonjs/Cameras/camera";
  53769. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53770. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  53771. import { Engine } from "babylonjs/Engines/engine";
  53772. import { Scene } from "babylonjs/scene";
  53773. /**
  53774. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  53775. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  53776. * based on samples that have a large difference in distance than the center pixel.
  53777. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  53778. */
  53779. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  53780. direction: Vector2;
  53781. /**
  53782. * Creates a new instance CircleOfConfusionPostProcess
  53783. * @param name The name of the effect.
  53784. * @param scene The scene the effect belongs to.
  53785. * @param direction The direction the blur should be applied.
  53786. * @param kernel The size of the kernel used to blur.
  53787. * @param options The required width/height ratio to downsize to before computing the render pass.
  53788. * @param camera The camera to apply the render pass to.
  53789. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  53790. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  53791. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53792. * @param engine The engine which the post process will be applied. (default: current engine)
  53793. * @param reusable If the post process can be reused on the same frame. (default: false)
  53794. * @param textureType Type of textures used when performing the post process. (default: 0)
  53795. * @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)
  53796. */
  53797. 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);
  53798. }
  53799. }
  53800. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  53801. /** @hidden */
  53802. export var depthOfFieldMergePixelShader: {
  53803. name: string;
  53804. shader: string;
  53805. };
  53806. }
  53807. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  53808. import { Nullable } from "babylonjs/types";
  53809. import { Camera } from "babylonjs/Cameras/camera";
  53810. import { Effect } from "babylonjs/Materials/effect";
  53811. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53812. import { Engine } from "babylonjs/Engines/engine";
  53813. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  53814. /**
  53815. * Options to be set when merging outputs from the default pipeline.
  53816. */
  53817. export class DepthOfFieldMergePostProcessOptions {
  53818. /**
  53819. * The original image to merge on top of
  53820. */
  53821. originalFromInput: PostProcess;
  53822. /**
  53823. * Parameters to perform the merge of the depth of field effect
  53824. */
  53825. depthOfField?: {
  53826. circleOfConfusion: PostProcess;
  53827. blurSteps: Array<PostProcess>;
  53828. };
  53829. /**
  53830. * Parameters to perform the merge of bloom effect
  53831. */
  53832. bloom?: {
  53833. blurred: PostProcess;
  53834. weight: number;
  53835. };
  53836. }
  53837. /**
  53838. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  53839. */
  53840. export class DepthOfFieldMergePostProcess extends PostProcess {
  53841. private blurSteps;
  53842. /**
  53843. * Creates a new instance of DepthOfFieldMergePostProcess
  53844. * @param name The name of the effect.
  53845. * @param originalFromInput Post process which's input will be used for the merge.
  53846. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  53847. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  53848. * @param options The required width/height ratio to downsize to before computing the render pass.
  53849. * @param camera The camera to apply the render pass to.
  53850. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53851. * @param engine The engine which the post process will be applied. (default: current engine)
  53852. * @param reusable If the post process can be reused on the same frame. (default: false)
  53853. * @param textureType Type of textures used when performing the post process. (default: 0)
  53854. * @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)
  53855. */
  53856. 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);
  53857. /**
  53858. * Updates the effect with the current post process compile time values and recompiles the shader.
  53859. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  53860. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  53861. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  53862. * @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
  53863. * @param onCompiled Called when the shader has been compiled.
  53864. * @param onError Called if there is an error when compiling a shader.
  53865. */
  53866. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  53867. }
  53868. }
  53869. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  53870. import { Nullable } from "babylonjs/types";
  53871. import { Camera } from "babylonjs/Cameras/camera";
  53872. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53873. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53874. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  53875. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  53876. import { Scene } from "babylonjs/scene";
  53877. /**
  53878. * Specifies the level of max blur that should be applied when using the depth of field effect
  53879. */
  53880. export enum DepthOfFieldEffectBlurLevel {
  53881. /**
  53882. * Subtle blur
  53883. */
  53884. Low = 0,
  53885. /**
  53886. * Medium blur
  53887. */
  53888. Medium = 1,
  53889. /**
  53890. * Large blur
  53891. */
  53892. High = 2
  53893. }
  53894. /**
  53895. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  53896. */
  53897. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  53898. private _circleOfConfusion;
  53899. /**
  53900. * @hidden Internal, blurs from high to low
  53901. */
  53902. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  53903. private _depthOfFieldBlurY;
  53904. private _dofMerge;
  53905. /**
  53906. * @hidden Internal post processes in depth of field effect
  53907. */
  53908. _effects: Array<PostProcess>;
  53909. /**
  53910. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  53911. */
  53912. focalLength: number;
  53913. /**
  53914. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  53915. */
  53916. fStop: number;
  53917. /**
  53918. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  53919. */
  53920. focusDistance: number;
  53921. /**
  53922. * 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.
  53923. */
  53924. lensSize: number;
  53925. /**
  53926. * Creates a new instance DepthOfFieldEffect
  53927. * @param scene The scene the effect belongs to.
  53928. * @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.
  53929. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  53930. * @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)
  53931. */
  53932. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  53933. /**
  53934. * 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.
  53935. */
  53936. depthTexture: RenderTargetTexture;
  53937. /**
  53938. * Disposes each of the internal effects for a given camera.
  53939. * @param camera The camera to dispose the effect on.
  53940. */
  53941. disposeEffects(camera: Camera): void;
  53942. /**
  53943. * @hidden Internal
  53944. */
  53945. _updateEffects(): void;
  53946. /**
  53947. * Internal
  53948. * @returns if all the contained post processes are ready.
  53949. * @hidden
  53950. */
  53951. _isReady(): boolean;
  53952. }
  53953. }
  53954. declare module "babylonjs/Shaders/displayPass.fragment" {
  53955. /** @hidden */
  53956. export var displayPassPixelShader: {
  53957. name: string;
  53958. shader: string;
  53959. };
  53960. }
  53961. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  53962. import { Nullable } from "babylonjs/types";
  53963. import { Camera } from "babylonjs/Cameras/camera";
  53964. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53965. import { Engine } from "babylonjs/Engines/engine";
  53966. import "babylonjs/Shaders/displayPass.fragment";
  53967. /**
  53968. * DisplayPassPostProcess which produces an output the same as it's input
  53969. */
  53970. export class DisplayPassPostProcess extends PostProcess {
  53971. /**
  53972. * Creates the DisplayPassPostProcess
  53973. * @param name The name of the effect.
  53974. * @param options The required width/height ratio to downsize to before computing the render pass.
  53975. * @param camera The camera to apply the render pass to.
  53976. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53977. * @param engine The engine which the post process will be applied. (default: current engine)
  53978. * @param reusable If the post process can be reused on the same frame. (default: false)
  53979. */
  53980. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53981. }
  53982. }
  53983. declare module "babylonjs/Shaders/filter.fragment" {
  53984. /** @hidden */
  53985. export var filterPixelShader: {
  53986. name: string;
  53987. shader: string;
  53988. };
  53989. }
  53990. declare module "babylonjs/PostProcesses/filterPostProcess" {
  53991. import { Nullable } from "babylonjs/types";
  53992. import { Matrix } from "babylonjs/Maths/math";
  53993. import { Camera } from "babylonjs/Cameras/camera";
  53994. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53995. import { Engine } from "babylonjs/Engines/engine";
  53996. import "babylonjs/Shaders/filter.fragment";
  53997. /**
  53998. * Applies a kernel filter to the image
  53999. */
  54000. export class FilterPostProcess extends PostProcess {
  54001. /** The matrix to be applied to the image */
  54002. kernelMatrix: Matrix;
  54003. /**
  54004. *
  54005. * @param name The name of the effect.
  54006. * @param kernelMatrix The matrix to be applied to the image
  54007. * @param options The required width/height ratio to downsize to before computing the render pass.
  54008. * @param camera The camera to apply the render pass to.
  54009. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54010. * @param engine The engine which the post process will be applied. (default: current engine)
  54011. * @param reusable If the post process can be reused on the same frame. (default: false)
  54012. */
  54013. constructor(name: string,
  54014. /** The matrix to be applied to the image */
  54015. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54016. }
  54017. }
  54018. declare module "babylonjs/Shaders/fxaa.fragment" {
  54019. /** @hidden */
  54020. export var fxaaPixelShader: {
  54021. name: string;
  54022. shader: string;
  54023. };
  54024. }
  54025. declare module "babylonjs/Shaders/fxaa.vertex" {
  54026. /** @hidden */
  54027. export var fxaaVertexShader: {
  54028. name: string;
  54029. shader: string;
  54030. };
  54031. }
  54032. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  54033. import { Nullable } from "babylonjs/types";
  54034. import { Camera } from "babylonjs/Cameras/camera";
  54035. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54036. import { Engine } from "babylonjs/Engines/engine";
  54037. import "babylonjs/Shaders/fxaa.fragment";
  54038. import "babylonjs/Shaders/fxaa.vertex";
  54039. /**
  54040. * Fxaa post process
  54041. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  54042. */
  54043. export class FxaaPostProcess extends PostProcess {
  54044. /** @hidden */
  54045. texelWidth: number;
  54046. /** @hidden */
  54047. texelHeight: number;
  54048. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54049. private _getDefines;
  54050. }
  54051. }
  54052. declare module "babylonjs/Shaders/grain.fragment" {
  54053. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54054. /** @hidden */
  54055. export var grainPixelShader: {
  54056. name: string;
  54057. shader: string;
  54058. };
  54059. }
  54060. declare module "babylonjs/PostProcesses/grainPostProcess" {
  54061. import { Nullable } from "babylonjs/types";
  54062. import { Camera } from "babylonjs/Cameras/camera";
  54063. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54064. import { Engine } from "babylonjs/Engines/engine";
  54065. import "babylonjs/Shaders/grain.fragment";
  54066. /**
  54067. * The GrainPostProcess adds noise to the image at mid luminance levels
  54068. */
  54069. export class GrainPostProcess extends PostProcess {
  54070. /**
  54071. * The intensity of the grain added (default: 30)
  54072. */
  54073. intensity: number;
  54074. /**
  54075. * If the grain should be randomized on every frame
  54076. */
  54077. animated: boolean;
  54078. /**
  54079. * Creates a new instance of @see GrainPostProcess
  54080. * @param name The name of the effect.
  54081. * @param options The required width/height ratio to downsize to before computing the render pass.
  54082. * @param camera The camera to apply the render pass to.
  54083. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54084. * @param engine The engine which the post process will be applied. (default: current engine)
  54085. * @param reusable If the post process can be reused on the same frame. (default: false)
  54086. * @param textureType Type of textures used when performing the post process. (default: 0)
  54087. * @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)
  54088. */
  54089. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54090. }
  54091. }
  54092. declare module "babylonjs/Shaders/highlights.fragment" {
  54093. /** @hidden */
  54094. export var highlightsPixelShader: {
  54095. name: string;
  54096. shader: string;
  54097. };
  54098. }
  54099. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  54100. import { Nullable } from "babylonjs/types";
  54101. import { Camera } from "babylonjs/Cameras/camera";
  54102. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54103. import { Engine } from "babylonjs/Engines/engine";
  54104. import "babylonjs/Shaders/highlights.fragment";
  54105. /**
  54106. * Extracts highlights from the image
  54107. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  54108. */
  54109. export class HighlightsPostProcess extends PostProcess {
  54110. /**
  54111. * Extracts highlights from the image
  54112. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  54113. * @param name The name of the effect.
  54114. * @param options The required width/height ratio to downsize to before computing the render pass.
  54115. * @param camera The camera to apply the render pass to.
  54116. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54117. * @param engine The engine which the post process will be applied. (default: current engine)
  54118. * @param reusable If the post process can be reused on the same frame. (default: false)
  54119. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  54120. */
  54121. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54122. }
  54123. }
  54124. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  54125. /** @hidden */
  54126. export var mrtFragmentDeclaration: {
  54127. name: string;
  54128. shader: string;
  54129. };
  54130. }
  54131. declare module "babylonjs/Shaders/geometry.fragment" {
  54132. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  54133. /** @hidden */
  54134. export var geometryPixelShader: {
  54135. name: string;
  54136. shader: string;
  54137. };
  54138. }
  54139. declare module "babylonjs/Shaders/geometry.vertex" {
  54140. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54141. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54142. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54143. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54144. /** @hidden */
  54145. export var geometryVertexShader: {
  54146. name: string;
  54147. shader: string;
  54148. };
  54149. }
  54150. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  54151. import { Matrix } from "babylonjs/Maths/math";
  54152. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54153. import { Mesh } from "babylonjs/Meshes/mesh";
  54154. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  54155. import { Effect } from "babylonjs/Materials/effect";
  54156. import { Scene } from "babylonjs/scene";
  54157. import "babylonjs/Shaders/geometry.fragment";
  54158. import "babylonjs/Shaders/geometry.vertex";
  54159. /**
  54160. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  54161. */
  54162. export class GeometryBufferRenderer {
  54163. /**
  54164. * Constant used to retrieve the position texture index in the G-Buffer textures array
  54165. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  54166. */
  54167. static readonly POSITION_TEXTURE_TYPE: number;
  54168. /**
  54169. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  54170. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  54171. */
  54172. static readonly VELOCITY_TEXTURE_TYPE: number;
  54173. /**
  54174. * Dictionary used to store the previous transformation matrices of each rendered mesh
  54175. * in order to compute objects velocities when enableVelocity is set to "true"
  54176. * @hidden
  54177. */
  54178. _previousTransformationMatrices: {
  54179. [index: number]: Matrix;
  54180. };
  54181. private _scene;
  54182. private _multiRenderTarget;
  54183. private _ratio;
  54184. private _enablePosition;
  54185. private _enableVelocity;
  54186. private _positionIndex;
  54187. private _velocityIndex;
  54188. protected _effect: Effect;
  54189. protected _cachedDefines: string;
  54190. /**
  54191. * Set the render list (meshes to be rendered) used in the G buffer.
  54192. */
  54193. renderList: Mesh[];
  54194. /**
  54195. * Gets wether or not G buffer are supported by the running hardware.
  54196. * This requires draw buffer supports
  54197. */
  54198. readonly isSupported: boolean;
  54199. /**
  54200. * Returns the index of the given texture type in the G-Buffer textures array
  54201. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  54202. * @returns the index of the given texture type in the G-Buffer textures array
  54203. */
  54204. getTextureIndex(textureType: number): number;
  54205. /**
  54206. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  54207. */
  54208. /**
  54209. * Sets whether or not objects positions are enabled for the G buffer.
  54210. */
  54211. enablePosition: boolean;
  54212. /**
  54213. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  54214. */
  54215. /**
  54216. * Sets wether or not objects velocities are enabled for the G buffer.
  54217. */
  54218. enableVelocity: boolean;
  54219. /**
  54220. * Gets the scene associated with the buffer.
  54221. */
  54222. readonly scene: Scene;
  54223. /**
  54224. * Gets the ratio used by the buffer during its creation.
  54225. * How big is the buffer related to the main canvas.
  54226. */
  54227. readonly ratio: number;
  54228. /** @hidden */
  54229. static _SceneComponentInitialization: (scene: Scene) => void;
  54230. /**
  54231. * Creates a new G Buffer for the scene
  54232. * @param scene The scene the buffer belongs to
  54233. * @param ratio How big is the buffer related to the main canvas.
  54234. */
  54235. constructor(scene: Scene, ratio?: number);
  54236. /**
  54237. * Checks wether everything is ready to render a submesh to the G buffer.
  54238. * @param subMesh the submesh to check readiness for
  54239. * @param useInstances is the mesh drawn using instance or not
  54240. * @returns true if ready otherwise false
  54241. */
  54242. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54243. /**
  54244. * Gets the current underlying G Buffer.
  54245. * @returns the buffer
  54246. */
  54247. getGBuffer(): MultiRenderTarget;
  54248. /**
  54249. * Gets the number of samples used to render the buffer (anti aliasing).
  54250. */
  54251. /**
  54252. * Sets the number of samples used to render the buffer (anti aliasing).
  54253. */
  54254. samples: number;
  54255. /**
  54256. * Disposes the renderer and frees up associated resources.
  54257. */
  54258. dispose(): void;
  54259. protected _createRenderTargets(): void;
  54260. }
  54261. }
  54262. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  54263. import { Nullable } from "babylonjs/types";
  54264. import { Scene } from "babylonjs/scene";
  54265. import { ISceneComponent } from "babylonjs/sceneComponent";
  54266. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  54267. module "babylonjs/scene" {
  54268. interface Scene {
  54269. /** @hidden (Backing field) */
  54270. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54271. /**
  54272. * Gets or Sets the current geometry buffer associated to the scene.
  54273. */
  54274. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54275. /**
  54276. * Enables a GeometryBufferRender and associates it with the scene
  54277. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  54278. * @returns the GeometryBufferRenderer
  54279. */
  54280. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  54281. /**
  54282. * Disables the GeometryBufferRender associated with the scene
  54283. */
  54284. disableGeometryBufferRenderer(): void;
  54285. }
  54286. }
  54287. /**
  54288. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  54289. * in several rendering techniques.
  54290. */
  54291. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  54292. /**
  54293. * The component name helpful to identify the component in the list of scene components.
  54294. */
  54295. readonly name: string;
  54296. /**
  54297. * The scene the component belongs to.
  54298. */
  54299. scene: Scene;
  54300. /**
  54301. * Creates a new instance of the component for the given scene
  54302. * @param scene Defines the scene to register the component in
  54303. */
  54304. constructor(scene: Scene);
  54305. /**
  54306. * Registers the component in a given scene
  54307. */
  54308. register(): void;
  54309. /**
  54310. * Rebuilds the elements related to this component in case of
  54311. * context lost for instance.
  54312. */
  54313. rebuild(): void;
  54314. /**
  54315. * Disposes the component and the associated ressources
  54316. */
  54317. dispose(): void;
  54318. private _gatherRenderTargets;
  54319. }
  54320. }
  54321. declare module "babylonjs/Shaders/motionBlur.fragment" {
  54322. /** @hidden */
  54323. export var motionBlurPixelShader: {
  54324. name: string;
  54325. shader: string;
  54326. };
  54327. }
  54328. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  54329. import { Nullable } from "babylonjs/types";
  54330. import { Camera } from "babylonjs/Cameras/camera";
  54331. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54332. import { Scene } from "babylonjs/scene";
  54333. import "babylonjs/Animations/animatable";
  54334. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  54335. import "babylonjs/Shaders/motionBlur.fragment";
  54336. import { Engine } from "babylonjs/Engines/engine";
  54337. /**
  54338. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  54339. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  54340. * As an example, all you have to do is to create the post-process:
  54341. * var mb = new BABYLON.MotionBlurPostProcess(
  54342. * 'mb', // The name of the effect.
  54343. * scene, // The scene containing the objects to blur according to their velocity.
  54344. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  54345. * camera // The camera to apply the render pass to.
  54346. * );
  54347. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  54348. */
  54349. export class MotionBlurPostProcess extends PostProcess {
  54350. /**
  54351. * Defines how much the image is blurred by the movement. Default value is equal to 1
  54352. */
  54353. motionStrength: number;
  54354. /**
  54355. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  54356. */
  54357. /**
  54358. * Sets the number of iterations to be used for motion blur quality
  54359. */
  54360. motionBlurSamples: number;
  54361. private _motionBlurSamples;
  54362. private _geometryBufferRenderer;
  54363. /**
  54364. * Creates a new instance MotionBlurPostProcess
  54365. * @param name The name of the effect.
  54366. * @param scene The scene containing the objects to blur according to their velocity.
  54367. * @param options The required width/height ratio to downsize to before computing the render pass.
  54368. * @param camera The camera to apply the render pass to.
  54369. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54370. * @param engine The engine which the post process will be applied. (default: current engine)
  54371. * @param reusable If the post process can be reused on the same frame. (default: false)
  54372. * @param textureType Type of textures used when performing the post process. (default: 0)
  54373. * @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)
  54374. */
  54375. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54376. /**
  54377. * Disposes the post process.
  54378. * @param camera The camera to dispose the post process on.
  54379. */
  54380. dispose(camera?: Camera): void;
  54381. }
  54382. }
  54383. declare module "babylonjs/Shaders/refraction.fragment" {
  54384. /** @hidden */
  54385. export var refractionPixelShader: {
  54386. name: string;
  54387. shader: string;
  54388. };
  54389. }
  54390. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  54391. import { Color3 } from "babylonjs/Maths/math";
  54392. import { Camera } from "babylonjs/Cameras/camera";
  54393. import { Texture } from "babylonjs/Materials/Textures/texture";
  54394. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54395. import { Engine } from "babylonjs/Engines/engine";
  54396. import "babylonjs/Shaders/refraction.fragment";
  54397. /**
  54398. * Post process which applies a refractin texture
  54399. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  54400. */
  54401. export class RefractionPostProcess extends PostProcess {
  54402. /** the base color of the refraction (used to taint the rendering) */
  54403. color: Color3;
  54404. /** simulated refraction depth */
  54405. depth: number;
  54406. /** the coefficient of the base color (0 to remove base color tainting) */
  54407. colorLevel: number;
  54408. private _refTexture;
  54409. private _ownRefractionTexture;
  54410. /**
  54411. * Gets or sets the refraction texture
  54412. * Please note that you are responsible for disposing the texture if you set it manually
  54413. */
  54414. refractionTexture: Texture;
  54415. /**
  54416. * Initializes the RefractionPostProcess
  54417. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  54418. * @param name The name of the effect.
  54419. * @param refractionTextureUrl Url of the refraction texture to use
  54420. * @param color the base color of the refraction (used to taint the rendering)
  54421. * @param depth simulated refraction depth
  54422. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  54423. * @param camera The camera to apply the render pass to.
  54424. * @param options The required width/height ratio to downsize to before computing the render pass.
  54425. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54426. * @param engine The engine which the post process will be applied. (default: current engine)
  54427. * @param reusable If the post process can be reused on the same frame. (default: false)
  54428. */
  54429. constructor(name: string, refractionTextureUrl: string,
  54430. /** the base color of the refraction (used to taint the rendering) */
  54431. color: Color3,
  54432. /** simulated refraction depth */
  54433. depth: number,
  54434. /** the coefficient of the base color (0 to remove base color tainting) */
  54435. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54436. /**
  54437. * Disposes of the post process
  54438. * @param camera Camera to dispose post process on
  54439. */
  54440. dispose(camera: Camera): void;
  54441. }
  54442. }
  54443. declare module "babylonjs/Shaders/sharpen.fragment" {
  54444. /** @hidden */
  54445. export var sharpenPixelShader: {
  54446. name: string;
  54447. shader: string;
  54448. };
  54449. }
  54450. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  54451. import { Nullable } from "babylonjs/types";
  54452. import { Camera } from "babylonjs/Cameras/camera";
  54453. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54454. import "babylonjs/Shaders/sharpen.fragment";
  54455. import { Engine } from "babylonjs/Engines/engine";
  54456. /**
  54457. * The SharpenPostProcess applies a sharpen kernel to every pixel
  54458. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  54459. */
  54460. export class SharpenPostProcess extends PostProcess {
  54461. /**
  54462. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  54463. */
  54464. colorAmount: number;
  54465. /**
  54466. * How much sharpness should be applied (default: 0.3)
  54467. */
  54468. edgeAmount: number;
  54469. /**
  54470. * Creates a new instance ConvolutionPostProcess
  54471. * @param name The name of the effect.
  54472. * @param options The required width/height ratio to downsize to before computing the render pass.
  54473. * @param camera The camera to apply the render pass to.
  54474. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54475. * @param engine The engine which the post process will be applied. (default: current engine)
  54476. * @param reusable If the post process can be reused on the same frame. (default: false)
  54477. * @param textureType Type of textures used when performing the post process. (default: 0)
  54478. * @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)
  54479. */
  54480. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54481. }
  54482. }
  54483. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  54484. import { Nullable } from "babylonjs/types";
  54485. import { Camera } from "babylonjs/Cameras/camera";
  54486. import { Engine } from "babylonjs/Engines/engine";
  54487. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54488. import { IInspectable } from "babylonjs/Misc/iInspectable";
  54489. /**
  54490. * PostProcessRenderPipeline
  54491. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54492. */
  54493. export class PostProcessRenderPipeline {
  54494. private engine;
  54495. private _renderEffects;
  54496. private _renderEffectsForIsolatedPass;
  54497. /**
  54498. * List of inspectable custom properties (used by the Inspector)
  54499. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  54500. */
  54501. inspectableCustomProperties: IInspectable[];
  54502. /**
  54503. * @hidden
  54504. */
  54505. protected _cameras: Camera[];
  54506. /** @hidden */
  54507. _name: string;
  54508. /**
  54509. * Gets pipeline name
  54510. */
  54511. readonly name: string;
  54512. /**
  54513. * Initializes a PostProcessRenderPipeline
  54514. * @param engine engine to add the pipeline to
  54515. * @param name name of the pipeline
  54516. */
  54517. constructor(engine: Engine, name: string);
  54518. /**
  54519. * Gets the class name
  54520. * @returns "PostProcessRenderPipeline"
  54521. */
  54522. getClassName(): string;
  54523. /**
  54524. * If all the render effects in the pipeline are supported
  54525. */
  54526. readonly isSupported: boolean;
  54527. /**
  54528. * Adds an effect to the pipeline
  54529. * @param renderEffect the effect to add
  54530. */
  54531. addEffect(renderEffect: PostProcessRenderEffect): void;
  54532. /** @hidden */
  54533. _rebuild(): void;
  54534. /** @hidden */
  54535. _enableEffect(renderEffectName: string, cameras: Camera): void;
  54536. /** @hidden */
  54537. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  54538. /** @hidden */
  54539. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  54540. /** @hidden */
  54541. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  54542. /** @hidden */
  54543. _attachCameras(cameras: Camera, unique: boolean): void;
  54544. /** @hidden */
  54545. _attachCameras(cameras: Camera[], unique: boolean): void;
  54546. /** @hidden */
  54547. _detachCameras(cameras: Camera): void;
  54548. /** @hidden */
  54549. _detachCameras(cameras: Nullable<Camera[]>): void;
  54550. /** @hidden */
  54551. _update(): void;
  54552. /** @hidden */
  54553. _reset(): void;
  54554. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  54555. /**
  54556. * Disposes of the pipeline
  54557. */
  54558. dispose(): void;
  54559. }
  54560. }
  54561. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  54562. import { Camera } from "babylonjs/Cameras/camera";
  54563. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54564. /**
  54565. * PostProcessRenderPipelineManager class
  54566. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54567. */
  54568. export class PostProcessRenderPipelineManager {
  54569. private _renderPipelines;
  54570. /**
  54571. * Initializes a PostProcessRenderPipelineManager
  54572. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54573. */
  54574. constructor();
  54575. /**
  54576. * Gets the list of supported render pipelines
  54577. */
  54578. readonly supportedPipelines: PostProcessRenderPipeline[];
  54579. /**
  54580. * Adds a pipeline to the manager
  54581. * @param renderPipeline The pipeline to add
  54582. */
  54583. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  54584. /**
  54585. * Attaches a camera to the pipeline
  54586. * @param renderPipelineName The name of the pipeline to attach to
  54587. * @param cameras the camera to attach
  54588. * @param unique if the camera can be attached multiple times to the pipeline
  54589. */
  54590. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  54591. /**
  54592. * Detaches a camera from the pipeline
  54593. * @param renderPipelineName The name of the pipeline to detach from
  54594. * @param cameras the camera to detach
  54595. */
  54596. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  54597. /**
  54598. * Enables an effect by name on a pipeline
  54599. * @param renderPipelineName the name of the pipeline to enable the effect in
  54600. * @param renderEffectName the name of the effect to enable
  54601. * @param cameras the cameras that the effect should be enabled on
  54602. */
  54603. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  54604. /**
  54605. * Disables an effect by name on a pipeline
  54606. * @param renderPipelineName the name of the pipeline to disable the effect in
  54607. * @param renderEffectName the name of the effect to disable
  54608. * @param cameras the cameras that the effect should be disabled on
  54609. */
  54610. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  54611. /**
  54612. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  54613. */
  54614. update(): void;
  54615. /** @hidden */
  54616. _rebuild(): void;
  54617. /**
  54618. * Disposes of the manager and pipelines
  54619. */
  54620. dispose(): void;
  54621. }
  54622. }
  54623. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  54624. import { ISceneComponent } from "babylonjs/sceneComponent";
  54625. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  54626. import { Scene } from "babylonjs/scene";
  54627. module "babylonjs/scene" {
  54628. interface Scene {
  54629. /** @hidden (Backing field) */
  54630. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  54631. /**
  54632. * Gets the postprocess render pipeline manager
  54633. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54634. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  54635. */
  54636. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  54637. }
  54638. }
  54639. /**
  54640. * Defines the Render Pipeline scene component responsible to rendering pipelines
  54641. */
  54642. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  54643. /**
  54644. * The component name helpfull to identify the component in the list of scene components.
  54645. */
  54646. readonly name: string;
  54647. /**
  54648. * The scene the component belongs to.
  54649. */
  54650. scene: Scene;
  54651. /**
  54652. * Creates a new instance of the component for the given scene
  54653. * @param scene Defines the scene to register the component in
  54654. */
  54655. constructor(scene: Scene);
  54656. /**
  54657. * Registers the component in a given scene
  54658. */
  54659. register(): void;
  54660. /**
  54661. * Rebuilds the elements related to this component in case of
  54662. * context lost for instance.
  54663. */
  54664. rebuild(): void;
  54665. /**
  54666. * Disposes the component and the associated ressources
  54667. */
  54668. dispose(): void;
  54669. private _gatherRenderTargets;
  54670. }
  54671. }
  54672. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  54673. import { IAnimatable } from "babylonjs/Misc/tools";
  54674. import { Camera } from "babylonjs/Cameras/camera";
  54675. import { IDisposable } from "babylonjs/scene";
  54676. import { Scene } from "babylonjs/scene";
  54677. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  54678. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  54679. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  54680. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  54681. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  54682. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54683. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  54684. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  54685. import { Animation } from "babylonjs/Animations/animation";
  54686. /**
  54687. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  54688. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  54689. */
  54690. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  54691. private _scene;
  54692. private _camerasToBeAttached;
  54693. /**
  54694. * ID of the sharpen post process,
  54695. */
  54696. private readonly SharpenPostProcessId;
  54697. /**
  54698. * @ignore
  54699. * ID of the image processing post process;
  54700. */
  54701. readonly ImageProcessingPostProcessId: string;
  54702. /**
  54703. * @ignore
  54704. * ID of the Fast Approximate Anti-Aliasing post process;
  54705. */
  54706. readonly FxaaPostProcessId: string;
  54707. /**
  54708. * ID of the chromatic aberration post process,
  54709. */
  54710. private readonly ChromaticAberrationPostProcessId;
  54711. /**
  54712. * ID of the grain post process
  54713. */
  54714. private readonly GrainPostProcessId;
  54715. /**
  54716. * Sharpen post process which will apply a sharpen convolution to enhance edges
  54717. */
  54718. sharpen: SharpenPostProcess;
  54719. private _sharpenEffect;
  54720. private bloom;
  54721. /**
  54722. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  54723. */
  54724. depthOfField: DepthOfFieldEffect;
  54725. /**
  54726. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  54727. */
  54728. fxaa: FxaaPostProcess;
  54729. /**
  54730. * Image post processing pass used to perform operations such as tone mapping or color grading.
  54731. */
  54732. imageProcessing: ImageProcessingPostProcess;
  54733. /**
  54734. * Chromatic aberration post process which will shift rgb colors in the image
  54735. */
  54736. chromaticAberration: ChromaticAberrationPostProcess;
  54737. private _chromaticAberrationEffect;
  54738. /**
  54739. * Grain post process which add noise to the image
  54740. */
  54741. grain: GrainPostProcess;
  54742. private _grainEffect;
  54743. /**
  54744. * Glow post process which adds a glow to emissive areas of the image
  54745. */
  54746. private _glowLayer;
  54747. /**
  54748. * Animations which can be used to tweak settings over a period of time
  54749. */
  54750. animations: Animation[];
  54751. private _imageProcessingConfigurationObserver;
  54752. private _sharpenEnabled;
  54753. private _bloomEnabled;
  54754. private _depthOfFieldEnabled;
  54755. private _depthOfFieldBlurLevel;
  54756. private _fxaaEnabled;
  54757. private _imageProcessingEnabled;
  54758. private _defaultPipelineTextureType;
  54759. private _bloomScale;
  54760. private _chromaticAberrationEnabled;
  54761. private _grainEnabled;
  54762. private _buildAllowed;
  54763. /**
  54764. * Gets active scene
  54765. */
  54766. readonly scene: Scene;
  54767. /**
  54768. * Enable or disable the sharpen process from the pipeline
  54769. */
  54770. sharpenEnabled: boolean;
  54771. private _resizeObserver;
  54772. private _hardwareScaleLevel;
  54773. private _bloomKernel;
  54774. /**
  54775. * Specifies the size of the bloom blur kernel, relative to the final output size
  54776. */
  54777. bloomKernel: number;
  54778. /**
  54779. * Specifies the weight of the bloom in the final rendering
  54780. */
  54781. private _bloomWeight;
  54782. /**
  54783. * Specifies the luma threshold for the area that will be blurred by the bloom
  54784. */
  54785. private _bloomThreshold;
  54786. private _hdr;
  54787. /**
  54788. * The strength of the bloom.
  54789. */
  54790. bloomWeight: number;
  54791. /**
  54792. * The strength of the bloom.
  54793. */
  54794. bloomThreshold: number;
  54795. /**
  54796. * The scale of the bloom, lower value will provide better performance.
  54797. */
  54798. bloomScale: number;
  54799. /**
  54800. * Enable or disable the bloom from the pipeline
  54801. */
  54802. bloomEnabled: boolean;
  54803. private _rebuildBloom;
  54804. /**
  54805. * If the depth of field is enabled.
  54806. */
  54807. depthOfFieldEnabled: boolean;
  54808. /**
  54809. * Blur level of the depth of field effect. (Higher blur will effect performance)
  54810. */
  54811. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  54812. /**
  54813. * If the anti aliasing is enabled.
  54814. */
  54815. fxaaEnabled: boolean;
  54816. private _samples;
  54817. /**
  54818. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  54819. */
  54820. samples: number;
  54821. /**
  54822. * If image processing is enabled.
  54823. */
  54824. imageProcessingEnabled: boolean;
  54825. /**
  54826. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  54827. */
  54828. glowLayerEnabled: boolean;
  54829. /**
  54830. * Enable or disable the chromaticAberration process from the pipeline
  54831. */
  54832. chromaticAberrationEnabled: boolean;
  54833. /**
  54834. * Enable or disable the grain process from the pipeline
  54835. */
  54836. grainEnabled: boolean;
  54837. /**
  54838. * @constructor
  54839. * @param name - The rendering pipeline name (default: "")
  54840. * @param hdr - If high dynamic range textures should be used (default: true)
  54841. * @param scene - The scene linked to this pipeline (default: the last created scene)
  54842. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  54843. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  54844. */
  54845. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  54846. /**
  54847. * Get the class name
  54848. * @returns "DefaultRenderingPipeline"
  54849. */
  54850. getClassName(): string;
  54851. /**
  54852. * Force the compilation of the entire pipeline.
  54853. */
  54854. prepare(): void;
  54855. private _hasCleared;
  54856. private _prevPostProcess;
  54857. private _prevPrevPostProcess;
  54858. private _setAutoClearAndTextureSharing;
  54859. private _depthOfFieldSceneObserver;
  54860. private _buildPipeline;
  54861. private _disposePostProcesses;
  54862. /**
  54863. * Adds a camera to the pipeline
  54864. * @param camera the camera to be added
  54865. */
  54866. addCamera(camera: Camera): void;
  54867. /**
  54868. * Removes a camera from the pipeline
  54869. * @param camera the camera to remove
  54870. */
  54871. removeCamera(camera: Camera): void;
  54872. /**
  54873. * Dispose of the pipeline and stop all post processes
  54874. */
  54875. dispose(): void;
  54876. /**
  54877. * Serialize the rendering pipeline (Used when exporting)
  54878. * @returns the serialized object
  54879. */
  54880. serialize(): any;
  54881. /**
  54882. * Parse the serialized pipeline
  54883. * @param source Source pipeline.
  54884. * @param scene The scene to load the pipeline to.
  54885. * @param rootUrl The URL of the serialized pipeline.
  54886. * @returns An instantiated pipeline from the serialized object.
  54887. */
  54888. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  54889. }
  54890. }
  54891. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  54892. /** @hidden */
  54893. export var lensHighlightsPixelShader: {
  54894. name: string;
  54895. shader: string;
  54896. };
  54897. }
  54898. declare module "babylonjs/Shaders/depthOfField.fragment" {
  54899. /** @hidden */
  54900. export var depthOfFieldPixelShader: {
  54901. name: string;
  54902. shader: string;
  54903. };
  54904. }
  54905. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  54906. import { Camera } from "babylonjs/Cameras/camera";
  54907. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54908. import { Scene } from "babylonjs/scene";
  54909. import "babylonjs/Shaders/chromaticAberration.fragment";
  54910. import "babylonjs/Shaders/lensHighlights.fragment";
  54911. import "babylonjs/Shaders/depthOfField.fragment";
  54912. /**
  54913. * BABYLON.JS Chromatic Aberration GLSL Shader
  54914. * Author: Olivier Guyot
  54915. * Separates very slightly R, G and B colors on the edges of the screen
  54916. * Inspired by Francois Tarlier & Martins Upitis
  54917. */
  54918. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  54919. /**
  54920. * @ignore
  54921. * The chromatic aberration PostProcess id in the pipeline
  54922. */
  54923. LensChromaticAberrationEffect: string;
  54924. /**
  54925. * @ignore
  54926. * The highlights enhancing PostProcess id in the pipeline
  54927. */
  54928. HighlightsEnhancingEffect: string;
  54929. /**
  54930. * @ignore
  54931. * The depth-of-field PostProcess id in the pipeline
  54932. */
  54933. LensDepthOfFieldEffect: string;
  54934. private _scene;
  54935. private _depthTexture;
  54936. private _grainTexture;
  54937. private _chromaticAberrationPostProcess;
  54938. private _highlightsPostProcess;
  54939. private _depthOfFieldPostProcess;
  54940. private _edgeBlur;
  54941. private _grainAmount;
  54942. private _chromaticAberration;
  54943. private _distortion;
  54944. private _highlightsGain;
  54945. private _highlightsThreshold;
  54946. private _dofDistance;
  54947. private _dofAperture;
  54948. private _dofDarken;
  54949. private _dofPentagon;
  54950. private _blurNoise;
  54951. /**
  54952. * @constructor
  54953. *
  54954. * Effect parameters are as follow:
  54955. * {
  54956. * chromatic_aberration: number; // from 0 to x (1 for realism)
  54957. * edge_blur: number; // from 0 to x (1 for realism)
  54958. * distortion: number; // from 0 to x (1 for realism)
  54959. * grain_amount: number; // from 0 to 1
  54960. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  54961. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  54962. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  54963. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  54964. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  54965. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  54966. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  54967. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  54968. * }
  54969. * Note: if an effect parameter is unset, effect is disabled
  54970. *
  54971. * @param name The rendering pipeline name
  54972. * @param parameters - An object containing all parameters (see above)
  54973. * @param scene The scene linked to this pipeline
  54974. * @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)
  54975. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54976. */
  54977. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  54978. /**
  54979. * Get the class name
  54980. * @returns "LensRenderingPipeline"
  54981. */
  54982. getClassName(): string;
  54983. /**
  54984. * Gets associated scene
  54985. */
  54986. readonly scene: Scene;
  54987. /**
  54988. * Gets or sets the edge blur
  54989. */
  54990. edgeBlur: number;
  54991. /**
  54992. * Gets or sets the grain amount
  54993. */
  54994. grainAmount: number;
  54995. /**
  54996. * Gets or sets the chromatic aberration amount
  54997. */
  54998. chromaticAberration: number;
  54999. /**
  55000. * Gets or sets the depth of field aperture
  55001. */
  55002. dofAperture: number;
  55003. /**
  55004. * Gets or sets the edge distortion
  55005. */
  55006. edgeDistortion: number;
  55007. /**
  55008. * Gets or sets the depth of field distortion
  55009. */
  55010. dofDistortion: number;
  55011. /**
  55012. * Gets or sets the darken out of focus amount
  55013. */
  55014. darkenOutOfFocus: number;
  55015. /**
  55016. * Gets or sets a boolean indicating if blur noise is enabled
  55017. */
  55018. blurNoise: boolean;
  55019. /**
  55020. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  55021. */
  55022. pentagonBokeh: boolean;
  55023. /**
  55024. * Gets or sets the highlight grain amount
  55025. */
  55026. highlightsGain: number;
  55027. /**
  55028. * Gets or sets the highlight threshold
  55029. */
  55030. highlightsThreshold: number;
  55031. /**
  55032. * Sets the amount of blur at the edges
  55033. * @param amount blur amount
  55034. */
  55035. setEdgeBlur(amount: number): void;
  55036. /**
  55037. * Sets edge blur to 0
  55038. */
  55039. disableEdgeBlur(): void;
  55040. /**
  55041. * Sets the amout of grain
  55042. * @param amount Amount of grain
  55043. */
  55044. setGrainAmount(amount: number): void;
  55045. /**
  55046. * Set grain amount to 0
  55047. */
  55048. disableGrain(): void;
  55049. /**
  55050. * Sets the chromatic aberration amount
  55051. * @param amount amount of chromatic aberration
  55052. */
  55053. setChromaticAberration(amount: number): void;
  55054. /**
  55055. * Sets chromatic aberration amount to 0
  55056. */
  55057. disableChromaticAberration(): void;
  55058. /**
  55059. * Sets the EdgeDistortion amount
  55060. * @param amount amount of EdgeDistortion
  55061. */
  55062. setEdgeDistortion(amount: number): void;
  55063. /**
  55064. * Sets edge distortion to 0
  55065. */
  55066. disableEdgeDistortion(): void;
  55067. /**
  55068. * Sets the FocusDistance amount
  55069. * @param amount amount of FocusDistance
  55070. */
  55071. setFocusDistance(amount: number): void;
  55072. /**
  55073. * Disables depth of field
  55074. */
  55075. disableDepthOfField(): void;
  55076. /**
  55077. * Sets the Aperture amount
  55078. * @param amount amount of Aperture
  55079. */
  55080. setAperture(amount: number): void;
  55081. /**
  55082. * Sets the DarkenOutOfFocus amount
  55083. * @param amount amount of DarkenOutOfFocus
  55084. */
  55085. setDarkenOutOfFocus(amount: number): void;
  55086. private _pentagonBokehIsEnabled;
  55087. /**
  55088. * Creates a pentagon bokeh effect
  55089. */
  55090. enablePentagonBokeh(): void;
  55091. /**
  55092. * Disables the pentagon bokeh effect
  55093. */
  55094. disablePentagonBokeh(): void;
  55095. /**
  55096. * Enables noise blur
  55097. */
  55098. enableNoiseBlur(): void;
  55099. /**
  55100. * Disables noise blur
  55101. */
  55102. disableNoiseBlur(): void;
  55103. /**
  55104. * Sets the HighlightsGain amount
  55105. * @param amount amount of HighlightsGain
  55106. */
  55107. setHighlightsGain(amount: number): void;
  55108. /**
  55109. * Sets the HighlightsThreshold amount
  55110. * @param amount amount of HighlightsThreshold
  55111. */
  55112. setHighlightsThreshold(amount: number): void;
  55113. /**
  55114. * Disables highlights
  55115. */
  55116. disableHighlights(): void;
  55117. /**
  55118. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  55119. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  55120. */
  55121. dispose(disableDepthRender?: boolean): void;
  55122. private _createChromaticAberrationPostProcess;
  55123. private _createHighlightsPostProcess;
  55124. private _createDepthOfFieldPostProcess;
  55125. private _createGrainTexture;
  55126. }
  55127. }
  55128. declare module "babylonjs/Shaders/ssao2.fragment" {
  55129. /** @hidden */
  55130. export var ssao2PixelShader: {
  55131. name: string;
  55132. shader: string;
  55133. };
  55134. }
  55135. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  55136. /** @hidden */
  55137. export var ssaoCombinePixelShader: {
  55138. name: string;
  55139. shader: string;
  55140. };
  55141. }
  55142. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  55143. import { Camera } from "babylonjs/Cameras/camera";
  55144. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55145. import { Scene } from "babylonjs/scene";
  55146. import "babylonjs/Shaders/ssao2.fragment";
  55147. import "babylonjs/Shaders/ssaoCombine.fragment";
  55148. /**
  55149. * Render pipeline to produce ssao effect
  55150. */
  55151. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  55152. /**
  55153. * @ignore
  55154. * The PassPostProcess id in the pipeline that contains the original scene color
  55155. */
  55156. SSAOOriginalSceneColorEffect: string;
  55157. /**
  55158. * @ignore
  55159. * The SSAO PostProcess id in the pipeline
  55160. */
  55161. SSAORenderEffect: string;
  55162. /**
  55163. * @ignore
  55164. * The horizontal blur PostProcess id in the pipeline
  55165. */
  55166. SSAOBlurHRenderEffect: string;
  55167. /**
  55168. * @ignore
  55169. * The vertical blur PostProcess id in the pipeline
  55170. */
  55171. SSAOBlurVRenderEffect: string;
  55172. /**
  55173. * @ignore
  55174. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  55175. */
  55176. SSAOCombineRenderEffect: string;
  55177. /**
  55178. * The output strength of the SSAO post-process. Default value is 1.0.
  55179. */
  55180. totalStrength: number;
  55181. /**
  55182. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  55183. */
  55184. maxZ: number;
  55185. /**
  55186. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  55187. */
  55188. minZAspect: number;
  55189. private _samples;
  55190. /**
  55191. * Number of samples used for the SSAO calculations. Default value is 8
  55192. */
  55193. samples: number;
  55194. private _textureSamples;
  55195. /**
  55196. * Number of samples to use for antialiasing
  55197. */
  55198. textureSamples: number;
  55199. /**
  55200. * Ratio object used for SSAO ratio and blur ratio
  55201. */
  55202. private _ratio;
  55203. /**
  55204. * Dynamically generated sphere sampler.
  55205. */
  55206. private _sampleSphere;
  55207. /**
  55208. * Blur filter offsets
  55209. */
  55210. private _samplerOffsets;
  55211. private _expensiveBlur;
  55212. /**
  55213. * If bilateral blur should be used
  55214. */
  55215. expensiveBlur: boolean;
  55216. /**
  55217. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  55218. */
  55219. radius: number;
  55220. /**
  55221. * The base color of the SSAO post-process
  55222. * The final result is "base + ssao" between [0, 1]
  55223. */
  55224. base: number;
  55225. /**
  55226. * Support test.
  55227. */
  55228. static readonly IsSupported: boolean;
  55229. private _scene;
  55230. private _depthTexture;
  55231. private _normalTexture;
  55232. private _randomTexture;
  55233. private _originalColorPostProcess;
  55234. private _ssaoPostProcess;
  55235. private _blurHPostProcess;
  55236. private _blurVPostProcess;
  55237. private _ssaoCombinePostProcess;
  55238. private _firstUpdate;
  55239. /**
  55240. * Gets active scene
  55241. */
  55242. readonly scene: Scene;
  55243. /**
  55244. * @constructor
  55245. * @param name The rendering pipeline name
  55246. * @param scene The scene linked to this pipeline
  55247. * @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 }
  55248. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55249. */
  55250. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  55251. /**
  55252. * Get the class name
  55253. * @returns "SSAO2RenderingPipeline"
  55254. */
  55255. getClassName(): string;
  55256. /**
  55257. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  55258. */
  55259. dispose(disableGeometryBufferRenderer?: boolean): void;
  55260. private _createBlurPostProcess;
  55261. /** @hidden */
  55262. _rebuild(): void;
  55263. private _bits;
  55264. private _radicalInverse_VdC;
  55265. private _hammersley;
  55266. private _hemisphereSample_uniform;
  55267. private _generateHemisphere;
  55268. private _createSSAOPostProcess;
  55269. private _createSSAOCombinePostProcess;
  55270. private _createRandomTexture;
  55271. /**
  55272. * Serialize the rendering pipeline (Used when exporting)
  55273. * @returns the serialized object
  55274. */
  55275. serialize(): any;
  55276. /**
  55277. * Parse the serialized pipeline
  55278. * @param source Source pipeline.
  55279. * @param scene The scene to load the pipeline to.
  55280. * @param rootUrl The URL of the serialized pipeline.
  55281. * @returns An instantiated pipeline from the serialized object.
  55282. */
  55283. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  55284. }
  55285. }
  55286. declare module "babylonjs/Shaders/ssao.fragment" {
  55287. /** @hidden */
  55288. export var ssaoPixelShader: {
  55289. name: string;
  55290. shader: string;
  55291. };
  55292. }
  55293. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  55294. import { Camera } from "babylonjs/Cameras/camera";
  55295. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55296. import { Scene } from "babylonjs/scene";
  55297. import "babylonjs/Shaders/ssao.fragment";
  55298. import "babylonjs/Shaders/ssaoCombine.fragment";
  55299. /**
  55300. * Render pipeline to produce ssao effect
  55301. */
  55302. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  55303. /**
  55304. * @ignore
  55305. * The PassPostProcess id in the pipeline that contains the original scene color
  55306. */
  55307. SSAOOriginalSceneColorEffect: string;
  55308. /**
  55309. * @ignore
  55310. * The SSAO PostProcess id in the pipeline
  55311. */
  55312. SSAORenderEffect: string;
  55313. /**
  55314. * @ignore
  55315. * The horizontal blur PostProcess id in the pipeline
  55316. */
  55317. SSAOBlurHRenderEffect: string;
  55318. /**
  55319. * @ignore
  55320. * The vertical blur PostProcess id in the pipeline
  55321. */
  55322. SSAOBlurVRenderEffect: string;
  55323. /**
  55324. * @ignore
  55325. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  55326. */
  55327. SSAOCombineRenderEffect: string;
  55328. /**
  55329. * The output strength of the SSAO post-process. Default value is 1.0.
  55330. */
  55331. totalStrength: number;
  55332. /**
  55333. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  55334. */
  55335. radius: number;
  55336. /**
  55337. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  55338. * Must not be equal to fallOff and superior to fallOff.
  55339. * Default value is 0.0075
  55340. */
  55341. area: number;
  55342. /**
  55343. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  55344. * Must not be equal to area and inferior to area.
  55345. * Default value is 0.000001
  55346. */
  55347. fallOff: number;
  55348. /**
  55349. * The base color of the SSAO post-process
  55350. * The final result is "base + ssao" between [0, 1]
  55351. */
  55352. base: number;
  55353. private _scene;
  55354. private _depthTexture;
  55355. private _randomTexture;
  55356. private _originalColorPostProcess;
  55357. private _ssaoPostProcess;
  55358. private _blurHPostProcess;
  55359. private _blurVPostProcess;
  55360. private _ssaoCombinePostProcess;
  55361. private _firstUpdate;
  55362. /**
  55363. * Gets active scene
  55364. */
  55365. readonly scene: Scene;
  55366. /**
  55367. * @constructor
  55368. * @param name - The rendering pipeline name
  55369. * @param scene - The scene linked to this pipeline
  55370. * @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 }
  55371. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  55372. */
  55373. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  55374. /**
  55375. * Get the class name
  55376. * @returns "SSAORenderingPipeline"
  55377. */
  55378. getClassName(): string;
  55379. /**
  55380. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  55381. */
  55382. dispose(disableDepthRender?: boolean): void;
  55383. private _createBlurPostProcess;
  55384. /** @hidden */
  55385. _rebuild(): void;
  55386. private _createSSAOPostProcess;
  55387. private _createSSAOCombinePostProcess;
  55388. private _createRandomTexture;
  55389. }
  55390. }
  55391. declare module "babylonjs/Shaders/standard.fragment" {
  55392. /** @hidden */
  55393. export var standardPixelShader: {
  55394. name: string;
  55395. shader: string;
  55396. };
  55397. }
  55398. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  55399. import { Nullable } from "babylonjs/types";
  55400. import { IAnimatable } from "babylonjs/Misc/tools";
  55401. import { Camera } from "babylonjs/Cameras/camera";
  55402. import { Texture } from "babylonjs/Materials/Textures/texture";
  55403. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55404. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55405. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  55406. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  55407. import { IDisposable } from "babylonjs/scene";
  55408. import { SpotLight } from "babylonjs/Lights/spotLight";
  55409. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  55410. import { Scene } from "babylonjs/scene";
  55411. import { Animation } from "babylonjs/Animations/animation";
  55412. import "babylonjs/Shaders/standard.fragment";
  55413. /**
  55414. * Standard rendering pipeline
  55415. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  55416. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  55417. */
  55418. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  55419. /**
  55420. * Public members
  55421. */
  55422. /**
  55423. * Post-process which contains the original scene color before the pipeline applies all the effects
  55424. */
  55425. originalPostProcess: Nullable<PostProcess>;
  55426. /**
  55427. * Post-process used to down scale an image x4
  55428. */
  55429. downSampleX4PostProcess: Nullable<PostProcess>;
  55430. /**
  55431. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  55432. */
  55433. brightPassPostProcess: Nullable<PostProcess>;
  55434. /**
  55435. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  55436. */
  55437. blurHPostProcesses: PostProcess[];
  55438. /**
  55439. * Post-process array storing all the vertical blur post-processes used by the pipeline
  55440. */
  55441. blurVPostProcesses: PostProcess[];
  55442. /**
  55443. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  55444. */
  55445. textureAdderPostProcess: Nullable<PostProcess>;
  55446. /**
  55447. * Post-process used to create volumetric lighting effect
  55448. */
  55449. volumetricLightPostProcess: Nullable<PostProcess>;
  55450. /**
  55451. * Post-process used to smooth the previous volumetric light post-process on the X axis
  55452. */
  55453. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  55454. /**
  55455. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  55456. */
  55457. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  55458. /**
  55459. * Post-process used to merge the volumetric light effect and the real scene color
  55460. */
  55461. volumetricLightMergePostProces: Nullable<PostProcess>;
  55462. /**
  55463. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  55464. */
  55465. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  55466. /**
  55467. * Base post-process used to calculate the average luminance of the final image for HDR
  55468. */
  55469. luminancePostProcess: Nullable<PostProcess>;
  55470. /**
  55471. * Post-processes used to create down sample post-processes in order to get
  55472. * the average luminance of the final image for HDR
  55473. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  55474. */
  55475. luminanceDownSamplePostProcesses: PostProcess[];
  55476. /**
  55477. * Post-process used to create a HDR effect (light adaptation)
  55478. */
  55479. hdrPostProcess: Nullable<PostProcess>;
  55480. /**
  55481. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  55482. */
  55483. textureAdderFinalPostProcess: Nullable<PostProcess>;
  55484. /**
  55485. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  55486. */
  55487. lensFlareFinalPostProcess: Nullable<PostProcess>;
  55488. /**
  55489. * Post-process used to merge the final HDR post-process and the real scene color
  55490. */
  55491. hdrFinalPostProcess: Nullable<PostProcess>;
  55492. /**
  55493. * Post-process used to create a lens flare effect
  55494. */
  55495. lensFlarePostProcess: Nullable<PostProcess>;
  55496. /**
  55497. * Post-process that merges the result of the lens flare post-process and the real scene color
  55498. */
  55499. lensFlareComposePostProcess: Nullable<PostProcess>;
  55500. /**
  55501. * Post-process used to create a motion blur effect
  55502. */
  55503. motionBlurPostProcess: Nullable<PostProcess>;
  55504. /**
  55505. * Post-process used to create a depth of field effect
  55506. */
  55507. depthOfFieldPostProcess: Nullable<PostProcess>;
  55508. /**
  55509. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  55510. */
  55511. fxaaPostProcess: Nullable<FxaaPostProcess>;
  55512. /**
  55513. * Represents the brightness threshold in order to configure the illuminated surfaces
  55514. */
  55515. brightThreshold: number;
  55516. /**
  55517. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  55518. */
  55519. blurWidth: number;
  55520. /**
  55521. * Sets if the blur for highlighted surfaces must be only horizontal
  55522. */
  55523. horizontalBlur: boolean;
  55524. /**
  55525. * Sets the overall exposure used by the pipeline
  55526. */
  55527. exposure: number;
  55528. /**
  55529. * Texture used typically to simulate "dirty" on camera lens
  55530. */
  55531. lensTexture: Nullable<Texture>;
  55532. /**
  55533. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  55534. */
  55535. volumetricLightCoefficient: number;
  55536. /**
  55537. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  55538. */
  55539. volumetricLightPower: number;
  55540. /**
  55541. * Used the set the blur intensity to smooth the volumetric lights
  55542. */
  55543. volumetricLightBlurScale: number;
  55544. /**
  55545. * Light (spot or directional) used to generate the volumetric lights rays
  55546. * The source light must have a shadow generate so the pipeline can get its
  55547. * depth map
  55548. */
  55549. sourceLight: Nullable<SpotLight | DirectionalLight>;
  55550. /**
  55551. * For eye adaptation, represents the minimum luminance the eye can see
  55552. */
  55553. hdrMinimumLuminance: number;
  55554. /**
  55555. * For eye adaptation, represents the decrease luminance speed
  55556. */
  55557. hdrDecreaseRate: number;
  55558. /**
  55559. * For eye adaptation, represents the increase luminance speed
  55560. */
  55561. hdrIncreaseRate: number;
  55562. /**
  55563. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  55564. */
  55565. lensColorTexture: Nullable<Texture>;
  55566. /**
  55567. * The overall strengh for the lens flare effect
  55568. */
  55569. lensFlareStrength: number;
  55570. /**
  55571. * Dispersion coefficient for lens flare ghosts
  55572. */
  55573. lensFlareGhostDispersal: number;
  55574. /**
  55575. * Main lens flare halo width
  55576. */
  55577. lensFlareHaloWidth: number;
  55578. /**
  55579. * Based on the lens distortion effect, defines how much the lens flare result
  55580. * is distorted
  55581. */
  55582. lensFlareDistortionStrength: number;
  55583. /**
  55584. * Lens star texture must be used to simulate rays on the flares and is available
  55585. * in the documentation
  55586. */
  55587. lensStarTexture: Nullable<Texture>;
  55588. /**
  55589. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  55590. * flare effect by taking account of the dirt texture
  55591. */
  55592. lensFlareDirtTexture: Nullable<Texture>;
  55593. /**
  55594. * Represents the focal length for the depth of field effect
  55595. */
  55596. depthOfFieldDistance: number;
  55597. /**
  55598. * Represents the blur intensity for the blurred part of the depth of field effect
  55599. */
  55600. depthOfFieldBlurWidth: number;
  55601. /**
  55602. * For motion blur, defines how much the image is blurred by the movement
  55603. */
  55604. motionStrength: number;
  55605. /**
  55606. * List of animations for the pipeline (IAnimatable implementation)
  55607. */
  55608. animations: Animation[];
  55609. /**
  55610. * Private members
  55611. */
  55612. private _scene;
  55613. private _currentDepthOfFieldSource;
  55614. private _basePostProcess;
  55615. private _hdrCurrentLuminance;
  55616. private _floatTextureType;
  55617. private _ratio;
  55618. private _bloomEnabled;
  55619. private _depthOfFieldEnabled;
  55620. private _vlsEnabled;
  55621. private _lensFlareEnabled;
  55622. private _hdrEnabled;
  55623. private _motionBlurEnabled;
  55624. private _fxaaEnabled;
  55625. private _motionBlurSamples;
  55626. private _volumetricLightStepsCount;
  55627. private _samples;
  55628. /**
  55629. * @ignore
  55630. * Specifies if the bloom pipeline is enabled
  55631. */
  55632. BloomEnabled: boolean;
  55633. /**
  55634. * @ignore
  55635. * Specifies if the depth of field pipeline is enabed
  55636. */
  55637. DepthOfFieldEnabled: boolean;
  55638. /**
  55639. * @ignore
  55640. * Specifies if the lens flare pipeline is enabed
  55641. */
  55642. LensFlareEnabled: boolean;
  55643. /**
  55644. * @ignore
  55645. * Specifies if the HDR pipeline is enabled
  55646. */
  55647. HDREnabled: boolean;
  55648. /**
  55649. * @ignore
  55650. * Specifies if the volumetric lights scattering effect is enabled
  55651. */
  55652. VLSEnabled: boolean;
  55653. /**
  55654. * @ignore
  55655. * Specifies if the motion blur effect is enabled
  55656. */
  55657. MotionBlurEnabled: boolean;
  55658. /**
  55659. * Specifies if anti-aliasing is enabled
  55660. */
  55661. fxaaEnabled: boolean;
  55662. /**
  55663. * Specifies the number of steps used to calculate the volumetric lights
  55664. * Typically in interval [50, 200]
  55665. */
  55666. volumetricLightStepsCount: number;
  55667. /**
  55668. * Specifies the number of samples used for the motion blur effect
  55669. * Typically in interval [16, 64]
  55670. */
  55671. motionBlurSamples: number;
  55672. /**
  55673. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  55674. */
  55675. samples: number;
  55676. /**
  55677. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  55678. * @constructor
  55679. * @param name The rendering pipeline name
  55680. * @param scene The scene linked to this pipeline
  55681. * @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)
  55682. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  55683. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55684. */
  55685. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  55686. private _buildPipeline;
  55687. private _createDownSampleX4PostProcess;
  55688. private _createBrightPassPostProcess;
  55689. private _createBlurPostProcesses;
  55690. private _createTextureAdderPostProcess;
  55691. private _createVolumetricLightPostProcess;
  55692. private _createLuminancePostProcesses;
  55693. private _createHdrPostProcess;
  55694. private _createLensFlarePostProcess;
  55695. private _createDepthOfFieldPostProcess;
  55696. private _createMotionBlurPostProcess;
  55697. private _getDepthTexture;
  55698. private _disposePostProcesses;
  55699. /**
  55700. * Dispose of the pipeline and stop all post processes
  55701. */
  55702. dispose(): void;
  55703. /**
  55704. * Serialize the rendering pipeline (Used when exporting)
  55705. * @returns the serialized object
  55706. */
  55707. serialize(): any;
  55708. /**
  55709. * Parse the serialized pipeline
  55710. * @param source Source pipeline.
  55711. * @param scene The scene to load the pipeline to.
  55712. * @param rootUrl The URL of the serialized pipeline.
  55713. * @returns An instantiated pipeline from the serialized object.
  55714. */
  55715. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  55716. /**
  55717. * Luminance steps
  55718. */
  55719. static LuminanceSteps: number;
  55720. }
  55721. }
  55722. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  55723. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  55724. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  55725. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  55726. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  55727. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  55728. }
  55729. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  55730. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  55731. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55732. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55733. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  55734. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  55735. }
  55736. declare module "babylonjs/Shaders/tonemap.fragment" {
  55737. /** @hidden */
  55738. export var tonemapPixelShader: {
  55739. name: string;
  55740. shader: string;
  55741. };
  55742. }
  55743. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  55744. import { Camera } from "babylonjs/Cameras/camera";
  55745. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55746. import "babylonjs/Shaders/tonemap.fragment";
  55747. import { Engine } from "babylonjs/Engines/engine";
  55748. /** Defines operator used for tonemapping */
  55749. export enum TonemappingOperator {
  55750. /** Hable */
  55751. Hable = 0,
  55752. /** Reinhard */
  55753. Reinhard = 1,
  55754. /** HejiDawson */
  55755. HejiDawson = 2,
  55756. /** Photographic */
  55757. Photographic = 3
  55758. }
  55759. /**
  55760. * Defines a post process to apply tone mapping
  55761. */
  55762. export class TonemapPostProcess extends PostProcess {
  55763. private _operator;
  55764. /** Defines the required exposure adjustement */
  55765. exposureAdjustment: number;
  55766. /**
  55767. * Creates a new TonemapPostProcess
  55768. * @param name defines the name of the postprocess
  55769. * @param _operator defines the operator to use
  55770. * @param exposureAdjustment defines the required exposure adjustement
  55771. * @param camera defines the camera to use (can be null)
  55772. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  55773. * @param engine defines the hosting engine (can be ignore if camera is set)
  55774. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  55775. */
  55776. constructor(name: string, _operator: TonemappingOperator,
  55777. /** Defines the required exposure adjustement */
  55778. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  55779. }
  55780. }
  55781. declare module "babylonjs/Shaders/depth.vertex" {
  55782. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55783. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55784. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55785. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55786. /** @hidden */
  55787. export var depthVertexShader: {
  55788. name: string;
  55789. shader: string;
  55790. };
  55791. }
  55792. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  55793. /** @hidden */
  55794. export var volumetricLightScatteringPixelShader: {
  55795. name: string;
  55796. shader: string;
  55797. };
  55798. }
  55799. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  55800. /** @hidden */
  55801. export var volumetricLightScatteringPassPixelShader: {
  55802. name: string;
  55803. shader: string;
  55804. };
  55805. }
  55806. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  55807. import { Vector3 } from "babylonjs/Maths/math";
  55808. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55809. import { Mesh } from "babylonjs/Meshes/mesh";
  55810. import { Camera } from "babylonjs/Cameras/camera";
  55811. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55812. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55813. import { Scene } from "babylonjs/scene";
  55814. import "babylonjs/Meshes/Builders/planeBuilder";
  55815. import "babylonjs/Shaders/depth.vertex";
  55816. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  55817. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  55818. import { Engine } from "babylonjs/Engines/engine";
  55819. /**
  55820. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  55821. */
  55822. export class VolumetricLightScatteringPostProcess extends PostProcess {
  55823. private _volumetricLightScatteringPass;
  55824. private _volumetricLightScatteringRTT;
  55825. private _viewPort;
  55826. private _screenCoordinates;
  55827. private _cachedDefines;
  55828. /**
  55829. * If not undefined, the mesh position is computed from the attached node position
  55830. */
  55831. attachedNode: {
  55832. position: Vector3;
  55833. };
  55834. /**
  55835. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  55836. */
  55837. customMeshPosition: Vector3;
  55838. /**
  55839. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  55840. */
  55841. useCustomMeshPosition: boolean;
  55842. /**
  55843. * If the post-process should inverse the light scattering direction
  55844. */
  55845. invert: boolean;
  55846. /**
  55847. * The internal mesh used by the post-process
  55848. */
  55849. mesh: Mesh;
  55850. /**
  55851. * @hidden
  55852. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  55853. */
  55854. useDiffuseColor: boolean;
  55855. /**
  55856. * Array containing the excluded meshes not rendered in the internal pass
  55857. */
  55858. excludedMeshes: AbstractMesh[];
  55859. /**
  55860. * Controls the overall intensity of the post-process
  55861. */
  55862. exposure: number;
  55863. /**
  55864. * Dissipates each sample's contribution in range [0, 1]
  55865. */
  55866. decay: number;
  55867. /**
  55868. * Controls the overall intensity of each sample
  55869. */
  55870. weight: number;
  55871. /**
  55872. * Controls the density of each sample
  55873. */
  55874. density: number;
  55875. /**
  55876. * @constructor
  55877. * @param name The post-process name
  55878. * @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)
  55879. * @param camera The camera that the post-process will be attached to
  55880. * @param mesh The mesh used to create the light scattering
  55881. * @param samples The post-process quality, default 100
  55882. * @param samplingModeThe post-process filtering mode
  55883. * @param engine The babylon engine
  55884. * @param reusable If the post-process is reusable
  55885. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  55886. */
  55887. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  55888. /**
  55889. * Returns the string "VolumetricLightScatteringPostProcess"
  55890. * @returns "VolumetricLightScatteringPostProcess"
  55891. */
  55892. getClassName(): string;
  55893. private _isReady;
  55894. /**
  55895. * Sets the new light position for light scattering effect
  55896. * @param position The new custom light position
  55897. */
  55898. setCustomMeshPosition(position: Vector3): void;
  55899. /**
  55900. * Returns the light position for light scattering effect
  55901. * @return Vector3 The custom light position
  55902. */
  55903. getCustomMeshPosition(): Vector3;
  55904. /**
  55905. * Disposes the internal assets and detaches the post-process from the camera
  55906. */
  55907. dispose(camera: Camera): void;
  55908. /**
  55909. * Returns the render target texture used by the post-process
  55910. * @return the render target texture used by the post-process
  55911. */
  55912. getPass(): RenderTargetTexture;
  55913. private _meshExcluded;
  55914. private _createPass;
  55915. private _updateMeshScreenCoordinates;
  55916. /**
  55917. * Creates a default mesh for the Volumeric Light Scattering post-process
  55918. * @param name The mesh name
  55919. * @param scene The scene where to create the mesh
  55920. * @return the default mesh
  55921. */
  55922. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  55923. }
  55924. }
  55925. declare module "babylonjs/PostProcesses/index" {
  55926. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  55927. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  55928. export * from "babylonjs/PostProcesses/bloomEffect";
  55929. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  55930. export * from "babylonjs/PostProcesses/blurPostProcess";
  55931. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  55932. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  55933. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  55934. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  55935. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  55936. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  55937. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  55938. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  55939. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  55940. export * from "babylonjs/PostProcesses/filterPostProcess";
  55941. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  55942. export * from "babylonjs/PostProcesses/grainPostProcess";
  55943. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  55944. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  55945. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  55946. export * from "babylonjs/PostProcesses/passPostProcess";
  55947. export * from "babylonjs/PostProcesses/postProcess";
  55948. export * from "babylonjs/PostProcesses/postProcessManager";
  55949. export * from "babylonjs/PostProcesses/refractionPostProcess";
  55950. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  55951. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  55952. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  55953. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  55954. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  55955. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  55956. }
  55957. declare module "babylonjs/Probes/index" {
  55958. export * from "babylonjs/Probes/reflectionProbe";
  55959. }
  55960. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  55961. import { Scene } from "babylonjs/scene";
  55962. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55963. import { Color3 } from "babylonjs/Maths/math";
  55964. import { SmartArray } from "babylonjs/Misc/smartArray";
  55965. import { ISceneComponent } from "babylonjs/sceneComponent";
  55966. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  55967. import "babylonjs/Meshes/Builders/boxBuilder";
  55968. import "babylonjs/Shaders/color.fragment";
  55969. import "babylonjs/Shaders/color.vertex";
  55970. module "babylonjs/scene" {
  55971. interface Scene {
  55972. /** @hidden (Backing field) */
  55973. _boundingBoxRenderer: BoundingBoxRenderer;
  55974. /** @hidden (Backing field) */
  55975. _forceShowBoundingBoxes: boolean;
  55976. /**
  55977. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  55978. */
  55979. forceShowBoundingBoxes: boolean;
  55980. /**
  55981. * Gets the bounding box renderer associated with the scene
  55982. * @returns a BoundingBoxRenderer
  55983. */
  55984. getBoundingBoxRenderer(): BoundingBoxRenderer;
  55985. }
  55986. }
  55987. module "babylonjs/Meshes/abstractMesh" {
  55988. interface AbstractMesh {
  55989. /** @hidden (Backing field) */
  55990. _showBoundingBox: boolean;
  55991. /**
  55992. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  55993. */
  55994. showBoundingBox: boolean;
  55995. }
  55996. }
  55997. /**
  55998. * Component responsible of rendering the bounding box of the meshes in a scene.
  55999. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  56000. */
  56001. export class BoundingBoxRenderer implements ISceneComponent {
  56002. /**
  56003. * The component name helpfull to identify the component in the list of scene components.
  56004. */
  56005. readonly name: string;
  56006. /**
  56007. * The scene the component belongs to.
  56008. */
  56009. scene: Scene;
  56010. /**
  56011. * Color of the bounding box lines placed in front of an object
  56012. */
  56013. frontColor: Color3;
  56014. /**
  56015. * Color of the bounding box lines placed behind an object
  56016. */
  56017. backColor: Color3;
  56018. /**
  56019. * Defines if the renderer should show the back lines or not
  56020. */
  56021. showBackLines: boolean;
  56022. /**
  56023. * @hidden
  56024. */
  56025. renderList: SmartArray<BoundingBox>;
  56026. private _colorShader;
  56027. private _vertexBuffers;
  56028. private _indexBuffer;
  56029. /**
  56030. * Instantiates a new bounding box renderer in a scene.
  56031. * @param scene the scene the renderer renders in
  56032. */
  56033. constructor(scene: Scene);
  56034. /**
  56035. * Registers the component in a given scene
  56036. */
  56037. register(): void;
  56038. private _evaluateSubMesh;
  56039. private _activeMesh;
  56040. private _prepareRessources;
  56041. private _createIndexBuffer;
  56042. /**
  56043. * Rebuilds the elements related to this component in case of
  56044. * context lost for instance.
  56045. */
  56046. rebuild(): void;
  56047. /**
  56048. * @hidden
  56049. */
  56050. reset(): void;
  56051. /**
  56052. * Render the bounding boxes of a specific rendering group
  56053. * @param renderingGroupId defines the rendering group to render
  56054. */
  56055. render(renderingGroupId: number): void;
  56056. /**
  56057. * In case of occlusion queries, we can render the occlusion bounding box through this method
  56058. * @param mesh Define the mesh to render the occlusion bounding box for
  56059. */
  56060. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  56061. /**
  56062. * Dispose and release the resources attached to this renderer.
  56063. */
  56064. dispose(): void;
  56065. }
  56066. }
  56067. declare module "babylonjs/Shaders/depth.fragment" {
  56068. /** @hidden */
  56069. export var depthPixelShader: {
  56070. name: string;
  56071. shader: string;
  56072. };
  56073. }
  56074. declare module "babylonjs/Rendering/depthRenderer" {
  56075. import { Nullable } from "babylonjs/types";
  56076. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56077. import { Scene } from "babylonjs/scene";
  56078. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56079. import { Camera } from "babylonjs/Cameras/camera";
  56080. import "babylonjs/Shaders/depth.fragment";
  56081. import "babylonjs/Shaders/depth.vertex";
  56082. /**
  56083. * This represents a depth renderer in Babylon.
  56084. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56085. */
  56086. export class DepthRenderer {
  56087. private _scene;
  56088. private _depthMap;
  56089. private _effect;
  56090. private _cachedDefines;
  56091. private _camera;
  56092. /**
  56093. * Specifiess that the depth renderer will only be used within
  56094. * the camera it is created for.
  56095. * This can help forcing its rendering during the camera processing.
  56096. */
  56097. useOnlyInActiveCamera: boolean;
  56098. /** @hidden */
  56099. static _SceneComponentInitialization: (scene: Scene) => void;
  56100. /**
  56101. * Instantiates a depth renderer
  56102. * @param scene The scene the renderer belongs to
  56103. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56104. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56105. */
  56106. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  56107. /**
  56108. * Creates the depth rendering effect and checks if the effect is ready.
  56109. * @param subMesh The submesh to be used to render the depth map of
  56110. * @param useInstances If multiple world instances should be used
  56111. * @returns if the depth renderer is ready to render the depth map
  56112. */
  56113. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56114. /**
  56115. * Gets the texture which the depth map will be written to.
  56116. * @returns The depth map texture
  56117. */
  56118. getDepthMap(): RenderTargetTexture;
  56119. /**
  56120. * Disposes of the depth renderer.
  56121. */
  56122. dispose(): void;
  56123. }
  56124. }
  56125. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  56126. import { Nullable } from "babylonjs/types";
  56127. import { Scene } from "babylonjs/scene";
  56128. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56129. import { Camera } from "babylonjs/Cameras/camera";
  56130. import { ISceneComponent } from "babylonjs/sceneComponent";
  56131. module "babylonjs/scene" {
  56132. interface Scene {
  56133. /** @hidden (Backing field) */
  56134. _depthRenderer: {
  56135. [id: string]: DepthRenderer;
  56136. };
  56137. /**
  56138. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  56139. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  56140. * @returns the created depth renderer
  56141. */
  56142. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  56143. /**
  56144. * Disables a depth renderer for a given camera
  56145. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  56146. */
  56147. disableDepthRenderer(camera?: Nullable<Camera>): void;
  56148. }
  56149. }
  56150. /**
  56151. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  56152. * in several rendering techniques.
  56153. */
  56154. export class DepthRendererSceneComponent implements ISceneComponent {
  56155. /**
  56156. * The component name helpfull to identify the component in the list of scene components.
  56157. */
  56158. readonly name: string;
  56159. /**
  56160. * The scene the component belongs to.
  56161. */
  56162. scene: Scene;
  56163. /**
  56164. * Creates a new instance of the component for the given scene
  56165. * @param scene Defines the scene to register the component in
  56166. */
  56167. constructor(scene: Scene);
  56168. /**
  56169. * Registers the component in a given scene
  56170. */
  56171. register(): void;
  56172. /**
  56173. * Rebuilds the elements related to this component in case of
  56174. * context lost for instance.
  56175. */
  56176. rebuild(): void;
  56177. /**
  56178. * Disposes the component and the associated ressources
  56179. */
  56180. dispose(): void;
  56181. private _gatherRenderTargets;
  56182. private _gatherActiveCameraRenderTargets;
  56183. }
  56184. }
  56185. declare module "babylonjs/Shaders/outline.fragment" {
  56186. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  56187. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  56188. /** @hidden */
  56189. export var outlinePixelShader: {
  56190. name: string;
  56191. shader: string;
  56192. };
  56193. }
  56194. declare module "babylonjs/Shaders/outline.vertex" {
  56195. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56196. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56197. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  56198. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56199. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56200. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  56201. /** @hidden */
  56202. export var outlineVertexShader: {
  56203. name: string;
  56204. shader: string;
  56205. };
  56206. }
  56207. declare module "babylonjs/Rendering/outlineRenderer" {
  56208. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56209. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  56210. import { Scene } from "babylonjs/scene";
  56211. import { ISceneComponent } from "babylonjs/sceneComponent";
  56212. import "babylonjs/Shaders/outline.fragment";
  56213. import "babylonjs/Shaders/outline.vertex";
  56214. module "babylonjs/scene" {
  56215. interface Scene {
  56216. /** @hidden */
  56217. _outlineRenderer: OutlineRenderer;
  56218. /**
  56219. * Gets the outline renderer associated with the scene
  56220. * @returns a OutlineRenderer
  56221. */
  56222. getOutlineRenderer(): OutlineRenderer;
  56223. }
  56224. }
  56225. module "babylonjs/Meshes/abstractMesh" {
  56226. interface AbstractMesh {
  56227. /** @hidden (Backing field) */
  56228. _renderOutline: boolean;
  56229. /**
  56230. * Gets or sets a boolean indicating if the outline must be rendered as well
  56231. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  56232. */
  56233. renderOutline: boolean;
  56234. /** @hidden (Backing field) */
  56235. _renderOverlay: boolean;
  56236. /**
  56237. * Gets or sets a boolean indicating if the overlay must be rendered as well
  56238. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  56239. */
  56240. renderOverlay: boolean;
  56241. }
  56242. }
  56243. /**
  56244. * This class is responsible to draw bothe outline/overlay of meshes.
  56245. * It should not be used directly but through the available method on mesh.
  56246. */
  56247. export class OutlineRenderer implements ISceneComponent {
  56248. /**
  56249. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  56250. */
  56251. private static _StencilReference;
  56252. /**
  56253. * The name of the component. Each component must have a unique name.
  56254. */
  56255. name: string;
  56256. /**
  56257. * The scene the component belongs to.
  56258. */
  56259. scene: Scene;
  56260. /**
  56261. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  56262. */
  56263. zOffset: number;
  56264. private _engine;
  56265. private _effect;
  56266. private _cachedDefines;
  56267. private _savedDepthWrite;
  56268. /**
  56269. * Instantiates a new outline renderer. (There could be only one per scene).
  56270. * @param scene Defines the scene it belongs to
  56271. */
  56272. constructor(scene: Scene);
  56273. /**
  56274. * Register the component to one instance of a scene.
  56275. */
  56276. register(): void;
  56277. /**
  56278. * Rebuilds the elements related to this component in case of
  56279. * context lost for instance.
  56280. */
  56281. rebuild(): void;
  56282. /**
  56283. * Disposes the component and the associated ressources.
  56284. */
  56285. dispose(): void;
  56286. /**
  56287. * Renders the outline in the canvas.
  56288. * @param subMesh Defines the sumesh to render
  56289. * @param batch Defines the batch of meshes in case of instances
  56290. * @param useOverlay Defines if the rendering is for the overlay or the outline
  56291. */
  56292. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  56293. /**
  56294. * Returns whether or not the outline renderer is ready for a given submesh.
  56295. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  56296. * @param subMesh Defines the submesh to check readyness for
  56297. * @param useInstances Defines wheter wee are trying to render instances or not
  56298. * @returns true if ready otherwise false
  56299. */
  56300. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56301. private _beforeRenderingMesh;
  56302. private _afterRenderingMesh;
  56303. }
  56304. }
  56305. declare module "babylonjs/Rendering/index" {
  56306. export * from "babylonjs/Rendering/boundingBoxRenderer";
  56307. export * from "babylonjs/Rendering/depthRenderer";
  56308. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  56309. export * from "babylonjs/Rendering/edgesRenderer";
  56310. export * from "babylonjs/Rendering/geometryBufferRenderer";
  56311. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  56312. export * from "babylonjs/Rendering/outlineRenderer";
  56313. export * from "babylonjs/Rendering/renderingGroup";
  56314. export * from "babylonjs/Rendering/renderingManager";
  56315. export * from "babylonjs/Rendering/utilityLayerRenderer";
  56316. }
  56317. declare module "babylonjs/Sprites/index" {
  56318. export * from "babylonjs/Sprites/sprite";
  56319. export * from "babylonjs/Sprites/spriteManager";
  56320. export * from "babylonjs/Sprites/spriteSceneComponent";
  56321. }
  56322. declare module "babylonjs/Misc/assetsManager" {
  56323. import { Scene } from "babylonjs/scene";
  56324. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56325. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56326. import { Skeleton } from "babylonjs/Bones/skeleton";
  56327. import { Observable } from "babylonjs/Misc/observable";
  56328. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56329. import { Texture } from "babylonjs/Materials/Textures/texture";
  56330. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  56331. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  56332. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  56333. /**
  56334. * Defines the list of states available for a task inside a AssetsManager
  56335. */
  56336. export enum AssetTaskState {
  56337. /**
  56338. * Initialization
  56339. */
  56340. INIT = 0,
  56341. /**
  56342. * Running
  56343. */
  56344. RUNNING = 1,
  56345. /**
  56346. * Done
  56347. */
  56348. DONE = 2,
  56349. /**
  56350. * Error
  56351. */
  56352. ERROR = 3
  56353. }
  56354. /**
  56355. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  56356. */
  56357. export abstract class AbstractAssetTask {
  56358. /**
  56359. * Task name
  56360. */ name: string;
  56361. /**
  56362. * Callback called when the task is successful
  56363. */
  56364. onSuccess: (task: any) => void;
  56365. /**
  56366. * Callback called when the task is not successful
  56367. */
  56368. onError: (task: any, message?: string, exception?: any) => void;
  56369. /**
  56370. * Creates a new AssetsManager
  56371. * @param name defines the name of the task
  56372. */
  56373. constructor(
  56374. /**
  56375. * Task name
  56376. */ name: string);
  56377. private _isCompleted;
  56378. private _taskState;
  56379. private _errorObject;
  56380. /**
  56381. * Get if the task is completed
  56382. */
  56383. readonly isCompleted: boolean;
  56384. /**
  56385. * Gets the current state of the task
  56386. */
  56387. readonly taskState: AssetTaskState;
  56388. /**
  56389. * Gets the current error object (if task is in error)
  56390. */
  56391. readonly errorObject: {
  56392. message?: string;
  56393. exception?: any;
  56394. };
  56395. /**
  56396. * Internal only
  56397. * @hidden
  56398. */
  56399. _setErrorObject(message?: string, exception?: any): void;
  56400. /**
  56401. * Execute the current task
  56402. * @param scene defines the scene where you want your assets to be loaded
  56403. * @param onSuccess is a callback called when the task is successfully executed
  56404. * @param onError is a callback called if an error occurs
  56405. */
  56406. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56407. /**
  56408. * Execute the current task
  56409. * @param scene defines the scene where you want your assets to be loaded
  56410. * @param onSuccess is a callback called when the task is successfully executed
  56411. * @param onError is a callback called if an error occurs
  56412. */
  56413. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56414. /**
  56415. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  56416. * This can be used with failed tasks that have the reason for failure fixed.
  56417. */
  56418. reset(): void;
  56419. private onErrorCallback;
  56420. private onDoneCallback;
  56421. }
  56422. /**
  56423. * Define the interface used by progress events raised during assets loading
  56424. */
  56425. export interface IAssetsProgressEvent {
  56426. /**
  56427. * Defines the number of remaining tasks to process
  56428. */
  56429. remainingCount: number;
  56430. /**
  56431. * Defines the total number of tasks
  56432. */
  56433. totalCount: number;
  56434. /**
  56435. * Defines the task that was just processed
  56436. */
  56437. task: AbstractAssetTask;
  56438. }
  56439. /**
  56440. * Class used to share progress information about assets loading
  56441. */
  56442. export class AssetsProgressEvent implements IAssetsProgressEvent {
  56443. /**
  56444. * Defines the number of remaining tasks to process
  56445. */
  56446. remainingCount: number;
  56447. /**
  56448. * Defines the total number of tasks
  56449. */
  56450. totalCount: number;
  56451. /**
  56452. * Defines the task that was just processed
  56453. */
  56454. task: AbstractAssetTask;
  56455. /**
  56456. * Creates a AssetsProgressEvent
  56457. * @param remainingCount defines the number of remaining tasks to process
  56458. * @param totalCount defines the total number of tasks
  56459. * @param task defines the task that was just processed
  56460. */
  56461. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  56462. }
  56463. /**
  56464. * Define a task used by AssetsManager to load meshes
  56465. */
  56466. export class MeshAssetTask extends AbstractAssetTask {
  56467. /**
  56468. * Defines the name of the task
  56469. */
  56470. name: string;
  56471. /**
  56472. * Defines the list of mesh's names you want to load
  56473. */
  56474. meshesNames: any;
  56475. /**
  56476. * Defines the root url to use as a base to load your meshes and associated resources
  56477. */
  56478. rootUrl: string;
  56479. /**
  56480. * Defines the filename of the scene to load from
  56481. */
  56482. sceneFilename: string;
  56483. /**
  56484. * Gets the list of loaded meshes
  56485. */
  56486. loadedMeshes: Array<AbstractMesh>;
  56487. /**
  56488. * Gets the list of loaded particle systems
  56489. */
  56490. loadedParticleSystems: Array<IParticleSystem>;
  56491. /**
  56492. * Gets the list of loaded skeletons
  56493. */
  56494. loadedSkeletons: Array<Skeleton>;
  56495. /**
  56496. * Gets the list of loaded animation groups
  56497. */
  56498. loadedAnimationGroups: Array<AnimationGroup>;
  56499. /**
  56500. * Callback called when the task is successful
  56501. */
  56502. onSuccess: (task: MeshAssetTask) => void;
  56503. /**
  56504. * Callback called when the task is successful
  56505. */
  56506. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  56507. /**
  56508. * Creates a new MeshAssetTask
  56509. * @param name defines the name of the task
  56510. * @param meshesNames defines the list of mesh's names you want to load
  56511. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  56512. * @param sceneFilename defines the filename of the scene to load from
  56513. */
  56514. constructor(
  56515. /**
  56516. * Defines the name of the task
  56517. */
  56518. name: string,
  56519. /**
  56520. * Defines the list of mesh's names you want to load
  56521. */
  56522. meshesNames: any,
  56523. /**
  56524. * Defines the root url to use as a base to load your meshes and associated resources
  56525. */
  56526. rootUrl: string,
  56527. /**
  56528. * Defines the filename of the scene to load from
  56529. */
  56530. sceneFilename: string);
  56531. /**
  56532. * Execute the current task
  56533. * @param scene defines the scene where you want your assets to be loaded
  56534. * @param onSuccess is a callback called when the task is successfully executed
  56535. * @param onError is a callback called if an error occurs
  56536. */
  56537. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56538. }
  56539. /**
  56540. * Define a task used by AssetsManager to load text content
  56541. */
  56542. export class TextFileAssetTask extends AbstractAssetTask {
  56543. /**
  56544. * Defines the name of the task
  56545. */
  56546. name: string;
  56547. /**
  56548. * Defines the location of the file to load
  56549. */
  56550. url: string;
  56551. /**
  56552. * Gets the loaded text string
  56553. */
  56554. text: string;
  56555. /**
  56556. * Callback called when the task is successful
  56557. */
  56558. onSuccess: (task: TextFileAssetTask) => void;
  56559. /**
  56560. * Callback called when the task is successful
  56561. */
  56562. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  56563. /**
  56564. * Creates a new TextFileAssetTask object
  56565. * @param name defines the name of the task
  56566. * @param url defines the location of the file to load
  56567. */
  56568. constructor(
  56569. /**
  56570. * Defines the name of the task
  56571. */
  56572. name: string,
  56573. /**
  56574. * Defines the location of the file to load
  56575. */
  56576. url: string);
  56577. /**
  56578. * Execute the current task
  56579. * @param scene defines the scene where you want your assets to be loaded
  56580. * @param onSuccess is a callback called when the task is successfully executed
  56581. * @param onError is a callback called if an error occurs
  56582. */
  56583. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56584. }
  56585. /**
  56586. * Define a task used by AssetsManager to load binary data
  56587. */
  56588. export class BinaryFileAssetTask extends AbstractAssetTask {
  56589. /**
  56590. * Defines the name of the task
  56591. */
  56592. name: string;
  56593. /**
  56594. * Defines the location of the file to load
  56595. */
  56596. url: string;
  56597. /**
  56598. * Gets the lodaded data (as an array buffer)
  56599. */
  56600. data: ArrayBuffer;
  56601. /**
  56602. * Callback called when the task is successful
  56603. */
  56604. onSuccess: (task: BinaryFileAssetTask) => void;
  56605. /**
  56606. * Callback called when the task is successful
  56607. */
  56608. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  56609. /**
  56610. * Creates a new BinaryFileAssetTask object
  56611. * @param name defines the name of the new task
  56612. * @param url defines the location of the file to load
  56613. */
  56614. constructor(
  56615. /**
  56616. * Defines the name of the task
  56617. */
  56618. name: string,
  56619. /**
  56620. * Defines the location of the file to load
  56621. */
  56622. url: string);
  56623. /**
  56624. * Execute the current task
  56625. * @param scene defines the scene where you want your assets to be loaded
  56626. * @param onSuccess is a callback called when the task is successfully executed
  56627. * @param onError is a callback called if an error occurs
  56628. */
  56629. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56630. }
  56631. /**
  56632. * Define a task used by AssetsManager to load images
  56633. */
  56634. export class ImageAssetTask extends AbstractAssetTask {
  56635. /**
  56636. * Defines the name of the task
  56637. */
  56638. name: string;
  56639. /**
  56640. * Defines the location of the image to load
  56641. */
  56642. url: string;
  56643. /**
  56644. * Gets the loaded images
  56645. */
  56646. image: HTMLImageElement;
  56647. /**
  56648. * Callback called when the task is successful
  56649. */
  56650. onSuccess: (task: ImageAssetTask) => void;
  56651. /**
  56652. * Callback called when the task is successful
  56653. */
  56654. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  56655. /**
  56656. * Creates a new ImageAssetTask
  56657. * @param name defines the name of the task
  56658. * @param url defines the location of the image to load
  56659. */
  56660. constructor(
  56661. /**
  56662. * Defines the name of the task
  56663. */
  56664. name: string,
  56665. /**
  56666. * Defines the location of the image to load
  56667. */
  56668. url: string);
  56669. /**
  56670. * Execute the current task
  56671. * @param scene defines the scene where you want your assets to be loaded
  56672. * @param onSuccess is a callback called when the task is successfully executed
  56673. * @param onError is a callback called if an error occurs
  56674. */
  56675. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56676. }
  56677. /**
  56678. * Defines the interface used by texture loading tasks
  56679. */
  56680. export interface ITextureAssetTask<TEX extends BaseTexture> {
  56681. /**
  56682. * Gets the loaded texture
  56683. */
  56684. texture: TEX;
  56685. }
  56686. /**
  56687. * Define a task used by AssetsManager to load 2D textures
  56688. */
  56689. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  56690. /**
  56691. * Defines the name of the task
  56692. */
  56693. name: string;
  56694. /**
  56695. * Defines the location of the file to load
  56696. */
  56697. url: string;
  56698. /**
  56699. * Defines if mipmap should not be generated (default is false)
  56700. */
  56701. noMipmap?: boolean | undefined;
  56702. /**
  56703. * Defines if texture must be inverted on Y axis (default is false)
  56704. */
  56705. invertY?: boolean | undefined;
  56706. /**
  56707. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  56708. */
  56709. samplingMode: number;
  56710. /**
  56711. * Gets the loaded texture
  56712. */
  56713. texture: Texture;
  56714. /**
  56715. * Callback called when the task is successful
  56716. */
  56717. onSuccess: (task: TextureAssetTask) => void;
  56718. /**
  56719. * Callback called when the task is successful
  56720. */
  56721. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  56722. /**
  56723. * Creates a new TextureAssetTask object
  56724. * @param name defines the name of the task
  56725. * @param url defines the location of the file to load
  56726. * @param noMipmap defines if mipmap should not be generated (default is false)
  56727. * @param invertY defines if texture must be inverted on Y axis (default is false)
  56728. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  56729. */
  56730. constructor(
  56731. /**
  56732. * Defines the name of the task
  56733. */
  56734. name: string,
  56735. /**
  56736. * Defines the location of the file to load
  56737. */
  56738. url: string,
  56739. /**
  56740. * Defines if mipmap should not be generated (default is false)
  56741. */
  56742. noMipmap?: boolean | undefined,
  56743. /**
  56744. * Defines if texture must be inverted on Y axis (default is false)
  56745. */
  56746. invertY?: boolean | undefined,
  56747. /**
  56748. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  56749. */
  56750. samplingMode?: number);
  56751. /**
  56752. * Execute the current task
  56753. * @param scene defines the scene where you want your assets to be loaded
  56754. * @param onSuccess is a callback called when the task is successfully executed
  56755. * @param onError is a callback called if an error occurs
  56756. */
  56757. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56758. }
  56759. /**
  56760. * Define a task used by AssetsManager to load cube textures
  56761. */
  56762. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  56763. /**
  56764. * Defines the name of the task
  56765. */
  56766. name: string;
  56767. /**
  56768. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56769. */
  56770. url: string;
  56771. /**
  56772. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56773. */
  56774. extensions?: string[] | undefined;
  56775. /**
  56776. * Defines if mipmaps should not be generated (default is false)
  56777. */
  56778. noMipmap?: boolean | undefined;
  56779. /**
  56780. * Defines the explicit list of files (undefined by default)
  56781. */
  56782. files?: string[] | undefined;
  56783. /**
  56784. * Gets the loaded texture
  56785. */
  56786. texture: CubeTexture;
  56787. /**
  56788. * Callback called when the task is successful
  56789. */
  56790. onSuccess: (task: CubeTextureAssetTask) => void;
  56791. /**
  56792. * Callback called when the task is successful
  56793. */
  56794. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  56795. /**
  56796. * Creates a new CubeTextureAssetTask
  56797. * @param name defines the name of the task
  56798. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56799. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56800. * @param noMipmap defines if mipmaps should not be generated (default is false)
  56801. * @param files defines the explicit list of files (undefined by default)
  56802. */
  56803. constructor(
  56804. /**
  56805. * Defines the name of the task
  56806. */
  56807. name: string,
  56808. /**
  56809. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56810. */
  56811. url: string,
  56812. /**
  56813. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56814. */
  56815. extensions?: string[] | undefined,
  56816. /**
  56817. * Defines if mipmaps should not be generated (default is false)
  56818. */
  56819. noMipmap?: boolean | undefined,
  56820. /**
  56821. * Defines the explicit list of files (undefined by default)
  56822. */
  56823. files?: string[] | undefined);
  56824. /**
  56825. * Execute the current task
  56826. * @param scene defines the scene where you want your assets to be loaded
  56827. * @param onSuccess is a callback called when the task is successfully executed
  56828. * @param onError is a callback called if an error occurs
  56829. */
  56830. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56831. }
  56832. /**
  56833. * Define a task used by AssetsManager to load HDR cube textures
  56834. */
  56835. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  56836. /**
  56837. * Defines the name of the task
  56838. */
  56839. name: string;
  56840. /**
  56841. * Defines the location of the file to load
  56842. */
  56843. url: string;
  56844. /**
  56845. * Defines the desired size (the more it increases the longer the generation will be)
  56846. */
  56847. size: number;
  56848. /**
  56849. * Defines if mipmaps should not be generated (default is false)
  56850. */
  56851. noMipmap: boolean;
  56852. /**
  56853. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56854. */
  56855. generateHarmonics: boolean;
  56856. /**
  56857. * 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)
  56858. */
  56859. gammaSpace: boolean;
  56860. /**
  56861. * Internal Use Only
  56862. */
  56863. reserved: boolean;
  56864. /**
  56865. * Gets the loaded texture
  56866. */
  56867. texture: HDRCubeTexture;
  56868. /**
  56869. * Callback called when the task is successful
  56870. */
  56871. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  56872. /**
  56873. * Callback called when the task is successful
  56874. */
  56875. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  56876. /**
  56877. * Creates a new HDRCubeTextureAssetTask object
  56878. * @param name defines the name of the task
  56879. * @param url defines the location of the file to load
  56880. * @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.
  56881. * @param noMipmap defines if mipmaps should not be generated (default is false)
  56882. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56883. * @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)
  56884. * @param reserved Internal use only
  56885. */
  56886. constructor(
  56887. /**
  56888. * Defines the name of the task
  56889. */
  56890. name: string,
  56891. /**
  56892. * Defines the location of the file to load
  56893. */
  56894. url: string,
  56895. /**
  56896. * Defines the desired size (the more it increases the longer the generation will be)
  56897. */
  56898. size: number,
  56899. /**
  56900. * Defines if mipmaps should not be generated (default is false)
  56901. */
  56902. noMipmap?: boolean,
  56903. /**
  56904. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56905. */
  56906. generateHarmonics?: boolean,
  56907. /**
  56908. * 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)
  56909. */
  56910. gammaSpace?: boolean,
  56911. /**
  56912. * Internal Use Only
  56913. */
  56914. reserved?: boolean);
  56915. /**
  56916. * Execute the current task
  56917. * @param scene defines the scene where you want your assets to be loaded
  56918. * @param onSuccess is a callback called when the task is successfully executed
  56919. * @param onError is a callback called if an error occurs
  56920. */
  56921. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56922. }
  56923. /**
  56924. * This class can be used to easily import assets into a scene
  56925. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  56926. */
  56927. export class AssetsManager {
  56928. private _scene;
  56929. private _isLoading;
  56930. protected _tasks: AbstractAssetTask[];
  56931. protected _waitingTasksCount: number;
  56932. protected _totalTasksCount: number;
  56933. /**
  56934. * Callback called when all tasks are processed
  56935. */
  56936. onFinish: (tasks: AbstractAssetTask[]) => void;
  56937. /**
  56938. * Callback called when a task is successful
  56939. */
  56940. onTaskSuccess: (task: AbstractAssetTask) => void;
  56941. /**
  56942. * Callback called when a task had an error
  56943. */
  56944. onTaskError: (task: AbstractAssetTask) => void;
  56945. /**
  56946. * Callback called when a task is done (whatever the result is)
  56947. */
  56948. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  56949. /**
  56950. * Observable called when all tasks are processed
  56951. */
  56952. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  56953. /**
  56954. * Observable called when a task had an error
  56955. */
  56956. onTaskErrorObservable: Observable<AbstractAssetTask>;
  56957. /**
  56958. * Observable called when all tasks were executed
  56959. */
  56960. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  56961. /**
  56962. * Observable called when a task is done (whatever the result is)
  56963. */
  56964. onProgressObservable: Observable<IAssetsProgressEvent>;
  56965. /**
  56966. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  56967. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  56968. */
  56969. useDefaultLoadingScreen: boolean;
  56970. /**
  56971. * Creates a new AssetsManager
  56972. * @param scene defines the scene to work on
  56973. */
  56974. constructor(scene: Scene);
  56975. /**
  56976. * Add a MeshAssetTask to the list of active tasks
  56977. * @param taskName defines the name of the new task
  56978. * @param meshesNames defines the name of meshes to load
  56979. * @param rootUrl defines the root url to use to locate files
  56980. * @param sceneFilename defines the filename of the scene file
  56981. * @returns a new MeshAssetTask object
  56982. */
  56983. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  56984. /**
  56985. * Add a TextFileAssetTask to the list of active tasks
  56986. * @param taskName defines the name of the new task
  56987. * @param url defines the url of the file to load
  56988. * @returns a new TextFileAssetTask object
  56989. */
  56990. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  56991. /**
  56992. * Add a BinaryFileAssetTask to the list of active tasks
  56993. * @param taskName defines the name of the new task
  56994. * @param url defines the url of the file to load
  56995. * @returns a new BinaryFileAssetTask object
  56996. */
  56997. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  56998. /**
  56999. * Add a ImageAssetTask to the list of active tasks
  57000. * @param taskName defines the name of the new task
  57001. * @param url defines the url of the file to load
  57002. * @returns a new ImageAssetTask object
  57003. */
  57004. addImageTask(taskName: string, url: string): ImageAssetTask;
  57005. /**
  57006. * Add a TextureAssetTask to the list of active tasks
  57007. * @param taskName defines the name of the new task
  57008. * @param url defines the url of the file to load
  57009. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57010. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  57011. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57012. * @returns a new TextureAssetTask object
  57013. */
  57014. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  57015. /**
  57016. * Add a CubeTextureAssetTask to the list of active tasks
  57017. * @param taskName defines the name of the new task
  57018. * @param url defines the url of the file to load
  57019. * @param extensions defines the extension to use to load the cube map (can be null)
  57020. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57021. * @param files defines the list of files to load (can be null)
  57022. * @returns a new CubeTextureAssetTask object
  57023. */
  57024. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  57025. /**
  57026. *
  57027. * Add a HDRCubeTextureAssetTask to the list of active tasks
  57028. * @param taskName defines the name of the new task
  57029. * @param url defines the url of the file to load
  57030. * @param size defines the size you want for the cubemap (can be null)
  57031. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57032. * @param generateHarmonics defines if you want to automatically generate (true by default)
  57033. * @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)
  57034. * @param reserved Internal use only
  57035. * @returns a new HDRCubeTextureAssetTask object
  57036. */
  57037. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  57038. /**
  57039. * Remove a task from the assets manager.
  57040. * @param task the task to remove
  57041. */
  57042. removeTask(task: AbstractAssetTask): void;
  57043. private _decreaseWaitingTasksCount;
  57044. private _runTask;
  57045. /**
  57046. * Reset the AssetsManager and remove all tasks
  57047. * @return the current instance of the AssetsManager
  57048. */
  57049. reset(): AssetsManager;
  57050. /**
  57051. * Start the loading process
  57052. * @return the current instance of the AssetsManager
  57053. */
  57054. load(): AssetsManager;
  57055. /**
  57056. * Start the loading process as an async operation
  57057. * @return a promise returning the list of failed tasks
  57058. */
  57059. loadAsync(): Promise<void>;
  57060. }
  57061. }
  57062. declare module "babylonjs/Misc/deferred" {
  57063. /**
  57064. * Wrapper class for promise with external resolve and reject.
  57065. */
  57066. export class Deferred<T> {
  57067. /**
  57068. * The promise associated with this deferred object.
  57069. */
  57070. readonly promise: Promise<T>;
  57071. private _resolve;
  57072. private _reject;
  57073. /**
  57074. * The resolve method of the promise associated with this deferred object.
  57075. */
  57076. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  57077. /**
  57078. * The reject method of the promise associated with this deferred object.
  57079. */
  57080. readonly reject: (reason?: any) => void;
  57081. /**
  57082. * Constructor for this deferred object.
  57083. */
  57084. constructor();
  57085. }
  57086. }
  57087. declare module "babylonjs/Misc/meshExploder" {
  57088. import { Mesh } from "babylonjs/Meshes/mesh";
  57089. /**
  57090. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  57091. */
  57092. export class MeshExploder {
  57093. private _centerMesh;
  57094. private _meshes;
  57095. private _meshesOrigins;
  57096. private _toCenterVectors;
  57097. private _scaledDirection;
  57098. private _newPosition;
  57099. private _centerPosition;
  57100. /**
  57101. * Explodes meshes from a center mesh.
  57102. * @param meshes The meshes to explode.
  57103. * @param centerMesh The mesh to be center of explosion.
  57104. */
  57105. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  57106. private _setCenterMesh;
  57107. /**
  57108. * Get class name
  57109. * @returns "MeshExploder"
  57110. */
  57111. getClassName(): string;
  57112. /**
  57113. * "Exploded meshes"
  57114. * @returns Array of meshes with the centerMesh at index 0.
  57115. */
  57116. getMeshes(): Array<Mesh>;
  57117. /**
  57118. * Explodes meshes giving a specific direction
  57119. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  57120. */
  57121. explode(direction?: number): void;
  57122. }
  57123. }
  57124. declare module "babylonjs/Misc/filesInput" {
  57125. import { Engine } from "babylonjs/Engines/engine";
  57126. import { Scene } from "babylonjs/scene";
  57127. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  57128. /**
  57129. * Class used to help managing file picking and drag'n'drop
  57130. */
  57131. export class FilesInput {
  57132. /**
  57133. * List of files ready to be loaded
  57134. */
  57135. static readonly FilesToLoad: {
  57136. [key: string]: File;
  57137. };
  57138. /**
  57139. * Callback called when a file is processed
  57140. */
  57141. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  57142. private _engine;
  57143. private _currentScene;
  57144. private _sceneLoadedCallback;
  57145. private _progressCallback;
  57146. private _additionalRenderLoopLogicCallback;
  57147. private _textureLoadingCallback;
  57148. private _startingProcessingFilesCallback;
  57149. private _onReloadCallback;
  57150. private _errorCallback;
  57151. private _elementToMonitor;
  57152. private _sceneFileToLoad;
  57153. private _filesToLoad;
  57154. /**
  57155. * Creates a new FilesInput
  57156. * @param engine defines the rendering engine
  57157. * @param scene defines the hosting scene
  57158. * @param sceneLoadedCallback callback called when scene is loaded
  57159. * @param progressCallback callback called to track progress
  57160. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  57161. * @param textureLoadingCallback callback called when a texture is loading
  57162. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  57163. * @param onReloadCallback callback called when a reload is requested
  57164. * @param errorCallback callback call if an error occurs
  57165. */
  57166. 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);
  57167. private _dragEnterHandler;
  57168. private _dragOverHandler;
  57169. private _dropHandler;
  57170. /**
  57171. * Calls this function to listen to drag'n'drop events on a specific DOM element
  57172. * @param elementToMonitor defines the DOM element to track
  57173. */
  57174. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  57175. /**
  57176. * Release all associated resources
  57177. */
  57178. dispose(): void;
  57179. private renderFunction;
  57180. private drag;
  57181. private drop;
  57182. private _traverseFolder;
  57183. private _processFiles;
  57184. /**
  57185. * Load files from a drop event
  57186. * @param event defines the drop event to use as source
  57187. */
  57188. loadFiles(event: any): void;
  57189. private _processReload;
  57190. /**
  57191. * Reload the current scene from the loaded files
  57192. */
  57193. reload(): void;
  57194. }
  57195. }
  57196. declare module "babylonjs/Misc/HighDynamicRange/index" {
  57197. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  57198. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  57199. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  57200. }
  57201. declare module "babylonjs/Misc/sceneOptimizer" {
  57202. import { Scene, IDisposable } from "babylonjs/scene";
  57203. import { Observable } from "babylonjs/Misc/observable";
  57204. /**
  57205. * Defines the root class used to create scene optimization to use with SceneOptimizer
  57206. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57207. */
  57208. export class SceneOptimization {
  57209. /**
  57210. * Defines the priority of this optimization (0 by default which means first in the list)
  57211. */
  57212. priority: number;
  57213. /**
  57214. * Gets a string describing the action executed by the current optimization
  57215. * @returns description string
  57216. */
  57217. getDescription(): string;
  57218. /**
  57219. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57220. * @param scene defines the current scene where to apply this optimization
  57221. * @param optimizer defines the current optimizer
  57222. * @returns true if everything that can be done was applied
  57223. */
  57224. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57225. /**
  57226. * Creates the SceneOptimization object
  57227. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57228. * @param desc defines the description associated with the optimization
  57229. */
  57230. constructor(
  57231. /**
  57232. * Defines the priority of this optimization (0 by default which means first in the list)
  57233. */
  57234. priority?: number);
  57235. }
  57236. /**
  57237. * Defines an optimization used to reduce the size of render target textures
  57238. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57239. */
  57240. export class TextureOptimization extends SceneOptimization {
  57241. /**
  57242. * Defines the priority of this optimization (0 by default which means first in the list)
  57243. */
  57244. priority: number;
  57245. /**
  57246. * 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
  57247. */
  57248. maximumSize: number;
  57249. /**
  57250. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  57251. */
  57252. step: number;
  57253. /**
  57254. * Gets a string describing the action executed by the current optimization
  57255. * @returns description string
  57256. */
  57257. getDescription(): string;
  57258. /**
  57259. * Creates the TextureOptimization object
  57260. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57261. * @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
  57262. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  57263. */
  57264. constructor(
  57265. /**
  57266. * Defines the priority of this optimization (0 by default which means first in the list)
  57267. */
  57268. priority?: number,
  57269. /**
  57270. * 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
  57271. */
  57272. maximumSize?: number,
  57273. /**
  57274. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  57275. */
  57276. step?: number);
  57277. /**
  57278. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57279. * @param scene defines the current scene where to apply this optimization
  57280. * @param optimizer defines the current optimizer
  57281. * @returns true if everything that can be done was applied
  57282. */
  57283. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57284. }
  57285. /**
  57286. * Defines an optimization used to increase or decrease the rendering resolution
  57287. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57288. */
  57289. export class HardwareScalingOptimization extends SceneOptimization {
  57290. /**
  57291. * Defines the priority of this optimization (0 by default which means first in the list)
  57292. */
  57293. priority: number;
  57294. /**
  57295. * Defines the maximum scale to use (2 by default)
  57296. */
  57297. maximumScale: number;
  57298. /**
  57299. * Defines the step to use between two passes (0.5 by default)
  57300. */
  57301. step: number;
  57302. private _currentScale;
  57303. private _directionOffset;
  57304. /**
  57305. * Gets a string describing the action executed by the current optimization
  57306. * @return description string
  57307. */
  57308. getDescription(): string;
  57309. /**
  57310. * Creates the HardwareScalingOptimization object
  57311. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57312. * @param maximumScale defines the maximum scale to use (2 by default)
  57313. * @param step defines the step to use between two passes (0.5 by default)
  57314. */
  57315. constructor(
  57316. /**
  57317. * Defines the priority of this optimization (0 by default which means first in the list)
  57318. */
  57319. priority?: number,
  57320. /**
  57321. * Defines the maximum scale to use (2 by default)
  57322. */
  57323. maximumScale?: number,
  57324. /**
  57325. * Defines the step to use between two passes (0.5 by default)
  57326. */
  57327. step?: number);
  57328. /**
  57329. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57330. * @param scene defines the current scene where to apply this optimization
  57331. * @param optimizer defines the current optimizer
  57332. * @returns true if everything that can be done was applied
  57333. */
  57334. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57335. }
  57336. /**
  57337. * Defines an optimization used to remove shadows
  57338. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57339. */
  57340. export class ShadowsOptimization extends SceneOptimization {
  57341. /**
  57342. * Gets a string describing the action executed by the current optimization
  57343. * @return description string
  57344. */
  57345. getDescription(): string;
  57346. /**
  57347. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57348. * @param scene defines the current scene where to apply this optimization
  57349. * @param optimizer defines the current optimizer
  57350. * @returns true if everything that can be done was applied
  57351. */
  57352. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57353. }
  57354. /**
  57355. * Defines an optimization used to turn post-processes off
  57356. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57357. */
  57358. export class PostProcessesOptimization extends SceneOptimization {
  57359. /**
  57360. * Gets a string describing the action executed by the current optimization
  57361. * @return description string
  57362. */
  57363. getDescription(): string;
  57364. /**
  57365. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57366. * @param scene defines the current scene where to apply this optimization
  57367. * @param optimizer defines the current optimizer
  57368. * @returns true if everything that can be done was applied
  57369. */
  57370. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57371. }
  57372. /**
  57373. * Defines an optimization used to turn lens flares off
  57374. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57375. */
  57376. export class LensFlaresOptimization extends SceneOptimization {
  57377. /**
  57378. * Gets a string describing the action executed by the current optimization
  57379. * @return description string
  57380. */
  57381. getDescription(): string;
  57382. /**
  57383. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57384. * @param scene defines the current scene where to apply this optimization
  57385. * @param optimizer defines the current optimizer
  57386. * @returns true if everything that can be done was applied
  57387. */
  57388. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57389. }
  57390. /**
  57391. * Defines an optimization based on user defined callback.
  57392. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57393. */
  57394. export class CustomOptimization extends SceneOptimization {
  57395. /**
  57396. * Callback called to apply the custom optimization.
  57397. */
  57398. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  57399. /**
  57400. * Callback called to get custom description
  57401. */
  57402. onGetDescription: () => string;
  57403. /**
  57404. * Gets a string describing the action executed by the current optimization
  57405. * @returns description string
  57406. */
  57407. getDescription(): string;
  57408. /**
  57409. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57410. * @param scene defines the current scene where to apply this optimization
  57411. * @param optimizer defines the current optimizer
  57412. * @returns true if everything that can be done was applied
  57413. */
  57414. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57415. }
  57416. /**
  57417. * Defines an optimization used to turn particles off
  57418. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57419. */
  57420. export class ParticlesOptimization extends SceneOptimization {
  57421. /**
  57422. * Gets a string describing the action executed by the current optimization
  57423. * @return description string
  57424. */
  57425. getDescription(): string;
  57426. /**
  57427. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57428. * @param scene defines the current scene where to apply this optimization
  57429. * @param optimizer defines the current optimizer
  57430. * @returns true if everything that can be done was applied
  57431. */
  57432. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57433. }
  57434. /**
  57435. * Defines an optimization used to turn render targets off
  57436. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57437. */
  57438. export class RenderTargetsOptimization extends SceneOptimization {
  57439. /**
  57440. * Gets a string describing the action executed by the current optimization
  57441. * @return description string
  57442. */
  57443. getDescription(): string;
  57444. /**
  57445. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57446. * @param scene defines the current scene where to apply this optimization
  57447. * @param optimizer defines the current optimizer
  57448. * @returns true if everything that can be done was applied
  57449. */
  57450. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57451. }
  57452. /**
  57453. * Defines an optimization used to merge meshes with compatible materials
  57454. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57455. */
  57456. export class MergeMeshesOptimization extends SceneOptimization {
  57457. private static _UpdateSelectionTree;
  57458. /**
  57459. * Gets or sets a boolean which defines if optimization octree has to be updated
  57460. */
  57461. /**
  57462. * Gets or sets a boolean which defines if optimization octree has to be updated
  57463. */
  57464. static UpdateSelectionTree: boolean;
  57465. /**
  57466. * Gets a string describing the action executed by the current optimization
  57467. * @return description string
  57468. */
  57469. getDescription(): string;
  57470. private _canBeMerged;
  57471. /**
  57472. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57473. * @param scene defines the current scene where to apply this optimization
  57474. * @param optimizer defines the current optimizer
  57475. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  57476. * @returns true if everything that can be done was applied
  57477. */
  57478. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  57479. }
  57480. /**
  57481. * Defines a list of options used by SceneOptimizer
  57482. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57483. */
  57484. export class SceneOptimizerOptions {
  57485. /**
  57486. * Defines the target frame rate to reach (60 by default)
  57487. */
  57488. targetFrameRate: number;
  57489. /**
  57490. * Defines the interval between two checkes (2000ms by default)
  57491. */
  57492. trackerDuration: number;
  57493. /**
  57494. * Gets the list of optimizations to apply
  57495. */
  57496. optimizations: SceneOptimization[];
  57497. /**
  57498. * Creates a new list of options used by SceneOptimizer
  57499. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  57500. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  57501. */
  57502. constructor(
  57503. /**
  57504. * Defines the target frame rate to reach (60 by default)
  57505. */
  57506. targetFrameRate?: number,
  57507. /**
  57508. * Defines the interval between two checkes (2000ms by default)
  57509. */
  57510. trackerDuration?: number);
  57511. /**
  57512. * Add a new optimization
  57513. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  57514. * @returns the current SceneOptimizerOptions
  57515. */
  57516. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  57517. /**
  57518. * Add a new custom optimization
  57519. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  57520. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  57521. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57522. * @returns the current SceneOptimizerOptions
  57523. */
  57524. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  57525. /**
  57526. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  57527. * @param targetFrameRate defines the target frame rate (60 by default)
  57528. * @returns a SceneOptimizerOptions object
  57529. */
  57530. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  57531. /**
  57532. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  57533. * @param targetFrameRate defines the target frame rate (60 by default)
  57534. * @returns a SceneOptimizerOptions object
  57535. */
  57536. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  57537. /**
  57538. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  57539. * @param targetFrameRate defines the target frame rate (60 by default)
  57540. * @returns a SceneOptimizerOptions object
  57541. */
  57542. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  57543. }
  57544. /**
  57545. * Class used to run optimizations in order to reach a target frame rate
  57546. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57547. */
  57548. export class SceneOptimizer implements IDisposable {
  57549. private _isRunning;
  57550. private _options;
  57551. private _scene;
  57552. private _currentPriorityLevel;
  57553. private _targetFrameRate;
  57554. private _trackerDuration;
  57555. private _currentFrameRate;
  57556. private _sceneDisposeObserver;
  57557. private _improvementMode;
  57558. /**
  57559. * Defines an observable called when the optimizer reaches the target frame rate
  57560. */
  57561. onSuccessObservable: Observable<SceneOptimizer>;
  57562. /**
  57563. * Defines an observable called when the optimizer enables an optimization
  57564. */
  57565. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  57566. /**
  57567. * Defines an observable called when the optimizer is not able to reach the target frame rate
  57568. */
  57569. onFailureObservable: Observable<SceneOptimizer>;
  57570. /**
  57571. * Gets a boolean indicating if the optimizer is in improvement mode
  57572. */
  57573. readonly isInImprovementMode: boolean;
  57574. /**
  57575. * Gets the current priority level (0 at start)
  57576. */
  57577. readonly currentPriorityLevel: number;
  57578. /**
  57579. * Gets the current frame rate checked by the SceneOptimizer
  57580. */
  57581. readonly currentFrameRate: number;
  57582. /**
  57583. * Gets or sets the current target frame rate (60 by default)
  57584. */
  57585. /**
  57586. * Gets or sets the current target frame rate (60 by default)
  57587. */
  57588. targetFrameRate: number;
  57589. /**
  57590. * Gets or sets the current interval between two checks (every 2000ms by default)
  57591. */
  57592. /**
  57593. * Gets or sets the current interval between two checks (every 2000ms by default)
  57594. */
  57595. trackerDuration: number;
  57596. /**
  57597. * Gets the list of active optimizations
  57598. */
  57599. readonly optimizations: SceneOptimization[];
  57600. /**
  57601. * Creates a new SceneOptimizer
  57602. * @param scene defines the scene to work on
  57603. * @param options defines the options to use with the SceneOptimizer
  57604. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  57605. * @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)
  57606. */
  57607. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  57608. /**
  57609. * Stops the current optimizer
  57610. */
  57611. stop(): void;
  57612. /**
  57613. * Reset the optimizer to initial step (current priority level = 0)
  57614. */
  57615. reset(): void;
  57616. /**
  57617. * Start the optimizer. By default it will try to reach a specific framerate
  57618. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  57619. */
  57620. start(): void;
  57621. private _checkCurrentState;
  57622. /**
  57623. * Release all resources
  57624. */
  57625. dispose(): void;
  57626. /**
  57627. * Helper function to create a SceneOptimizer with one single line of code
  57628. * @param scene defines the scene to work on
  57629. * @param options defines the options to use with the SceneOptimizer
  57630. * @param onSuccess defines a callback to call on success
  57631. * @param onFailure defines a callback to call on failure
  57632. * @returns the new SceneOptimizer object
  57633. */
  57634. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  57635. }
  57636. }
  57637. declare module "babylonjs/Misc/sceneSerializer" {
  57638. import { Scene } from "babylonjs/scene";
  57639. /**
  57640. * Class used to serialize a scene into a string
  57641. */
  57642. export class SceneSerializer {
  57643. /**
  57644. * Clear cache used by a previous serialization
  57645. */
  57646. static ClearCache(): void;
  57647. /**
  57648. * Serialize a scene into a JSON compatible object
  57649. * @param scene defines the scene to serialize
  57650. * @returns a JSON compatible object
  57651. */
  57652. static Serialize(scene: Scene): any;
  57653. /**
  57654. * Serialize a mesh into a JSON compatible object
  57655. * @param toSerialize defines the mesh to serialize
  57656. * @param withParents defines if parents must be serialized as well
  57657. * @param withChildren defines if children must be serialized as well
  57658. * @returns a JSON compatible object
  57659. */
  57660. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  57661. }
  57662. }
  57663. declare module "babylonjs/Misc/videoRecorder" {
  57664. import { Nullable } from "babylonjs/types";
  57665. import { Engine } from "babylonjs/Engines/engine";
  57666. /**
  57667. * This represents the different options avilable for the video capture.
  57668. */
  57669. export interface VideoRecorderOptions {
  57670. /** Defines the mime type of the video */
  57671. mimeType: string;
  57672. /** Defines the video the video should be recorded at */
  57673. fps: number;
  57674. /** Defines the chunk size for the recording data */
  57675. recordChunckSize: number;
  57676. /** The audio tracks to attach to the record */
  57677. audioTracks?: MediaStreamTrack[];
  57678. }
  57679. /**
  57680. * This can helps recording videos from BabylonJS.
  57681. * This is based on the available WebRTC functionalities of the browser.
  57682. *
  57683. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  57684. */
  57685. export class VideoRecorder {
  57686. private static readonly _defaultOptions;
  57687. /**
  57688. * Returns wehther or not the VideoRecorder is available in your browser.
  57689. * @param engine Defines the Babylon Engine to check the support for
  57690. * @returns true if supported otherwise false
  57691. */
  57692. static IsSupported(engine: Engine): boolean;
  57693. private readonly _options;
  57694. private _canvas;
  57695. private _mediaRecorder;
  57696. private _recordedChunks;
  57697. private _fileName;
  57698. private _resolve;
  57699. private _reject;
  57700. /**
  57701. * True wether a recording is already in progress.
  57702. */
  57703. readonly isRecording: boolean;
  57704. /**
  57705. * Create a new VideoCapture object which can help converting what you see in Babylon to
  57706. * a video file.
  57707. * @param engine Defines the BabylonJS Engine you wish to record
  57708. * @param options Defines options that can be used to customized the capture
  57709. */
  57710. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  57711. /**
  57712. * Stops the current recording before the default capture timeout passed in the startRecording
  57713. * functions.
  57714. */
  57715. stopRecording(): void;
  57716. /**
  57717. * Starts recording the canvas for a max duration specified in parameters.
  57718. * @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.
  57719. * @param maxDuration Defines the maximum recording time in seconds.
  57720. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  57721. * @return a promise callback at the end of the recording with the video data in Blob.
  57722. */
  57723. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  57724. /**
  57725. * Releases internal resources used during the recording.
  57726. */
  57727. dispose(): void;
  57728. private _handleDataAvailable;
  57729. private _handleError;
  57730. private _handleStop;
  57731. }
  57732. }
  57733. declare module "babylonjs/Misc/workerPool" {
  57734. import { IDisposable } from "babylonjs/scene";
  57735. /**
  57736. * Helper class to push actions to a pool of workers.
  57737. */
  57738. export class WorkerPool implements IDisposable {
  57739. private _workerInfos;
  57740. private _pendingActions;
  57741. /**
  57742. * Constructor
  57743. * @param workers Array of workers to use for actions
  57744. */
  57745. constructor(workers: Array<Worker>);
  57746. /**
  57747. * Terminates all workers and clears any pending actions.
  57748. */
  57749. dispose(): void;
  57750. /**
  57751. * Pushes an action to the worker pool. If all the workers are active, the action will be
  57752. * pended until a worker has completed its action.
  57753. * @param action The action to perform. Call onComplete when the action is complete.
  57754. */
  57755. push(action: (worker: Worker, onComplete: () => void) => void): void;
  57756. private _execute;
  57757. }
  57758. }
  57759. declare module "babylonjs/Misc/screenshotTools" {
  57760. import { Camera } from "babylonjs/Cameras/camera";
  57761. import { Engine } from "babylonjs/Engines/engine";
  57762. /**
  57763. * Class containing a set of static utilities functions for screenshots
  57764. */
  57765. export class ScreenshotTools {
  57766. /**
  57767. * Captures a screenshot of the current rendering
  57768. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  57769. * @param engine defines the rendering engine
  57770. * @param camera defines the source camera
  57771. * @param size This parameter can be set to a single number or to an object with the
  57772. * following (optional) properties: precision, width, height. If a single number is passed,
  57773. * it will be used for both width and height. If an object is passed, the screenshot size
  57774. * will be derived from the parameters. The precision property is a multiplier allowing
  57775. * rendering at a higher or lower resolution
  57776. * @param successCallback defines the callback receives a single parameter which contains the
  57777. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  57778. * src parameter of an <img> to display it
  57779. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  57780. * Check your browser for supported MIME types
  57781. */
  57782. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  57783. /**
  57784. * Generates an image screenshot from the specified camera.
  57785. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  57786. * @param engine The engine to use for rendering
  57787. * @param camera The camera to use for rendering
  57788. * @param size This parameter can be set to a single number or to an object with the
  57789. * following (optional) properties: precision, width, height. If a single number is passed,
  57790. * it will be used for both width and height. If an object is passed, the screenshot size
  57791. * will be derived from the parameters. The precision property is a multiplier allowing
  57792. * rendering at a higher or lower resolution
  57793. * @param successCallback The callback receives a single parameter which contains the
  57794. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  57795. * src parameter of an <img> to display it
  57796. * @param mimeType The MIME type of the screenshot image (default: image/png).
  57797. * Check your browser for supported MIME types
  57798. * @param samples Texture samples (default: 1)
  57799. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  57800. * @param fileName A name for for the downloaded file.
  57801. */
  57802. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  57803. }
  57804. }
  57805. declare module "babylonjs/Misc/index" {
  57806. export * from "babylonjs/Misc/andOrNotEvaluator";
  57807. export * from "babylonjs/Misc/assetsManager";
  57808. export * from "babylonjs/Misc/dds";
  57809. export * from "babylonjs/Misc/decorators";
  57810. export * from "babylonjs/Misc/deferred";
  57811. export * from "babylonjs/Misc/environmentTextureTools";
  57812. export * from "babylonjs/Misc/meshExploder";
  57813. export * from "babylonjs/Misc/filesInput";
  57814. export * from "babylonjs/Misc/HighDynamicRange/index";
  57815. export * from "babylonjs/Misc/khronosTextureContainer";
  57816. export * from "babylonjs/Misc/observable";
  57817. export * from "babylonjs/Misc/performanceMonitor";
  57818. export * from "babylonjs/Misc/promise";
  57819. export * from "babylonjs/Misc/sceneOptimizer";
  57820. export * from "babylonjs/Misc/sceneSerializer";
  57821. export * from "babylonjs/Misc/smartArray";
  57822. export * from "babylonjs/Misc/stringDictionary";
  57823. export * from "babylonjs/Misc/tags";
  57824. export * from "babylonjs/Misc/textureTools";
  57825. export * from "babylonjs/Misc/tga";
  57826. export * from "babylonjs/Misc/tools";
  57827. export * from "babylonjs/Misc/videoRecorder";
  57828. export * from "babylonjs/Misc/virtualJoystick";
  57829. export * from "babylonjs/Misc/workerPool";
  57830. export * from "babylonjs/Misc/logger";
  57831. export * from "babylonjs/Misc/typeStore";
  57832. export * from "babylonjs/Misc/filesInputStore";
  57833. export * from "babylonjs/Misc/deepCopier";
  57834. export * from "babylonjs/Misc/pivotTools";
  57835. export * from "babylonjs/Misc/precisionDate";
  57836. export * from "babylonjs/Misc/screenshotTools";
  57837. export * from "babylonjs/Misc/typeStore";
  57838. export * from "babylonjs/Misc/webRequest";
  57839. export * from "babylonjs/Misc/iInspectable";
  57840. }
  57841. declare module "babylonjs/index" {
  57842. export * from "babylonjs/abstractScene";
  57843. export * from "babylonjs/Actions/index";
  57844. export * from "babylonjs/Animations/index";
  57845. export * from "babylonjs/assetContainer";
  57846. export * from "babylonjs/Audio/index";
  57847. export * from "babylonjs/Behaviors/index";
  57848. export * from "babylonjs/Bones/index";
  57849. export * from "babylonjs/Cameras/index";
  57850. export * from "babylonjs/Collisions/index";
  57851. export * from "babylonjs/Culling/index";
  57852. export * from "babylonjs/Debug/index";
  57853. export * from "babylonjs/Engines/index";
  57854. export * from "babylonjs/Events/index";
  57855. export * from "babylonjs/Gamepads/index";
  57856. export * from "babylonjs/Gizmos/index";
  57857. export * from "babylonjs/Helpers/index";
  57858. export * from "babylonjs/Instrumentation/index";
  57859. export * from "babylonjs/Layers/index";
  57860. export * from "babylonjs/LensFlares/index";
  57861. export * from "babylonjs/Lights/index";
  57862. export * from "babylonjs/Loading/index";
  57863. export * from "babylonjs/Materials/index";
  57864. export * from "babylonjs/Maths/index";
  57865. export * from "babylonjs/Meshes/index";
  57866. export * from "babylonjs/Morph/index";
  57867. export * from "babylonjs/node";
  57868. export * from "babylonjs/Offline/index";
  57869. export * from "babylonjs/Particles/index";
  57870. export * from "babylonjs/Physics/index";
  57871. export * from "babylonjs/PostProcesses/index";
  57872. export * from "babylonjs/Probes/index";
  57873. export * from "babylonjs/Rendering/index";
  57874. export * from "babylonjs/scene";
  57875. export * from "babylonjs/sceneComponent";
  57876. export * from "babylonjs/Sprites/index";
  57877. export * from "babylonjs/States/index";
  57878. export * from "babylonjs/Misc/index";
  57879. export * from "babylonjs/types";
  57880. }
  57881. declare module "babylonjs/Animations/pathCursor" {
  57882. import { Path2, Vector3 } from "babylonjs/Maths/math";
  57883. /**
  57884. * A cursor which tracks a point on a path
  57885. */
  57886. export class PathCursor {
  57887. private path;
  57888. /**
  57889. * Stores path cursor callbacks for when an onchange event is triggered
  57890. */
  57891. private _onchange;
  57892. /**
  57893. * The value of the path cursor
  57894. */
  57895. value: number;
  57896. /**
  57897. * The animation array of the path cursor
  57898. */
  57899. animations: Animation[];
  57900. /**
  57901. * Initializes the path cursor
  57902. * @param path The path to track
  57903. */
  57904. constructor(path: Path2);
  57905. /**
  57906. * Gets the cursor point on the path
  57907. * @returns A point on the path cursor at the cursor location
  57908. */
  57909. getPoint(): Vector3;
  57910. /**
  57911. * Moves the cursor ahead by the step amount
  57912. * @param step The amount to move the cursor forward
  57913. * @returns This path cursor
  57914. */
  57915. moveAhead(step?: number): PathCursor;
  57916. /**
  57917. * Moves the cursor behind by the step amount
  57918. * @param step The amount to move the cursor back
  57919. * @returns This path cursor
  57920. */
  57921. moveBack(step?: number): PathCursor;
  57922. /**
  57923. * Moves the cursor by the step amount
  57924. * If the step amount is greater than one, an exception is thrown
  57925. * @param step The amount to move the cursor
  57926. * @returns This path cursor
  57927. */
  57928. move(step: number): PathCursor;
  57929. /**
  57930. * Ensures that the value is limited between zero and one
  57931. * @returns This path cursor
  57932. */
  57933. private ensureLimits;
  57934. /**
  57935. * Runs onchange callbacks on change (used by the animation engine)
  57936. * @returns This path cursor
  57937. */
  57938. private raiseOnChange;
  57939. /**
  57940. * Executes a function on change
  57941. * @param f A path cursor onchange callback
  57942. * @returns This path cursor
  57943. */
  57944. onchange(f: (cursor: PathCursor) => void): PathCursor;
  57945. }
  57946. }
  57947. declare module "babylonjs/Legacy/legacy" {
  57948. import * as Babylon from "babylonjs/index";
  57949. export * from "babylonjs/index";
  57950. }
  57951. declare module "babylonjs/Shaders/blur.fragment" {
  57952. /** @hidden */
  57953. export var blurPixelShader: {
  57954. name: string;
  57955. shader: string;
  57956. };
  57957. }
  57958. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  57959. /** @hidden */
  57960. export var bones300Declaration: {
  57961. name: string;
  57962. shader: string;
  57963. };
  57964. }
  57965. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  57966. /** @hidden */
  57967. export var instances300Declaration: {
  57968. name: string;
  57969. shader: string;
  57970. };
  57971. }
  57972. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  57973. /** @hidden */
  57974. export var pointCloudVertexDeclaration: {
  57975. name: string;
  57976. shader: string;
  57977. };
  57978. }
  57979. // Mixins
  57980. interface Window {
  57981. mozIndexedDB: IDBFactory;
  57982. webkitIndexedDB: IDBFactory;
  57983. msIndexedDB: IDBFactory;
  57984. webkitURL: typeof URL;
  57985. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  57986. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  57987. WebGLRenderingContext: WebGLRenderingContext;
  57988. MSGesture: MSGesture;
  57989. CANNON: any;
  57990. AudioContext: AudioContext;
  57991. webkitAudioContext: AudioContext;
  57992. PointerEvent: any;
  57993. Math: Math;
  57994. Uint8Array: Uint8ArrayConstructor;
  57995. Float32Array: Float32ArrayConstructor;
  57996. mozURL: typeof URL;
  57997. msURL: typeof URL;
  57998. VRFrameData: any; // WebVR, from specs 1.1
  57999. DracoDecoderModule: any;
  58000. setImmediate(handler: (...args: any[]) => void): number;
  58001. }
  58002. interface HTMLCanvasElement {
  58003. requestPointerLock(): void;
  58004. msRequestPointerLock?(): void;
  58005. mozRequestPointerLock?(): void;
  58006. webkitRequestPointerLock?(): void;
  58007. /** Track wether a record is in progress */
  58008. isRecording: boolean;
  58009. /** Capture Stream method defined by some browsers */
  58010. captureStream(fps?: number): MediaStream;
  58011. }
  58012. interface CanvasRenderingContext2D {
  58013. msImageSmoothingEnabled: boolean;
  58014. }
  58015. interface MouseEvent {
  58016. mozMovementX: number;
  58017. mozMovementY: number;
  58018. webkitMovementX: number;
  58019. webkitMovementY: number;
  58020. msMovementX: number;
  58021. msMovementY: number;
  58022. }
  58023. interface Navigator {
  58024. mozGetVRDevices: (any: any) => any;
  58025. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58026. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58027. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58028. webkitGetGamepads(): Gamepad[];
  58029. msGetGamepads(): Gamepad[];
  58030. webkitGamepads(): Gamepad[];
  58031. }
  58032. interface HTMLVideoElement {
  58033. mozSrcObject: any;
  58034. }
  58035. interface Math {
  58036. fround(x: number): number;
  58037. imul(a: number, b: number): number;
  58038. }
  58039. interface WebGLProgram {
  58040. context?: WebGLRenderingContext;
  58041. vertexShader?: WebGLShader;
  58042. fragmentShader?: WebGLShader;
  58043. isParallelCompiled: boolean;
  58044. onCompiled?: () => void;
  58045. }
  58046. interface WebGLRenderingContext {
  58047. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  58048. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  58049. vertexAttribDivisor(index: number, divisor: number): void;
  58050. createVertexArray(): any;
  58051. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  58052. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  58053. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  58054. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  58055. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  58056. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  58057. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  58058. // Queries
  58059. createQuery(): WebGLQuery;
  58060. deleteQuery(query: WebGLQuery): void;
  58061. beginQuery(target: number, query: WebGLQuery): void;
  58062. endQuery(target: number): void;
  58063. getQueryParameter(query: WebGLQuery, pname: number): any;
  58064. getQuery(target: number, pname: number): any;
  58065. MAX_SAMPLES: number;
  58066. RGBA8: number;
  58067. READ_FRAMEBUFFER: number;
  58068. DRAW_FRAMEBUFFER: number;
  58069. UNIFORM_BUFFER: number;
  58070. HALF_FLOAT_OES: number;
  58071. RGBA16F: number;
  58072. RGBA32F: number;
  58073. R32F: number;
  58074. RG32F: number;
  58075. RGB32F: number;
  58076. R16F: number;
  58077. RG16F: number;
  58078. RGB16F: number;
  58079. RED: number;
  58080. RG: number;
  58081. R8: number;
  58082. RG8: number;
  58083. UNSIGNED_INT_24_8: number;
  58084. DEPTH24_STENCIL8: number;
  58085. /* Multiple Render Targets */
  58086. drawBuffers(buffers: number[]): void;
  58087. readBuffer(src: number): void;
  58088. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  58089. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  58090. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  58091. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  58092. // Occlusion Query
  58093. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  58094. ANY_SAMPLES_PASSED: number;
  58095. QUERY_RESULT_AVAILABLE: number;
  58096. QUERY_RESULT: number;
  58097. }
  58098. interface WebGLBuffer {
  58099. references: number;
  58100. capacity: number;
  58101. is32Bits: boolean;
  58102. }
  58103. interface WebGLProgram {
  58104. transformFeedback?: WebGLTransformFeedback | null;
  58105. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  58106. }
  58107. interface EXT_disjoint_timer_query {
  58108. QUERY_COUNTER_BITS_EXT: number;
  58109. TIME_ELAPSED_EXT: number;
  58110. TIMESTAMP_EXT: number;
  58111. GPU_DISJOINT_EXT: number;
  58112. QUERY_RESULT_EXT: number;
  58113. QUERY_RESULT_AVAILABLE_EXT: number;
  58114. queryCounterEXT(query: WebGLQuery, target: number): void;
  58115. createQueryEXT(): WebGLQuery;
  58116. beginQueryEXT(target: number, query: WebGLQuery): void;
  58117. endQueryEXT(target: number): void;
  58118. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  58119. deleteQueryEXT(query: WebGLQuery): void;
  58120. }
  58121. interface WebGLUniformLocation {
  58122. _currentState: any;
  58123. }
  58124. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  58125. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  58126. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  58127. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  58128. interface WebGLRenderingContext {
  58129. readonly RASTERIZER_DISCARD: number;
  58130. readonly DEPTH_COMPONENT24: number;
  58131. readonly TEXTURE_3D: number;
  58132. readonly TEXTURE_2D_ARRAY: number;
  58133. readonly TEXTURE_COMPARE_FUNC: number;
  58134. readonly TEXTURE_COMPARE_MODE: number;
  58135. readonly COMPARE_REF_TO_TEXTURE: number;
  58136. readonly TEXTURE_WRAP_R: number;
  58137. readonly HALF_FLOAT: number;
  58138. readonly RGB8: number;
  58139. readonly RED_INTEGER: number;
  58140. readonly RG_INTEGER: number;
  58141. readonly RGB_INTEGER: number;
  58142. readonly RGBA_INTEGER: number;
  58143. readonly R8_SNORM: number;
  58144. readonly RG8_SNORM: number;
  58145. readonly RGB8_SNORM: number;
  58146. readonly RGBA8_SNORM: number;
  58147. readonly R8I: number;
  58148. readonly RG8I: number;
  58149. readonly RGB8I: number;
  58150. readonly RGBA8I: number;
  58151. readonly R8UI: number;
  58152. readonly RG8UI: number;
  58153. readonly RGB8UI: number;
  58154. readonly RGBA8UI: number;
  58155. readonly R16I: number;
  58156. readonly RG16I: number;
  58157. readonly RGB16I: number;
  58158. readonly RGBA16I: number;
  58159. readonly R16UI: number;
  58160. readonly RG16UI: number;
  58161. readonly RGB16UI: number;
  58162. readonly RGBA16UI: number;
  58163. readonly R32I: number;
  58164. readonly RG32I: number;
  58165. readonly RGB32I: number;
  58166. readonly RGBA32I: number;
  58167. readonly R32UI: number;
  58168. readonly RG32UI: number;
  58169. readonly RGB32UI: number;
  58170. readonly RGBA32UI: number;
  58171. readonly RGB10_A2UI: number;
  58172. readonly R11F_G11F_B10F: number;
  58173. readonly RGB9_E5: number;
  58174. readonly RGB10_A2: number;
  58175. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  58176. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  58177. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  58178. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  58179. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  58180. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  58181. 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;
  58182. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  58183. readonly TRANSFORM_FEEDBACK: number;
  58184. readonly INTERLEAVED_ATTRIBS: number;
  58185. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  58186. createTransformFeedback(): WebGLTransformFeedback;
  58187. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  58188. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  58189. beginTransformFeedback(primitiveMode: number): void;
  58190. endTransformFeedback(): void;
  58191. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  58192. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58193. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58194. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58195. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  58196. }
  58197. interface ImageBitmap {
  58198. readonly width: number;
  58199. readonly height: number;
  58200. close(): void;
  58201. }
  58202. interface WebGLQuery extends WebGLObject {
  58203. }
  58204. declare var WebGLQuery: {
  58205. prototype: WebGLQuery;
  58206. new(): WebGLQuery;
  58207. };
  58208. interface WebGLSampler extends WebGLObject {
  58209. }
  58210. declare var WebGLSampler: {
  58211. prototype: WebGLSampler;
  58212. new(): WebGLSampler;
  58213. };
  58214. interface WebGLSync extends WebGLObject {
  58215. }
  58216. declare var WebGLSync: {
  58217. prototype: WebGLSync;
  58218. new(): WebGLSync;
  58219. };
  58220. interface WebGLTransformFeedback extends WebGLObject {
  58221. }
  58222. declare var WebGLTransformFeedback: {
  58223. prototype: WebGLTransformFeedback;
  58224. new(): WebGLTransformFeedback;
  58225. };
  58226. interface WebGLVertexArrayObject extends WebGLObject {
  58227. }
  58228. declare var WebGLVertexArrayObject: {
  58229. prototype: WebGLVertexArrayObject;
  58230. new(): WebGLVertexArrayObject;
  58231. };
  58232. // Type definitions for WebVR API
  58233. // Project: https://w3c.github.io/webvr/
  58234. // Definitions by: six a <https://github.com/lostfictions>
  58235. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  58236. interface VRDisplay extends EventTarget {
  58237. /**
  58238. * Dictionary of capabilities describing the VRDisplay.
  58239. */
  58240. readonly capabilities: VRDisplayCapabilities;
  58241. /**
  58242. * z-depth defining the far plane of the eye view frustum
  58243. * enables mapping of values in the render target depth
  58244. * attachment to scene coordinates. Initially set to 10000.0.
  58245. */
  58246. depthFar: number;
  58247. /**
  58248. * z-depth defining the near plane of the eye view frustum
  58249. * enables mapping of values in the render target depth
  58250. * attachment to scene coordinates. Initially set to 0.01.
  58251. */
  58252. depthNear: number;
  58253. /**
  58254. * An identifier for this distinct VRDisplay. Used as an
  58255. * association point in the Gamepad API.
  58256. */
  58257. readonly displayId: number;
  58258. /**
  58259. * A display name, a user-readable name identifying it.
  58260. */
  58261. readonly displayName: string;
  58262. readonly isConnected: boolean;
  58263. readonly isPresenting: boolean;
  58264. /**
  58265. * If this VRDisplay supports room-scale experiences, the optional
  58266. * stage attribute contains details on the room-scale parameters.
  58267. */
  58268. readonly stageParameters: VRStageParameters | null;
  58269. /**
  58270. * Passing the value returned by `requestAnimationFrame` to
  58271. * `cancelAnimationFrame` will unregister the callback.
  58272. * @param handle Define the hanle of the request to cancel
  58273. */
  58274. cancelAnimationFrame(handle: number): void;
  58275. /**
  58276. * Stops presenting to the VRDisplay.
  58277. * @returns a promise to know when it stopped
  58278. */
  58279. exitPresent(): Promise<void>;
  58280. /**
  58281. * Return the current VREyeParameters for the given eye.
  58282. * @param whichEye Define the eye we want the parameter for
  58283. * @returns the eye parameters
  58284. */
  58285. getEyeParameters(whichEye: string): VREyeParameters;
  58286. /**
  58287. * Populates the passed VRFrameData with the information required to render
  58288. * the current frame.
  58289. * @param frameData Define the data structure to populate
  58290. * @returns true if ok otherwise false
  58291. */
  58292. getFrameData(frameData: VRFrameData): boolean;
  58293. /**
  58294. * Get the layers currently being presented.
  58295. * @returns the list of VR layers
  58296. */
  58297. getLayers(): VRLayer[];
  58298. /**
  58299. * Return a VRPose containing the future predicted pose of the VRDisplay
  58300. * when the current frame will be presented. The value returned will not
  58301. * change until JavaScript has returned control to the browser.
  58302. *
  58303. * The VRPose will contain the position, orientation, velocity,
  58304. * and acceleration of each of these properties.
  58305. * @returns the pose object
  58306. */
  58307. getPose(): VRPose;
  58308. /**
  58309. * Return the current instantaneous pose of the VRDisplay, with no
  58310. * prediction applied.
  58311. * @returns the current instantaneous pose
  58312. */
  58313. getImmediatePose(): VRPose;
  58314. /**
  58315. * The callback passed to `requestAnimationFrame` will be called
  58316. * any time a new frame should be rendered. When the VRDisplay is
  58317. * presenting the callback will be called at the native refresh
  58318. * rate of the HMD. When not presenting this function acts
  58319. * identically to how window.requestAnimationFrame acts. Content should
  58320. * make no assumptions of frame rate or vsync behavior as the HMD runs
  58321. * asynchronously from other displays and at differing refresh rates.
  58322. * @param callback Define the eaction to run next frame
  58323. * @returns the request handle it
  58324. */
  58325. requestAnimationFrame(callback: FrameRequestCallback): number;
  58326. /**
  58327. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  58328. * Repeat calls while already presenting will update the VRLayers being displayed.
  58329. * @param layers Define the list of layer to present
  58330. * @returns a promise to know when the request has been fulfilled
  58331. */
  58332. requestPresent(layers: VRLayer[]): Promise<void>;
  58333. /**
  58334. * Reset the pose for this display, treating its current position and
  58335. * orientation as the "origin/zero" values. VRPose.position,
  58336. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  58337. * updated when calling resetPose(). This should be called in only
  58338. * sitting-space experiences.
  58339. */
  58340. resetPose(): void;
  58341. /**
  58342. * The VRLayer provided to the VRDisplay will be captured and presented
  58343. * in the HMD. Calling this function has the same effect on the source
  58344. * canvas as any other operation that uses its source image, and canvases
  58345. * created without preserveDrawingBuffer set to true will be cleared.
  58346. * @param pose Define the pose to submit
  58347. */
  58348. submitFrame(pose?: VRPose): void;
  58349. }
  58350. declare var VRDisplay: {
  58351. prototype: VRDisplay;
  58352. new(): VRDisplay;
  58353. };
  58354. interface VRLayer {
  58355. leftBounds?: number[] | Float32Array | null;
  58356. rightBounds?: number[] | Float32Array | null;
  58357. source?: HTMLCanvasElement | null;
  58358. }
  58359. interface VRDisplayCapabilities {
  58360. readonly canPresent: boolean;
  58361. readonly hasExternalDisplay: boolean;
  58362. readonly hasOrientation: boolean;
  58363. readonly hasPosition: boolean;
  58364. readonly maxLayers: number;
  58365. }
  58366. interface VREyeParameters {
  58367. /** @deprecated */
  58368. readonly fieldOfView: VRFieldOfView;
  58369. readonly offset: Float32Array;
  58370. readonly renderHeight: number;
  58371. readonly renderWidth: number;
  58372. }
  58373. interface VRFieldOfView {
  58374. readonly downDegrees: number;
  58375. readonly leftDegrees: number;
  58376. readonly rightDegrees: number;
  58377. readonly upDegrees: number;
  58378. }
  58379. interface VRFrameData {
  58380. readonly leftProjectionMatrix: Float32Array;
  58381. readonly leftViewMatrix: Float32Array;
  58382. readonly pose: VRPose;
  58383. readonly rightProjectionMatrix: Float32Array;
  58384. readonly rightViewMatrix: Float32Array;
  58385. readonly timestamp: number;
  58386. }
  58387. interface VRPose {
  58388. readonly angularAcceleration: Float32Array | null;
  58389. readonly angularVelocity: Float32Array | null;
  58390. readonly linearAcceleration: Float32Array | null;
  58391. readonly linearVelocity: Float32Array | null;
  58392. readonly orientation: Float32Array | null;
  58393. readonly position: Float32Array | null;
  58394. readonly timestamp: number;
  58395. }
  58396. interface VRStageParameters {
  58397. sittingToStandingTransform?: Float32Array;
  58398. sizeX?: number;
  58399. sizeY?: number;
  58400. }
  58401. interface Navigator {
  58402. getVRDisplays(): Promise<VRDisplay[]>;
  58403. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  58404. }
  58405. interface Window {
  58406. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  58407. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  58408. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  58409. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  58410. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  58411. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  58412. }
  58413. interface Gamepad {
  58414. readonly displayId: number;
  58415. }
  58416. interface XRDevice {
  58417. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  58418. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  58419. }
  58420. interface XRSession {
  58421. getInputSources(): Array<any>;
  58422. baseLayer: XRWebGLLayer;
  58423. requestFrameOfReference(type: string): Promise<void>;
  58424. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  58425. end(): Promise<void>;
  58426. requestAnimationFrame: Function;
  58427. addEventListener: Function;
  58428. }
  58429. interface XRSessionCreationOptions {
  58430. outputContext?: WebGLRenderingContext | null;
  58431. immersive?: boolean;
  58432. environmentIntegration?: boolean;
  58433. }
  58434. interface XRLayer {
  58435. getViewport: Function;
  58436. framebufferWidth: number;
  58437. framebufferHeight: number;
  58438. }
  58439. interface XRView {
  58440. projectionMatrix: Float32Array;
  58441. }
  58442. interface XRFrame {
  58443. getDevicePose: Function;
  58444. getInputPose: Function;
  58445. views: Array<XRView>;
  58446. baseLayer: XRLayer;
  58447. }
  58448. interface XRFrameOfReference {
  58449. }
  58450. interface XRWebGLLayer extends XRLayer {
  58451. framebuffer: WebGLFramebuffer;
  58452. }
  58453. declare var XRWebGLLayer: {
  58454. prototype: XRWebGLLayer;
  58455. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  58456. };
  58457. declare module "babylonjs" {
  58458. export * from "babylonjs/Legacy/legacy";
  58459. }
  58460. declare module BABYLON {
  58461. /** Alias type for value that can be null */
  58462. export type Nullable<T> = T | null;
  58463. /**
  58464. * Alias type for number that are floats
  58465. * @ignorenaming
  58466. */
  58467. export type float = number;
  58468. /**
  58469. * Alias type for number that are doubles.
  58470. * @ignorenaming
  58471. */
  58472. export type double = number;
  58473. /**
  58474. * Alias type for number that are integer
  58475. * @ignorenaming
  58476. */
  58477. export type int = number;
  58478. /** Alias type for number array or Float32Array */
  58479. export type FloatArray = number[] | Float32Array;
  58480. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  58481. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  58482. /**
  58483. * Alias for types that can be used by a Buffer or VertexBuffer.
  58484. */
  58485. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  58486. /**
  58487. * Alias type for primitive types
  58488. * @ignorenaming
  58489. */
  58490. type Primitive = undefined | null | boolean | string | number | Function;
  58491. /**
  58492. * Type modifier to make all the properties of an object Readonly
  58493. */
  58494. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  58495. /**
  58496. * Type modifier to make all the properties of an object Readonly recursively
  58497. */
  58498. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  58499. /** @hidden */
  58500. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  58501. }
  58502. /** @hidden */
  58503. /** @hidden */
  58504. type DeepImmutableObject<T> = {
  58505. readonly [K in keyof T]: DeepImmutable<T[K]>;
  58506. };
  58507. }
  58508. declare module BABYLON {
  58509. /**
  58510. * Class containing a set of static utilities functions for arrays.
  58511. */
  58512. export class ArrayTools {
  58513. /**
  58514. * Returns an array of the given size filled with element built from the given constructor and the paramters
  58515. * @param size the number of element to construct and put in the array
  58516. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58517. * @returns a new array filled with new objects
  58518. */
  58519. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  58520. }
  58521. }
  58522. declare module BABYLON {
  58523. /**
  58524. * Scalar computation library
  58525. */
  58526. export class Scalar {
  58527. /**
  58528. * Two pi constants convenient for computation.
  58529. */
  58530. static TwoPi: number;
  58531. /**
  58532. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  58533. * @param a number
  58534. * @param b number
  58535. * @param epsilon (default = 1.401298E-45)
  58536. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  58537. */
  58538. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  58539. /**
  58540. * Returns a string : the upper case translation of the number i to hexadecimal.
  58541. * @param i number
  58542. * @returns the upper case translation of the number i to hexadecimal.
  58543. */
  58544. static ToHex(i: number): string;
  58545. /**
  58546. * Returns -1 if value is negative and +1 is value is positive.
  58547. * @param value the value
  58548. * @returns the value itself if it's equal to zero.
  58549. */
  58550. static Sign(value: number): number;
  58551. /**
  58552. * Returns the value itself if it's between min and max.
  58553. * Returns min if the value is lower than min.
  58554. * Returns max if the value is greater than max.
  58555. * @param value the value to clmap
  58556. * @param min the min value to clamp to (default: 0)
  58557. * @param max the max value to clamp to (default: 1)
  58558. * @returns the clamped value
  58559. */
  58560. static Clamp(value: number, min?: number, max?: number): number;
  58561. /**
  58562. * the log2 of value.
  58563. * @param value the value to compute log2 of
  58564. * @returns the log2 of value.
  58565. */
  58566. static Log2(value: number): number;
  58567. /**
  58568. * Loops the value, so that it is never larger than length and never smaller than 0.
  58569. *
  58570. * This is similar to the modulo operator but it works with floating point numbers.
  58571. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  58572. * With t = 5 and length = 2.5, the result would be 0.0.
  58573. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  58574. * @param value the value
  58575. * @param length the length
  58576. * @returns the looped value
  58577. */
  58578. static Repeat(value: number, length: number): number;
  58579. /**
  58580. * Normalize the value between 0.0 and 1.0 using min and max values
  58581. * @param value value to normalize
  58582. * @param min max to normalize between
  58583. * @param max min to normalize between
  58584. * @returns the normalized value
  58585. */
  58586. static Normalize(value: number, min: number, max: number): number;
  58587. /**
  58588. * Denormalize the value from 0.0 and 1.0 using min and max values
  58589. * @param normalized value to denormalize
  58590. * @param min max to denormalize between
  58591. * @param max min to denormalize between
  58592. * @returns the denormalized value
  58593. */
  58594. static Denormalize(normalized: number, min: number, max: number): number;
  58595. /**
  58596. * Calculates the shortest difference between two given angles given in degrees.
  58597. * @param current current angle in degrees
  58598. * @param target target angle in degrees
  58599. * @returns the delta
  58600. */
  58601. static DeltaAngle(current: number, target: number): number;
  58602. /**
  58603. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  58604. * @param tx value
  58605. * @param length length
  58606. * @returns The returned value will move back and forth between 0 and length
  58607. */
  58608. static PingPong(tx: number, length: number): number;
  58609. /**
  58610. * Interpolates between min and max with smoothing at the limits.
  58611. *
  58612. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  58613. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  58614. * @param from from
  58615. * @param to to
  58616. * @param tx value
  58617. * @returns the smooth stepped value
  58618. */
  58619. static SmoothStep(from: number, to: number, tx: number): number;
  58620. /**
  58621. * Moves a value current towards target.
  58622. *
  58623. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  58624. * Negative values of maxDelta pushes the value away from target.
  58625. * @param current current value
  58626. * @param target target value
  58627. * @param maxDelta max distance to move
  58628. * @returns resulting value
  58629. */
  58630. static MoveTowards(current: number, target: number, maxDelta: number): number;
  58631. /**
  58632. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  58633. *
  58634. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  58635. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  58636. * @param current current value
  58637. * @param target target value
  58638. * @param maxDelta max distance to move
  58639. * @returns resulting angle
  58640. */
  58641. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  58642. /**
  58643. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  58644. * @param start start value
  58645. * @param end target value
  58646. * @param amount amount to lerp between
  58647. * @returns the lerped value
  58648. */
  58649. static Lerp(start: number, end: number, amount: number): number;
  58650. /**
  58651. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  58652. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  58653. * @param start start value
  58654. * @param end target value
  58655. * @param amount amount to lerp between
  58656. * @returns the lerped value
  58657. */
  58658. static LerpAngle(start: number, end: number, amount: number): number;
  58659. /**
  58660. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  58661. * @param a start value
  58662. * @param b target value
  58663. * @param value value between a and b
  58664. * @returns the inverseLerp value
  58665. */
  58666. static InverseLerp(a: number, b: number, value: number): number;
  58667. /**
  58668. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  58669. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  58670. * @param value1 spline value
  58671. * @param tangent1 spline value
  58672. * @param value2 spline value
  58673. * @param tangent2 spline value
  58674. * @param amount input value
  58675. * @returns hermite result
  58676. */
  58677. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  58678. /**
  58679. * Returns a random float number between and min and max values
  58680. * @param min min value of random
  58681. * @param max max value of random
  58682. * @returns random value
  58683. */
  58684. static RandomRange(min: number, max: number): number;
  58685. /**
  58686. * This function returns percentage of a number in a given range.
  58687. *
  58688. * RangeToPercent(40,20,60) will return 0.5 (50%)
  58689. * RangeToPercent(34,0,100) will return 0.34 (34%)
  58690. * @param number to convert to percentage
  58691. * @param min min range
  58692. * @param max max range
  58693. * @returns the percentage
  58694. */
  58695. static RangeToPercent(number: number, min: number, max: number): number;
  58696. /**
  58697. * This function returns number that corresponds to the percentage in a given range.
  58698. *
  58699. * PercentToRange(0.34,0,100) will return 34.
  58700. * @param percent to convert to number
  58701. * @param min min range
  58702. * @param max max range
  58703. * @returns the number
  58704. */
  58705. static PercentToRange(percent: number, min: number, max: number): number;
  58706. /**
  58707. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  58708. * @param angle The angle to normalize in radian.
  58709. * @return The converted angle.
  58710. */
  58711. static NormalizeRadians(angle: number): number;
  58712. }
  58713. }
  58714. declare module BABYLON {
  58715. /**
  58716. * Constant used to convert a value to gamma space
  58717. * @ignorenaming
  58718. */
  58719. export const ToGammaSpace: number;
  58720. /**
  58721. * Constant used to convert a value to linear space
  58722. * @ignorenaming
  58723. */
  58724. export const ToLinearSpace = 2.2;
  58725. /**
  58726. * Constant used to define the minimal number value in Babylon.js
  58727. * @ignorenaming
  58728. */
  58729. export const Epsilon = 0.001;
  58730. /**
  58731. * Class used to hold a RBG color
  58732. */
  58733. export class Color3 {
  58734. /**
  58735. * Defines the red component (between 0 and 1, default is 0)
  58736. */
  58737. r: number;
  58738. /**
  58739. * Defines the green component (between 0 and 1, default is 0)
  58740. */
  58741. g: number;
  58742. /**
  58743. * Defines the blue component (between 0 and 1, default is 0)
  58744. */
  58745. b: number;
  58746. /**
  58747. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  58748. * @param r defines the red component (between 0 and 1, default is 0)
  58749. * @param g defines the green component (between 0 and 1, default is 0)
  58750. * @param b defines the blue component (between 0 and 1, default is 0)
  58751. */
  58752. constructor(
  58753. /**
  58754. * Defines the red component (between 0 and 1, default is 0)
  58755. */
  58756. r?: number,
  58757. /**
  58758. * Defines the green component (between 0 and 1, default is 0)
  58759. */
  58760. g?: number,
  58761. /**
  58762. * Defines the blue component (between 0 and 1, default is 0)
  58763. */
  58764. b?: number);
  58765. /**
  58766. * Creates a string with the Color3 current values
  58767. * @returns the string representation of the Color3 object
  58768. */
  58769. toString(): string;
  58770. /**
  58771. * Returns the string "Color3"
  58772. * @returns "Color3"
  58773. */
  58774. getClassName(): string;
  58775. /**
  58776. * Compute the Color3 hash code
  58777. * @returns an unique number that can be used to hash Color3 objects
  58778. */
  58779. getHashCode(): number;
  58780. /**
  58781. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  58782. * @param array defines the array where to store the r,g,b components
  58783. * @param index defines an optional index in the target array to define where to start storing values
  58784. * @returns the current Color3 object
  58785. */
  58786. toArray(array: FloatArray, index?: number): Color3;
  58787. /**
  58788. * Returns a new Color4 object from the current Color3 and the given alpha
  58789. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  58790. * @returns a new Color4 object
  58791. */
  58792. toColor4(alpha?: number): Color4;
  58793. /**
  58794. * Returns a new array populated with 3 numeric elements : red, green and blue values
  58795. * @returns the new array
  58796. */
  58797. asArray(): number[];
  58798. /**
  58799. * Returns the luminance value
  58800. * @returns a float value
  58801. */
  58802. toLuminance(): number;
  58803. /**
  58804. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  58805. * @param otherColor defines the second operand
  58806. * @returns the new Color3 object
  58807. */
  58808. multiply(otherColor: DeepImmutable<Color3>): Color3;
  58809. /**
  58810. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  58811. * @param otherColor defines the second operand
  58812. * @param result defines the Color3 object where to store the result
  58813. * @returns the current Color3
  58814. */
  58815. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  58816. /**
  58817. * Determines equality between Color3 objects
  58818. * @param otherColor defines the second operand
  58819. * @returns true if the rgb values are equal to the given ones
  58820. */
  58821. equals(otherColor: DeepImmutable<Color3>): boolean;
  58822. /**
  58823. * Determines equality between the current Color3 object and a set of r,b,g values
  58824. * @param r defines the red component to check
  58825. * @param g defines the green component to check
  58826. * @param b defines the blue component to check
  58827. * @returns true if the rgb values are equal to the given ones
  58828. */
  58829. equalsFloats(r: number, g: number, b: number): boolean;
  58830. /**
  58831. * Multiplies in place each rgb value by scale
  58832. * @param scale defines the scaling factor
  58833. * @returns the updated Color3
  58834. */
  58835. scale(scale: number): Color3;
  58836. /**
  58837. * Multiplies the rgb values by scale and stores the result into "result"
  58838. * @param scale defines the scaling factor
  58839. * @param result defines the Color3 object where to store the result
  58840. * @returns the unmodified current Color3
  58841. */
  58842. scaleToRef(scale: number, result: Color3): Color3;
  58843. /**
  58844. * Scale the current Color3 values by a factor and add the result to a given Color3
  58845. * @param scale defines the scale factor
  58846. * @param result defines color to store the result into
  58847. * @returns the unmodified current Color3
  58848. */
  58849. scaleAndAddToRef(scale: number, result: Color3): Color3;
  58850. /**
  58851. * Clamps the rgb values by the min and max values and stores the result into "result"
  58852. * @param min defines minimum clamping value (default is 0)
  58853. * @param max defines maximum clamping value (default is 1)
  58854. * @param result defines color to store the result into
  58855. * @returns the original Color3
  58856. */
  58857. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  58858. /**
  58859. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  58860. * @param otherColor defines the second operand
  58861. * @returns the new Color3
  58862. */
  58863. add(otherColor: DeepImmutable<Color3>): Color3;
  58864. /**
  58865. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  58866. * @param otherColor defines the second operand
  58867. * @param result defines Color3 object to store the result into
  58868. * @returns the unmodified current Color3
  58869. */
  58870. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  58871. /**
  58872. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  58873. * @param otherColor defines the second operand
  58874. * @returns the new Color3
  58875. */
  58876. subtract(otherColor: DeepImmutable<Color3>): Color3;
  58877. /**
  58878. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  58879. * @param otherColor defines the second operand
  58880. * @param result defines Color3 object to store the result into
  58881. * @returns the unmodified current Color3
  58882. */
  58883. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  58884. /**
  58885. * Copy the current object
  58886. * @returns a new Color3 copied the current one
  58887. */
  58888. clone(): Color3;
  58889. /**
  58890. * Copies the rgb values from the source in the current Color3
  58891. * @param source defines the source Color3 object
  58892. * @returns the updated Color3 object
  58893. */
  58894. copyFrom(source: DeepImmutable<Color3>): Color3;
  58895. /**
  58896. * Updates the Color3 rgb values from the given floats
  58897. * @param r defines the red component to read from
  58898. * @param g defines the green component to read from
  58899. * @param b defines the blue component to read from
  58900. * @returns the current Color3 object
  58901. */
  58902. copyFromFloats(r: number, g: number, b: number): Color3;
  58903. /**
  58904. * Updates the Color3 rgb values from the given floats
  58905. * @param r defines the red component to read from
  58906. * @param g defines the green component to read from
  58907. * @param b defines the blue component to read from
  58908. * @returns the current Color3 object
  58909. */
  58910. set(r: number, g: number, b: number): Color3;
  58911. /**
  58912. * Compute the Color3 hexadecimal code as a string
  58913. * @returns a string containing the hexadecimal representation of the Color3 object
  58914. */
  58915. toHexString(): string;
  58916. /**
  58917. * Computes a new Color3 converted from the current one to linear space
  58918. * @returns a new Color3 object
  58919. */
  58920. toLinearSpace(): Color3;
  58921. /**
  58922. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  58923. * @param convertedColor defines the Color3 object where to store the linear space version
  58924. * @returns the unmodified Color3
  58925. */
  58926. toLinearSpaceToRef(convertedColor: Color3): Color3;
  58927. /**
  58928. * Computes a new Color3 converted from the current one to gamma space
  58929. * @returns a new Color3 object
  58930. */
  58931. toGammaSpace(): Color3;
  58932. /**
  58933. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  58934. * @param convertedColor defines the Color3 object where to store the gamma space version
  58935. * @returns the unmodified Color3
  58936. */
  58937. toGammaSpaceToRef(convertedColor: Color3): Color3;
  58938. private static _BlackReadOnly;
  58939. /**
  58940. * Creates a new Color3 from the string containing valid hexadecimal values
  58941. * @param hex defines a string containing valid hexadecimal values
  58942. * @returns a new Color3 object
  58943. */
  58944. static FromHexString(hex: string): Color3;
  58945. /**
  58946. * Creates a new Vector3 from the starting index of the given array
  58947. * @param array defines the source array
  58948. * @param offset defines an offset in the source array
  58949. * @returns a new Color3 object
  58950. */
  58951. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  58952. /**
  58953. * Creates a new Color3 from integer values (< 256)
  58954. * @param r defines the red component to read from (value between 0 and 255)
  58955. * @param g defines the green component to read from (value between 0 and 255)
  58956. * @param b defines the blue component to read from (value between 0 and 255)
  58957. * @returns a new Color3 object
  58958. */
  58959. static FromInts(r: number, g: number, b: number): Color3;
  58960. /**
  58961. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  58962. * @param start defines the start Color3 value
  58963. * @param end defines the end Color3 value
  58964. * @param amount defines the gradient value between start and end
  58965. * @returns a new Color3 object
  58966. */
  58967. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  58968. /**
  58969. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  58970. * @param left defines the start value
  58971. * @param right defines the end value
  58972. * @param amount defines the gradient factor
  58973. * @param result defines the Color3 object where to store the result
  58974. */
  58975. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  58976. /**
  58977. * Returns a Color3 value containing a red color
  58978. * @returns a new Color3 object
  58979. */
  58980. static Red(): Color3;
  58981. /**
  58982. * Returns a Color3 value containing a green color
  58983. * @returns a new Color3 object
  58984. */
  58985. static Green(): Color3;
  58986. /**
  58987. * Returns a Color3 value containing a blue color
  58988. * @returns a new Color3 object
  58989. */
  58990. static Blue(): Color3;
  58991. /**
  58992. * Returns a Color3 value containing a black color
  58993. * @returns a new Color3 object
  58994. */
  58995. static Black(): Color3;
  58996. /**
  58997. * Gets a Color3 value containing a black color that must not be updated
  58998. */
  58999. static readonly BlackReadOnly: DeepImmutable<Color3>;
  59000. /**
  59001. * Returns a Color3 value containing a white color
  59002. * @returns a new Color3 object
  59003. */
  59004. static White(): Color3;
  59005. /**
  59006. * Returns a Color3 value containing a purple color
  59007. * @returns a new Color3 object
  59008. */
  59009. static Purple(): Color3;
  59010. /**
  59011. * Returns a Color3 value containing a magenta color
  59012. * @returns a new Color3 object
  59013. */
  59014. static Magenta(): Color3;
  59015. /**
  59016. * Returns a Color3 value containing a yellow color
  59017. * @returns a new Color3 object
  59018. */
  59019. static Yellow(): Color3;
  59020. /**
  59021. * Returns a Color3 value containing a gray color
  59022. * @returns a new Color3 object
  59023. */
  59024. static Gray(): Color3;
  59025. /**
  59026. * Returns a Color3 value containing a teal color
  59027. * @returns a new Color3 object
  59028. */
  59029. static Teal(): Color3;
  59030. /**
  59031. * Returns a Color3 value containing a random color
  59032. * @returns a new Color3 object
  59033. */
  59034. static Random(): Color3;
  59035. }
  59036. /**
  59037. * Class used to hold a RBGA color
  59038. */
  59039. export class Color4 {
  59040. /**
  59041. * Defines the red component (between 0 and 1, default is 0)
  59042. */
  59043. r: number;
  59044. /**
  59045. * Defines the green component (between 0 and 1, default is 0)
  59046. */
  59047. g: number;
  59048. /**
  59049. * Defines the blue component (between 0 and 1, default is 0)
  59050. */
  59051. b: number;
  59052. /**
  59053. * Defines the alpha component (between 0 and 1, default is 1)
  59054. */
  59055. a: number;
  59056. /**
  59057. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  59058. * @param r defines the red component (between 0 and 1, default is 0)
  59059. * @param g defines the green component (between 0 and 1, default is 0)
  59060. * @param b defines the blue component (between 0 and 1, default is 0)
  59061. * @param a defines the alpha component (between 0 and 1, default is 1)
  59062. */
  59063. constructor(
  59064. /**
  59065. * Defines the red component (between 0 and 1, default is 0)
  59066. */
  59067. r?: number,
  59068. /**
  59069. * Defines the green component (between 0 and 1, default is 0)
  59070. */
  59071. g?: number,
  59072. /**
  59073. * Defines the blue component (between 0 and 1, default is 0)
  59074. */
  59075. b?: number,
  59076. /**
  59077. * Defines the alpha component (between 0 and 1, default is 1)
  59078. */
  59079. a?: number);
  59080. /**
  59081. * Adds in place the given Color4 values to the current Color4 object
  59082. * @param right defines the second operand
  59083. * @returns the current updated Color4 object
  59084. */
  59085. addInPlace(right: DeepImmutable<Color4>): Color4;
  59086. /**
  59087. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  59088. * @returns the new array
  59089. */
  59090. asArray(): number[];
  59091. /**
  59092. * Stores from the starting index in the given array the Color4 successive values
  59093. * @param array defines the array where to store the r,g,b components
  59094. * @param index defines an optional index in the target array to define where to start storing values
  59095. * @returns the current Color4 object
  59096. */
  59097. toArray(array: number[], index?: number): Color4;
  59098. /**
  59099. * Determines equality between Color4 objects
  59100. * @param otherColor defines the second operand
  59101. * @returns true if the rgba values are equal to the given ones
  59102. */
  59103. equals(otherColor: DeepImmutable<Color4>): boolean;
  59104. /**
  59105. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  59106. * @param right defines the second operand
  59107. * @returns a new Color4 object
  59108. */
  59109. add(right: DeepImmutable<Color4>): Color4;
  59110. /**
  59111. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  59112. * @param right defines the second operand
  59113. * @returns a new Color4 object
  59114. */
  59115. subtract(right: DeepImmutable<Color4>): Color4;
  59116. /**
  59117. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  59118. * @param right defines the second operand
  59119. * @param result defines the Color4 object where to store the result
  59120. * @returns the current Color4 object
  59121. */
  59122. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  59123. /**
  59124. * Creates a new Color4 with the current Color4 values multiplied by scale
  59125. * @param scale defines the scaling factor to apply
  59126. * @returns a new Color4 object
  59127. */
  59128. scale(scale: number): Color4;
  59129. /**
  59130. * Multiplies the current Color4 values by scale and stores the result in "result"
  59131. * @param scale defines the scaling factor to apply
  59132. * @param result defines the Color4 object where to store the result
  59133. * @returns the current unmodified Color4
  59134. */
  59135. scaleToRef(scale: number, result: Color4): Color4;
  59136. /**
  59137. * Scale the current Color4 values by a factor and add the result to a given Color4
  59138. * @param scale defines the scale factor
  59139. * @param result defines the Color4 object where to store the result
  59140. * @returns the unmodified current Color4
  59141. */
  59142. scaleAndAddToRef(scale: number, result: Color4): Color4;
  59143. /**
  59144. * Clamps the rgb values by the min and max values and stores the result into "result"
  59145. * @param min defines minimum clamping value (default is 0)
  59146. * @param max defines maximum clamping value (default is 1)
  59147. * @param result defines color to store the result into.
  59148. * @returns the cuurent Color4
  59149. */
  59150. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  59151. /**
  59152. * Multipy an Color4 value by another and return a new Color4 object
  59153. * @param color defines the Color4 value to multiply by
  59154. * @returns a new Color4 object
  59155. */
  59156. multiply(color: Color4): Color4;
  59157. /**
  59158. * Multipy a Color4 value by another and push the result in a reference value
  59159. * @param color defines the Color4 value to multiply by
  59160. * @param result defines the Color4 to fill the result in
  59161. * @returns the result Color4
  59162. */
  59163. multiplyToRef(color: Color4, result: Color4): Color4;
  59164. /**
  59165. * Creates a string with the Color4 current values
  59166. * @returns the string representation of the Color4 object
  59167. */
  59168. toString(): string;
  59169. /**
  59170. * Returns the string "Color4"
  59171. * @returns "Color4"
  59172. */
  59173. getClassName(): string;
  59174. /**
  59175. * Compute the Color4 hash code
  59176. * @returns an unique number that can be used to hash Color4 objects
  59177. */
  59178. getHashCode(): number;
  59179. /**
  59180. * Creates a new Color4 copied from the current one
  59181. * @returns a new Color4 object
  59182. */
  59183. clone(): Color4;
  59184. /**
  59185. * Copies the given Color4 values into the current one
  59186. * @param source defines the source Color4 object
  59187. * @returns the current updated Color4 object
  59188. */
  59189. copyFrom(source: Color4): Color4;
  59190. /**
  59191. * Copies the given float values into the current one
  59192. * @param r defines the red component to read from
  59193. * @param g defines the green component to read from
  59194. * @param b defines the blue component to read from
  59195. * @param a defines the alpha component to read from
  59196. * @returns the current updated Color4 object
  59197. */
  59198. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  59199. /**
  59200. * Copies the given float values into the current one
  59201. * @param r defines the red component to read from
  59202. * @param g defines the green component to read from
  59203. * @param b defines the blue component to read from
  59204. * @param a defines the alpha component to read from
  59205. * @returns the current updated Color4 object
  59206. */
  59207. set(r: number, g: number, b: number, a: number): Color4;
  59208. /**
  59209. * Compute the Color4 hexadecimal code as a string
  59210. * @returns a string containing the hexadecimal representation of the Color4 object
  59211. */
  59212. toHexString(): string;
  59213. /**
  59214. * Computes a new Color4 converted from the current one to linear space
  59215. * @returns a new Color4 object
  59216. */
  59217. toLinearSpace(): Color4;
  59218. /**
  59219. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  59220. * @param convertedColor defines the Color4 object where to store the linear space version
  59221. * @returns the unmodified Color4
  59222. */
  59223. toLinearSpaceToRef(convertedColor: Color4): Color4;
  59224. /**
  59225. * Computes a new Color4 converted from the current one to gamma space
  59226. * @returns a new Color4 object
  59227. */
  59228. toGammaSpace(): Color4;
  59229. /**
  59230. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  59231. * @param convertedColor defines the Color4 object where to store the gamma space version
  59232. * @returns the unmodified Color4
  59233. */
  59234. toGammaSpaceToRef(convertedColor: Color4): Color4;
  59235. /**
  59236. * Creates a new Color4 from the string containing valid hexadecimal values
  59237. * @param hex defines a string containing valid hexadecimal values
  59238. * @returns a new Color4 object
  59239. */
  59240. static FromHexString(hex: string): Color4;
  59241. /**
  59242. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  59243. * @param left defines the start value
  59244. * @param right defines the end value
  59245. * @param amount defines the gradient factor
  59246. * @returns a new Color4 object
  59247. */
  59248. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  59249. /**
  59250. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  59251. * @param left defines the start value
  59252. * @param right defines the end value
  59253. * @param amount defines the gradient factor
  59254. * @param result defines the Color4 object where to store data
  59255. */
  59256. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  59257. /**
  59258. * Creates a new Color4 from a Color3 and an alpha value
  59259. * @param color3 defines the source Color3 to read from
  59260. * @param alpha defines the alpha component (1.0 by default)
  59261. * @returns a new Color4 object
  59262. */
  59263. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  59264. /**
  59265. * Creates a new Color4 from the starting index element of the given array
  59266. * @param array defines the source array to read from
  59267. * @param offset defines the offset in the source array
  59268. * @returns a new Color4 object
  59269. */
  59270. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  59271. /**
  59272. * Creates a new Color3 from integer values (< 256)
  59273. * @param r defines the red component to read from (value between 0 and 255)
  59274. * @param g defines the green component to read from (value between 0 and 255)
  59275. * @param b defines the blue component to read from (value between 0 and 255)
  59276. * @param a defines the alpha component to read from (value between 0 and 255)
  59277. * @returns a new Color3 object
  59278. */
  59279. static FromInts(r: number, g: number, b: number, a: number): Color4;
  59280. /**
  59281. * Check the content of a given array and convert it to an array containing RGBA data
  59282. * If the original array was already containing count * 4 values then it is returned directly
  59283. * @param colors defines the array to check
  59284. * @param count defines the number of RGBA data to expect
  59285. * @returns an array containing count * 4 values (RGBA)
  59286. */
  59287. static CheckColors4(colors: number[], count: number): number[];
  59288. }
  59289. /**
  59290. * Class representing a vector containing 2 coordinates
  59291. */
  59292. export class Vector2 {
  59293. /** defines the first coordinate */
  59294. x: number;
  59295. /** defines the second coordinate */
  59296. y: number;
  59297. /**
  59298. * Creates a new Vector2 from the given x and y coordinates
  59299. * @param x defines the first coordinate
  59300. * @param y defines the second coordinate
  59301. */
  59302. constructor(
  59303. /** defines the first coordinate */
  59304. x?: number,
  59305. /** defines the second coordinate */
  59306. y?: number);
  59307. /**
  59308. * Gets a string with the Vector2 coordinates
  59309. * @returns a string with the Vector2 coordinates
  59310. */
  59311. toString(): string;
  59312. /**
  59313. * Gets class name
  59314. * @returns the string "Vector2"
  59315. */
  59316. getClassName(): string;
  59317. /**
  59318. * Gets current vector hash code
  59319. * @returns the Vector2 hash code as a number
  59320. */
  59321. getHashCode(): number;
  59322. /**
  59323. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  59324. * @param array defines the source array
  59325. * @param index defines the offset in source array
  59326. * @returns the current Vector2
  59327. */
  59328. toArray(array: FloatArray, index?: number): Vector2;
  59329. /**
  59330. * Copy the current vector to an array
  59331. * @returns a new array with 2 elements: the Vector2 coordinates.
  59332. */
  59333. asArray(): number[];
  59334. /**
  59335. * Sets the Vector2 coordinates with the given Vector2 coordinates
  59336. * @param source defines the source Vector2
  59337. * @returns the current updated Vector2
  59338. */
  59339. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  59340. /**
  59341. * Sets the Vector2 coordinates with the given floats
  59342. * @param x defines the first coordinate
  59343. * @param y defines the second coordinate
  59344. * @returns the current updated Vector2
  59345. */
  59346. copyFromFloats(x: number, y: number): Vector2;
  59347. /**
  59348. * Sets the Vector2 coordinates with the given floats
  59349. * @param x defines the first coordinate
  59350. * @param y defines the second coordinate
  59351. * @returns the current updated Vector2
  59352. */
  59353. set(x: number, y: number): Vector2;
  59354. /**
  59355. * Add another vector with the current one
  59356. * @param otherVector defines the other vector
  59357. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  59358. */
  59359. add(otherVector: DeepImmutable<Vector2>): Vector2;
  59360. /**
  59361. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  59362. * @param otherVector defines the other vector
  59363. * @param result defines the target vector
  59364. * @returns the unmodified current Vector2
  59365. */
  59366. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  59367. /**
  59368. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  59369. * @param otherVector defines the other vector
  59370. * @returns the current updated Vector2
  59371. */
  59372. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  59373. /**
  59374. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  59375. * @param otherVector defines the other vector
  59376. * @returns a new Vector2
  59377. */
  59378. addVector3(otherVector: Vector3): Vector2;
  59379. /**
  59380. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  59381. * @param otherVector defines the other vector
  59382. * @returns a new Vector2
  59383. */
  59384. subtract(otherVector: Vector2): Vector2;
  59385. /**
  59386. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  59387. * @param otherVector defines the other vector
  59388. * @param result defines the target vector
  59389. * @returns the unmodified current Vector2
  59390. */
  59391. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  59392. /**
  59393. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  59394. * @param otherVector defines the other vector
  59395. * @returns the current updated Vector2
  59396. */
  59397. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  59398. /**
  59399. * Multiplies in place the current Vector2 coordinates by the given ones
  59400. * @param otherVector defines the other vector
  59401. * @returns the current updated Vector2
  59402. */
  59403. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  59404. /**
  59405. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  59406. * @param otherVector defines the other vector
  59407. * @returns a new Vector2
  59408. */
  59409. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  59410. /**
  59411. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  59412. * @param otherVector defines the other vector
  59413. * @param result defines the target vector
  59414. * @returns the unmodified current Vector2
  59415. */
  59416. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  59417. /**
  59418. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  59419. * @param x defines the first coordinate
  59420. * @param y defines the second coordinate
  59421. * @returns a new Vector2
  59422. */
  59423. multiplyByFloats(x: number, y: number): Vector2;
  59424. /**
  59425. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  59426. * @param otherVector defines the other vector
  59427. * @returns a new Vector2
  59428. */
  59429. divide(otherVector: Vector2): Vector2;
  59430. /**
  59431. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  59432. * @param otherVector defines the other vector
  59433. * @param result defines the target vector
  59434. * @returns the unmodified current Vector2
  59435. */
  59436. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  59437. /**
  59438. * Divides the current Vector2 coordinates by the given ones
  59439. * @param otherVector defines the other vector
  59440. * @returns the current updated Vector2
  59441. */
  59442. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  59443. /**
  59444. * Gets a new Vector2 with current Vector2 negated coordinates
  59445. * @returns a new Vector2
  59446. */
  59447. negate(): Vector2;
  59448. /**
  59449. * Multiply the Vector2 coordinates by scale
  59450. * @param scale defines the scaling factor
  59451. * @returns the current updated Vector2
  59452. */
  59453. scaleInPlace(scale: number): Vector2;
  59454. /**
  59455. * Returns a new Vector2 scaled by "scale" from the current Vector2
  59456. * @param scale defines the scaling factor
  59457. * @returns a new Vector2
  59458. */
  59459. scale(scale: number): Vector2;
  59460. /**
  59461. * Scale the current Vector2 values by a factor to a given Vector2
  59462. * @param scale defines the scale factor
  59463. * @param result defines the Vector2 object where to store the result
  59464. * @returns the unmodified current Vector2
  59465. */
  59466. scaleToRef(scale: number, result: Vector2): Vector2;
  59467. /**
  59468. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  59469. * @param scale defines the scale factor
  59470. * @param result defines the Vector2 object where to store the result
  59471. * @returns the unmodified current Vector2
  59472. */
  59473. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  59474. /**
  59475. * Gets a boolean if two vectors are equals
  59476. * @param otherVector defines the other vector
  59477. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  59478. */
  59479. equals(otherVector: DeepImmutable<Vector2>): boolean;
  59480. /**
  59481. * Gets a boolean if two vectors are equals (using an epsilon value)
  59482. * @param otherVector defines the other vector
  59483. * @param epsilon defines the minimal distance to consider equality
  59484. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  59485. */
  59486. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  59487. /**
  59488. * Gets a new Vector2 from current Vector2 floored values
  59489. * @returns a new Vector2
  59490. */
  59491. floor(): Vector2;
  59492. /**
  59493. * Gets a new Vector2 from current Vector2 floored values
  59494. * @returns a new Vector2
  59495. */
  59496. fract(): Vector2;
  59497. /**
  59498. * Gets the length of the vector
  59499. * @returns the vector length (float)
  59500. */
  59501. length(): number;
  59502. /**
  59503. * Gets the vector squared length
  59504. * @returns the vector squared length (float)
  59505. */
  59506. lengthSquared(): number;
  59507. /**
  59508. * Normalize the vector
  59509. * @returns the current updated Vector2
  59510. */
  59511. normalize(): Vector2;
  59512. /**
  59513. * Gets a new Vector2 copied from the Vector2
  59514. * @returns a new Vector2
  59515. */
  59516. clone(): Vector2;
  59517. /**
  59518. * Gets a new Vector2(0, 0)
  59519. * @returns a new Vector2
  59520. */
  59521. static Zero(): Vector2;
  59522. /**
  59523. * Gets a new Vector2(1, 1)
  59524. * @returns a new Vector2
  59525. */
  59526. static One(): Vector2;
  59527. /**
  59528. * Gets a new Vector2 set from the given index element of the given array
  59529. * @param array defines the data source
  59530. * @param offset defines the offset in the data source
  59531. * @returns a new Vector2
  59532. */
  59533. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  59534. /**
  59535. * Sets "result" from the given index element of the given array
  59536. * @param array defines the data source
  59537. * @param offset defines the offset in the data source
  59538. * @param result defines the target vector
  59539. */
  59540. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  59541. /**
  59542. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  59543. * @param value1 defines 1st point of control
  59544. * @param value2 defines 2nd point of control
  59545. * @param value3 defines 3rd point of control
  59546. * @param value4 defines 4th point of control
  59547. * @param amount defines the interpolation factor
  59548. * @returns a new Vector2
  59549. */
  59550. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  59551. /**
  59552. * 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".
  59553. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  59554. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  59555. * @param value defines the value to clamp
  59556. * @param min defines the lower limit
  59557. * @param max defines the upper limit
  59558. * @returns a new Vector2
  59559. */
  59560. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  59561. /**
  59562. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  59563. * @param value1 defines the 1st control point
  59564. * @param tangent1 defines the outgoing tangent
  59565. * @param value2 defines the 2nd control point
  59566. * @param tangent2 defines the incoming tangent
  59567. * @param amount defines the interpolation factor
  59568. * @returns a new Vector2
  59569. */
  59570. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  59571. /**
  59572. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  59573. * @param start defines the start vector
  59574. * @param end defines the end vector
  59575. * @param amount defines the interpolation factor
  59576. * @returns a new Vector2
  59577. */
  59578. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  59579. /**
  59580. * Gets the dot product of the vector "left" and the vector "right"
  59581. * @param left defines first vector
  59582. * @param right defines second vector
  59583. * @returns the dot product (float)
  59584. */
  59585. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  59586. /**
  59587. * Returns a new Vector2 equal to the normalized given vector
  59588. * @param vector defines the vector to normalize
  59589. * @returns a new Vector2
  59590. */
  59591. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  59592. /**
  59593. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  59594. * @param left defines 1st vector
  59595. * @param right defines 2nd vector
  59596. * @returns a new Vector2
  59597. */
  59598. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  59599. /**
  59600. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  59601. * @param left defines 1st vector
  59602. * @param right defines 2nd vector
  59603. * @returns a new Vector2
  59604. */
  59605. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  59606. /**
  59607. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  59608. * @param vector defines the vector to transform
  59609. * @param transformation defines the matrix to apply
  59610. * @returns a new Vector2
  59611. */
  59612. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  59613. /**
  59614. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  59615. * @param vector defines the vector to transform
  59616. * @param transformation defines the matrix to apply
  59617. * @param result defines the target vector
  59618. */
  59619. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  59620. /**
  59621. * Determines if a given vector is included in a triangle
  59622. * @param p defines the vector to test
  59623. * @param p0 defines 1st triangle point
  59624. * @param p1 defines 2nd triangle point
  59625. * @param p2 defines 3rd triangle point
  59626. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  59627. */
  59628. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  59629. /**
  59630. * Gets the distance between the vectors "value1" and "value2"
  59631. * @param value1 defines first vector
  59632. * @param value2 defines second vector
  59633. * @returns the distance between vectors
  59634. */
  59635. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  59636. /**
  59637. * Returns the squared distance between the vectors "value1" and "value2"
  59638. * @param value1 defines first vector
  59639. * @param value2 defines second vector
  59640. * @returns the squared distance between vectors
  59641. */
  59642. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  59643. /**
  59644. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  59645. * @param value1 defines first vector
  59646. * @param value2 defines second vector
  59647. * @returns a new Vector2
  59648. */
  59649. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  59650. /**
  59651. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  59652. * @param p defines the middle point
  59653. * @param segA defines one point of the segment
  59654. * @param segB defines the other point of the segment
  59655. * @returns the shortest distance
  59656. */
  59657. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  59658. }
  59659. /**
  59660. * Classed used to store (x,y,z) vector representation
  59661. * A Vector3 is the main object used in 3D geometry
  59662. * It can represent etiher the coordinates of a point the space, either a direction
  59663. * Reminder: js uses a left handed forward facing system
  59664. */
  59665. export class Vector3 {
  59666. /**
  59667. * Defines the first coordinates (on X axis)
  59668. */
  59669. x: number;
  59670. /**
  59671. * Defines the second coordinates (on Y axis)
  59672. */
  59673. y: number;
  59674. /**
  59675. * Defines the third coordinates (on Z axis)
  59676. */
  59677. z: number;
  59678. private static _UpReadOnly;
  59679. /**
  59680. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  59681. * @param x defines the first coordinates (on X axis)
  59682. * @param y defines the second coordinates (on Y axis)
  59683. * @param z defines the third coordinates (on Z axis)
  59684. */
  59685. constructor(
  59686. /**
  59687. * Defines the first coordinates (on X axis)
  59688. */
  59689. x?: number,
  59690. /**
  59691. * Defines the second coordinates (on Y axis)
  59692. */
  59693. y?: number,
  59694. /**
  59695. * Defines the third coordinates (on Z axis)
  59696. */
  59697. z?: number);
  59698. /**
  59699. * Creates a string representation of the Vector3
  59700. * @returns a string with the Vector3 coordinates.
  59701. */
  59702. toString(): string;
  59703. /**
  59704. * Gets the class name
  59705. * @returns the string "Vector3"
  59706. */
  59707. getClassName(): string;
  59708. /**
  59709. * Creates the Vector3 hash code
  59710. * @returns a number which tends to be unique between Vector3 instances
  59711. */
  59712. getHashCode(): number;
  59713. /**
  59714. * Creates an array containing three elements : the coordinates of the Vector3
  59715. * @returns a new array of numbers
  59716. */
  59717. asArray(): number[];
  59718. /**
  59719. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  59720. * @param array defines the destination array
  59721. * @param index defines the offset in the destination array
  59722. * @returns the current Vector3
  59723. */
  59724. toArray(array: FloatArray, index?: number): Vector3;
  59725. /**
  59726. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  59727. * @returns a new Quaternion object, computed from the Vector3 coordinates
  59728. */
  59729. toQuaternion(): Quaternion;
  59730. /**
  59731. * Adds the given vector to the current Vector3
  59732. * @param otherVector defines the second operand
  59733. * @returns the current updated Vector3
  59734. */
  59735. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  59736. /**
  59737. * Adds the given coordinates to the current Vector3
  59738. * @param x defines the x coordinate of the operand
  59739. * @param y defines the y coordinate of the operand
  59740. * @param z defines the z coordinate of the operand
  59741. * @returns the current updated Vector3
  59742. */
  59743. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  59744. /**
  59745. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  59746. * @param otherVector defines the second operand
  59747. * @returns the resulting Vector3
  59748. */
  59749. add(otherVector: DeepImmutable<Vector3>): Vector3;
  59750. /**
  59751. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  59752. * @param otherVector defines the second operand
  59753. * @param result defines the Vector3 object where to store the result
  59754. * @returns the current Vector3
  59755. */
  59756. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59757. /**
  59758. * Subtract the given vector from the current Vector3
  59759. * @param otherVector defines the second operand
  59760. * @returns the current updated Vector3
  59761. */
  59762. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  59763. /**
  59764. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  59765. * @param otherVector defines the second operand
  59766. * @returns the resulting Vector3
  59767. */
  59768. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  59769. /**
  59770. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  59771. * @param otherVector defines the second operand
  59772. * @param result defines the Vector3 object where to store the result
  59773. * @returns the current Vector3
  59774. */
  59775. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59776. /**
  59777. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  59778. * @param x defines the x coordinate of the operand
  59779. * @param y defines the y coordinate of the operand
  59780. * @param z defines the z coordinate of the operand
  59781. * @returns the resulting Vector3
  59782. */
  59783. subtractFromFloats(x: number, y: number, z: number): Vector3;
  59784. /**
  59785. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  59786. * @param x defines the x coordinate of the operand
  59787. * @param y defines the y coordinate of the operand
  59788. * @param z defines the z coordinate of the operand
  59789. * @param result defines the Vector3 object where to store the result
  59790. * @returns the current Vector3
  59791. */
  59792. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  59793. /**
  59794. * Gets a new Vector3 set with the current Vector3 negated coordinates
  59795. * @returns a new Vector3
  59796. */
  59797. negate(): Vector3;
  59798. /**
  59799. * Multiplies the Vector3 coordinates by the float "scale"
  59800. * @param scale defines the multiplier factor
  59801. * @returns the current updated Vector3
  59802. */
  59803. scaleInPlace(scale: number): Vector3;
  59804. /**
  59805. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  59806. * @param scale defines the multiplier factor
  59807. * @returns a new Vector3
  59808. */
  59809. scale(scale: number): Vector3;
  59810. /**
  59811. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  59812. * @param scale defines the multiplier factor
  59813. * @param result defines the Vector3 object where to store the result
  59814. * @returns the current Vector3
  59815. */
  59816. scaleToRef(scale: number, result: Vector3): Vector3;
  59817. /**
  59818. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  59819. * @param scale defines the scale factor
  59820. * @param result defines the Vector3 object where to store the result
  59821. * @returns the unmodified current Vector3
  59822. */
  59823. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  59824. /**
  59825. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  59826. * @param otherVector defines the second operand
  59827. * @returns true if both vectors are equals
  59828. */
  59829. equals(otherVector: DeepImmutable<Vector3>): boolean;
  59830. /**
  59831. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  59832. * @param otherVector defines the second operand
  59833. * @param epsilon defines the minimal distance to define values as equals
  59834. * @returns true if both vectors are distant less than epsilon
  59835. */
  59836. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  59837. /**
  59838. * Returns true if the current Vector3 coordinates equals the given floats
  59839. * @param x defines the x coordinate of the operand
  59840. * @param y defines the y coordinate of the operand
  59841. * @param z defines the z coordinate of the operand
  59842. * @returns true if both vectors are equals
  59843. */
  59844. equalsToFloats(x: number, y: number, z: number): boolean;
  59845. /**
  59846. * Multiplies the current Vector3 coordinates by the given ones
  59847. * @param otherVector defines the second operand
  59848. * @returns the current updated Vector3
  59849. */
  59850. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  59851. /**
  59852. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  59853. * @param otherVector defines the second operand
  59854. * @returns the new Vector3
  59855. */
  59856. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  59857. /**
  59858. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  59859. * @param otherVector defines the second operand
  59860. * @param result defines the Vector3 object where to store the result
  59861. * @returns the current Vector3
  59862. */
  59863. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59864. /**
  59865. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  59866. * @param x defines the x coordinate of the operand
  59867. * @param y defines the y coordinate of the operand
  59868. * @param z defines the z coordinate of the operand
  59869. * @returns the new Vector3
  59870. */
  59871. multiplyByFloats(x: number, y: number, z: number): Vector3;
  59872. /**
  59873. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  59874. * @param otherVector defines the second operand
  59875. * @returns the new Vector3
  59876. */
  59877. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  59878. /**
  59879. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  59880. * @param otherVector defines the second operand
  59881. * @param result defines the Vector3 object where to store the result
  59882. * @returns the current Vector3
  59883. */
  59884. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59885. /**
  59886. * Divides the current Vector3 coordinates by the given ones.
  59887. * @param otherVector defines the second operand
  59888. * @returns the current updated Vector3
  59889. */
  59890. divideInPlace(otherVector: Vector3): Vector3;
  59891. /**
  59892. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  59893. * @param other defines the second operand
  59894. * @returns the current updated Vector3
  59895. */
  59896. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  59897. /**
  59898. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  59899. * @param other defines the second operand
  59900. * @returns the current updated Vector3
  59901. */
  59902. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  59903. /**
  59904. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  59905. * @param x defines the x coordinate of the operand
  59906. * @param y defines the y coordinate of the operand
  59907. * @param z defines the z coordinate of the operand
  59908. * @returns the current updated Vector3
  59909. */
  59910. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  59911. /**
  59912. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  59913. * @param x defines the x coordinate of the operand
  59914. * @param y defines the y coordinate of the operand
  59915. * @param z defines the z coordinate of the operand
  59916. * @returns the current updated Vector3
  59917. */
  59918. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  59919. /**
  59920. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  59921. * Check if is non uniform within a certain amount of decimal places to account for this
  59922. * @param epsilon the amount the values can differ
  59923. * @returns if the the vector is non uniform to a certain number of decimal places
  59924. */
  59925. isNonUniformWithinEpsilon(epsilon: number): boolean;
  59926. /**
  59927. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  59928. */
  59929. readonly isNonUniform: boolean;
  59930. /**
  59931. * Gets a new Vector3 from current Vector3 floored values
  59932. * @returns a new Vector3
  59933. */
  59934. floor(): Vector3;
  59935. /**
  59936. * Gets a new Vector3 from current Vector3 floored values
  59937. * @returns a new Vector3
  59938. */
  59939. fract(): Vector3;
  59940. /**
  59941. * Gets the length of the Vector3
  59942. * @returns the length of the Vecto3
  59943. */
  59944. length(): number;
  59945. /**
  59946. * Gets the squared length of the Vector3
  59947. * @returns squared length of the Vector3
  59948. */
  59949. lengthSquared(): number;
  59950. /**
  59951. * Normalize the current Vector3.
  59952. * Please note that this is an in place operation.
  59953. * @returns the current updated Vector3
  59954. */
  59955. normalize(): Vector3;
  59956. /**
  59957. * Reorders the x y z properties of the vector in place
  59958. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  59959. * @returns the current updated vector
  59960. */
  59961. reorderInPlace(order: string): this;
  59962. /**
  59963. * Rotates the vector around 0,0,0 by a quaternion
  59964. * @param quaternion the rotation quaternion
  59965. * @param result vector to store the result
  59966. * @returns the resulting vector
  59967. */
  59968. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  59969. /**
  59970. * Rotates a vector around a given point
  59971. * @param quaternion the rotation quaternion
  59972. * @param point the point to rotate around
  59973. * @param result vector to store the result
  59974. * @returns the resulting vector
  59975. */
  59976. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  59977. /**
  59978. * Normalize the current Vector3 with the given input length.
  59979. * Please note that this is an in place operation.
  59980. * @param len the length of the vector
  59981. * @returns the current updated Vector3
  59982. */
  59983. normalizeFromLength(len: number): Vector3;
  59984. /**
  59985. * Normalize the current Vector3 to a new vector
  59986. * @returns the new Vector3
  59987. */
  59988. normalizeToNew(): Vector3;
  59989. /**
  59990. * Normalize the current Vector3 to the reference
  59991. * @param reference define the Vector3 to update
  59992. * @returns the updated Vector3
  59993. */
  59994. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  59995. /**
  59996. * Creates a new Vector3 copied from the current Vector3
  59997. * @returns the new Vector3
  59998. */
  59999. clone(): Vector3;
  60000. /**
  60001. * Copies the given vector coordinates to the current Vector3 ones
  60002. * @param source defines the source Vector3
  60003. * @returns the current updated Vector3
  60004. */
  60005. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  60006. /**
  60007. * Copies the given floats to the current Vector3 coordinates
  60008. * @param x defines the x coordinate of the operand
  60009. * @param y defines the y coordinate of the operand
  60010. * @param z defines the z coordinate of the operand
  60011. * @returns the current updated Vector3
  60012. */
  60013. copyFromFloats(x: number, y: number, z: number): Vector3;
  60014. /**
  60015. * Copies the given floats to the current Vector3 coordinates
  60016. * @param x defines the x coordinate of the operand
  60017. * @param y defines the y coordinate of the operand
  60018. * @param z defines the z coordinate of the operand
  60019. * @returns the current updated Vector3
  60020. */
  60021. set(x: number, y: number, z: number): Vector3;
  60022. /**
  60023. * Copies the given float to the current Vector3 coordinates
  60024. * @param v defines the x, y and z coordinates of the operand
  60025. * @returns the current updated Vector3
  60026. */
  60027. setAll(v: number): Vector3;
  60028. /**
  60029. * Get the clip factor between two vectors
  60030. * @param vector0 defines the first operand
  60031. * @param vector1 defines the second operand
  60032. * @param axis defines the axis to use
  60033. * @param size defines the size along the axis
  60034. * @returns the clip factor
  60035. */
  60036. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  60037. /**
  60038. * Get angle between two vectors
  60039. * @param vector0 angle between vector0 and vector1
  60040. * @param vector1 angle between vector0 and vector1
  60041. * @param normal direction of the normal
  60042. * @return the angle between vector0 and vector1
  60043. */
  60044. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  60045. /**
  60046. * Returns a new Vector3 set from the index "offset" of the given array
  60047. * @param array defines the source array
  60048. * @param offset defines the offset in the source array
  60049. * @returns the new Vector3
  60050. */
  60051. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  60052. /**
  60053. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  60054. * This function is deprecated. Use FromArray instead
  60055. * @param array defines the source array
  60056. * @param offset defines the offset in the source array
  60057. * @returns the new Vector3
  60058. */
  60059. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  60060. /**
  60061. * Sets the given vector "result" with the element values from the index "offset" of the given array
  60062. * @param array defines the source array
  60063. * @param offset defines the offset in the source array
  60064. * @param result defines the Vector3 where to store the result
  60065. */
  60066. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  60067. /**
  60068. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  60069. * This function is deprecated. Use FromArrayToRef instead.
  60070. * @param array defines the source array
  60071. * @param offset defines the offset in the source array
  60072. * @param result defines the Vector3 where to store the result
  60073. */
  60074. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  60075. /**
  60076. * Sets the given vector "result" with the given floats.
  60077. * @param x defines the x coordinate of the source
  60078. * @param y defines the y coordinate of the source
  60079. * @param z defines the z coordinate of the source
  60080. * @param result defines the Vector3 where to store the result
  60081. */
  60082. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  60083. /**
  60084. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  60085. * @returns a new empty Vector3
  60086. */
  60087. static Zero(): Vector3;
  60088. /**
  60089. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  60090. * @returns a new unit Vector3
  60091. */
  60092. static One(): Vector3;
  60093. /**
  60094. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  60095. * @returns a new up Vector3
  60096. */
  60097. static Up(): Vector3;
  60098. /**
  60099. * Gets a up Vector3 that must not be updated
  60100. */
  60101. static readonly UpReadOnly: DeepImmutable<Vector3>;
  60102. /**
  60103. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  60104. * @returns a new down Vector3
  60105. */
  60106. static Down(): Vector3;
  60107. /**
  60108. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  60109. * @returns a new forward Vector3
  60110. */
  60111. static Forward(): Vector3;
  60112. /**
  60113. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  60114. * @returns a new forward Vector3
  60115. */
  60116. static Backward(): Vector3;
  60117. /**
  60118. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  60119. * @returns a new right Vector3
  60120. */
  60121. static Right(): Vector3;
  60122. /**
  60123. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  60124. * @returns a new left Vector3
  60125. */
  60126. static Left(): Vector3;
  60127. /**
  60128. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  60129. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  60130. * @param vector defines the Vector3 to transform
  60131. * @param transformation defines the transformation matrix
  60132. * @returns the transformed Vector3
  60133. */
  60134. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  60135. /**
  60136. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  60137. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  60138. * @param vector defines the Vector3 to transform
  60139. * @param transformation defines the transformation matrix
  60140. * @param result defines the Vector3 where to store the result
  60141. */
  60142. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  60143. /**
  60144. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  60145. * This method computes tranformed coordinates only, not transformed direction vectors
  60146. * @param x define the x coordinate of the source vector
  60147. * @param y define the y coordinate of the source vector
  60148. * @param z define the z coordinate of the source vector
  60149. * @param transformation defines the transformation matrix
  60150. * @param result defines the Vector3 where to store the result
  60151. */
  60152. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  60153. /**
  60154. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  60155. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  60156. * @param vector defines the Vector3 to transform
  60157. * @param transformation defines the transformation matrix
  60158. * @returns the new Vector3
  60159. */
  60160. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  60161. /**
  60162. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  60163. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  60164. * @param vector defines the Vector3 to transform
  60165. * @param transformation defines the transformation matrix
  60166. * @param result defines the Vector3 where to store the result
  60167. */
  60168. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  60169. /**
  60170. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  60171. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  60172. * @param x define the x coordinate of the source vector
  60173. * @param y define the y coordinate of the source vector
  60174. * @param z define the z coordinate of the source vector
  60175. * @param transformation defines the transformation matrix
  60176. * @param result defines the Vector3 where to store the result
  60177. */
  60178. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  60179. /**
  60180. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  60181. * @param value1 defines the first control point
  60182. * @param value2 defines the second control point
  60183. * @param value3 defines the third control point
  60184. * @param value4 defines the fourth control point
  60185. * @param amount defines the amount on the spline to use
  60186. * @returns the new Vector3
  60187. */
  60188. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  60189. /**
  60190. * 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"
  60191. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  60192. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  60193. * @param value defines the current value
  60194. * @param min defines the lower range value
  60195. * @param max defines the upper range value
  60196. * @returns the new Vector3
  60197. */
  60198. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  60199. /**
  60200. * 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"
  60201. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  60202. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  60203. * @param value defines the current value
  60204. * @param min defines the lower range value
  60205. * @param max defines the upper range value
  60206. * @param result defines the Vector3 where to store the result
  60207. */
  60208. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  60209. /**
  60210. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  60211. * @param value1 defines the first control point
  60212. * @param tangent1 defines the first tangent vector
  60213. * @param value2 defines the second control point
  60214. * @param tangent2 defines the second tangent vector
  60215. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  60216. * @returns the new Vector3
  60217. */
  60218. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  60219. /**
  60220. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  60221. * @param start defines the start value
  60222. * @param end defines the end value
  60223. * @param amount max defines amount between both (between 0 and 1)
  60224. * @returns the new Vector3
  60225. */
  60226. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  60227. /**
  60228. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  60229. * @param start defines the start value
  60230. * @param end defines the end value
  60231. * @param amount max defines amount between both (between 0 and 1)
  60232. * @param result defines the Vector3 where to store the result
  60233. */
  60234. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  60235. /**
  60236. * Returns the dot product (float) between the vectors "left" and "right"
  60237. * @param left defines the left operand
  60238. * @param right defines the right operand
  60239. * @returns the dot product
  60240. */
  60241. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  60242. /**
  60243. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  60244. * The cross product is then orthogonal to both "left" and "right"
  60245. * @param left defines the left operand
  60246. * @param right defines the right operand
  60247. * @returns the cross product
  60248. */
  60249. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  60250. /**
  60251. * Sets the given vector "result" with the cross product of "left" and "right"
  60252. * The cross product is then orthogonal to both "left" and "right"
  60253. * @param left defines the left operand
  60254. * @param right defines the right operand
  60255. * @param result defines the Vector3 where to store the result
  60256. */
  60257. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  60258. /**
  60259. * Returns a new Vector3 as the normalization of the given vector
  60260. * @param vector defines the Vector3 to normalize
  60261. * @returns the new Vector3
  60262. */
  60263. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  60264. /**
  60265. * Sets the given vector "result" with the normalization of the given first vector
  60266. * @param vector defines the Vector3 to normalize
  60267. * @param result defines the Vector3 where to store the result
  60268. */
  60269. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  60270. /**
  60271. * Project a Vector3 onto screen space
  60272. * @param vector defines the Vector3 to project
  60273. * @param world defines the world matrix to use
  60274. * @param transform defines the transform (view x projection) matrix to use
  60275. * @param viewport defines the screen viewport to use
  60276. * @returns the new Vector3
  60277. */
  60278. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  60279. /** @hidden */
  60280. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  60281. /**
  60282. * Unproject from screen space to object space
  60283. * @param source defines the screen space Vector3 to use
  60284. * @param viewportWidth defines the current width of the viewport
  60285. * @param viewportHeight defines the current height of the viewport
  60286. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  60287. * @param transform defines the transform (view x projection) matrix to use
  60288. * @returns the new Vector3
  60289. */
  60290. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  60291. /**
  60292. * Unproject from screen space to object space
  60293. * @param source defines the screen space Vector3 to use
  60294. * @param viewportWidth defines the current width of the viewport
  60295. * @param viewportHeight defines the current height of the viewport
  60296. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  60297. * @param view defines the view matrix to use
  60298. * @param projection defines the projection matrix to use
  60299. * @returns the new Vector3
  60300. */
  60301. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  60302. /**
  60303. * Unproject from screen space to object space
  60304. * @param source defines the screen space Vector3 to use
  60305. * @param viewportWidth defines the current width of the viewport
  60306. * @param viewportHeight defines the current height of the viewport
  60307. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  60308. * @param view defines the view matrix to use
  60309. * @param projection defines the projection matrix to use
  60310. * @param result defines the Vector3 where to store the result
  60311. */
  60312. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  60313. /**
  60314. * Unproject from screen space to object space
  60315. * @param sourceX defines the screen space x coordinate to use
  60316. * @param sourceY defines the screen space y coordinate to use
  60317. * @param sourceZ defines the screen space z coordinate to use
  60318. * @param viewportWidth defines the current width of the viewport
  60319. * @param viewportHeight defines the current height of the viewport
  60320. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  60321. * @param view defines the view matrix to use
  60322. * @param projection defines the projection matrix to use
  60323. * @param result defines the Vector3 where to store the result
  60324. */
  60325. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  60326. /**
  60327. * Gets the minimal coordinate values between two Vector3
  60328. * @param left defines the first operand
  60329. * @param right defines the second operand
  60330. * @returns the new Vector3
  60331. */
  60332. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  60333. /**
  60334. * Gets the maximal coordinate values between two Vector3
  60335. * @param left defines the first operand
  60336. * @param right defines the second operand
  60337. * @returns the new Vector3
  60338. */
  60339. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  60340. /**
  60341. * Returns the distance between the vectors "value1" and "value2"
  60342. * @param value1 defines the first operand
  60343. * @param value2 defines the second operand
  60344. * @returns the distance
  60345. */
  60346. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  60347. /**
  60348. * Returns the squared distance between the vectors "value1" and "value2"
  60349. * @param value1 defines the first operand
  60350. * @param value2 defines the second operand
  60351. * @returns the squared distance
  60352. */
  60353. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  60354. /**
  60355. * Returns a new Vector3 located at the center between "value1" and "value2"
  60356. * @param value1 defines the first operand
  60357. * @param value2 defines the second operand
  60358. * @returns the new Vector3
  60359. */
  60360. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  60361. /**
  60362. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  60363. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  60364. * to something in order to rotate it from its local system to the given target system
  60365. * Note: axis1, axis2 and axis3 are normalized during this operation
  60366. * @param axis1 defines the first axis
  60367. * @param axis2 defines the second axis
  60368. * @param axis3 defines the third axis
  60369. * @returns a new Vector3
  60370. */
  60371. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  60372. /**
  60373. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  60374. * @param axis1 defines the first axis
  60375. * @param axis2 defines the second axis
  60376. * @param axis3 defines the third axis
  60377. * @param ref defines the Vector3 where to store the result
  60378. */
  60379. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  60380. }
  60381. /**
  60382. * Vector4 class created for EulerAngle class conversion to Quaternion
  60383. */
  60384. export class Vector4 {
  60385. /** x value of the vector */
  60386. x: number;
  60387. /** y value of the vector */
  60388. y: number;
  60389. /** z value of the vector */
  60390. z: number;
  60391. /** w value of the vector */
  60392. w: number;
  60393. /**
  60394. * Creates a Vector4 object from the given floats.
  60395. * @param x x value of the vector
  60396. * @param y y value of the vector
  60397. * @param z z value of the vector
  60398. * @param w w value of the vector
  60399. */
  60400. constructor(
  60401. /** x value of the vector */
  60402. x: number,
  60403. /** y value of the vector */
  60404. y: number,
  60405. /** z value of the vector */
  60406. z: number,
  60407. /** w value of the vector */
  60408. w: number);
  60409. /**
  60410. * Returns the string with the Vector4 coordinates.
  60411. * @returns a string containing all the vector values
  60412. */
  60413. toString(): string;
  60414. /**
  60415. * Returns the string "Vector4".
  60416. * @returns "Vector4"
  60417. */
  60418. getClassName(): string;
  60419. /**
  60420. * Returns the Vector4 hash code.
  60421. * @returns a unique hash code
  60422. */
  60423. getHashCode(): number;
  60424. /**
  60425. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  60426. * @returns the resulting array
  60427. */
  60428. asArray(): number[];
  60429. /**
  60430. * Populates the given array from the given index with the Vector4 coordinates.
  60431. * @param array array to populate
  60432. * @param index index of the array to start at (default: 0)
  60433. * @returns the Vector4.
  60434. */
  60435. toArray(array: FloatArray, index?: number): Vector4;
  60436. /**
  60437. * Adds the given vector to the current Vector4.
  60438. * @param otherVector the vector to add
  60439. * @returns the updated Vector4.
  60440. */
  60441. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  60442. /**
  60443. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  60444. * @param otherVector the vector to add
  60445. * @returns the resulting vector
  60446. */
  60447. add(otherVector: DeepImmutable<Vector4>): Vector4;
  60448. /**
  60449. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  60450. * @param otherVector the vector to add
  60451. * @param result the vector to store the result
  60452. * @returns the current Vector4.
  60453. */
  60454. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  60455. /**
  60456. * Subtract in place the given vector from the current Vector4.
  60457. * @param otherVector the vector to subtract
  60458. * @returns the updated Vector4.
  60459. */
  60460. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  60461. /**
  60462. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  60463. * @param otherVector the vector to add
  60464. * @returns the new vector with the result
  60465. */
  60466. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  60467. /**
  60468. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  60469. * @param otherVector the vector to subtract
  60470. * @param result the vector to store the result
  60471. * @returns the current Vector4.
  60472. */
  60473. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  60474. /**
  60475. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  60476. */
  60477. /**
  60478. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  60479. * @param x value to subtract
  60480. * @param y value to subtract
  60481. * @param z value to subtract
  60482. * @param w value to subtract
  60483. * @returns new vector containing the result
  60484. */
  60485. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  60486. /**
  60487. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  60488. * @param x value to subtract
  60489. * @param y value to subtract
  60490. * @param z value to subtract
  60491. * @param w value to subtract
  60492. * @param result the vector to store the result in
  60493. * @returns the current Vector4.
  60494. */
  60495. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  60496. /**
  60497. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  60498. * @returns a new vector with the negated values
  60499. */
  60500. negate(): Vector4;
  60501. /**
  60502. * Multiplies the current Vector4 coordinates by scale (float).
  60503. * @param scale the number to scale with
  60504. * @returns the updated Vector4.
  60505. */
  60506. scaleInPlace(scale: number): Vector4;
  60507. /**
  60508. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  60509. * @param scale the number to scale with
  60510. * @returns a new vector with the result
  60511. */
  60512. scale(scale: number): Vector4;
  60513. /**
  60514. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  60515. * @param scale the number to scale with
  60516. * @param result a vector to store the result in
  60517. * @returns the current Vector4.
  60518. */
  60519. scaleToRef(scale: number, result: Vector4): Vector4;
  60520. /**
  60521. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  60522. * @param scale defines the scale factor
  60523. * @param result defines the Vector4 object where to store the result
  60524. * @returns the unmodified current Vector4
  60525. */
  60526. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  60527. /**
  60528. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  60529. * @param otherVector the vector to compare against
  60530. * @returns true if they are equal
  60531. */
  60532. equals(otherVector: DeepImmutable<Vector4>): boolean;
  60533. /**
  60534. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  60535. * @param otherVector vector to compare against
  60536. * @param epsilon (Default: very small number)
  60537. * @returns true if they are equal
  60538. */
  60539. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  60540. /**
  60541. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  60542. * @param x x value to compare against
  60543. * @param y y value to compare against
  60544. * @param z z value to compare against
  60545. * @param w w value to compare against
  60546. * @returns true if equal
  60547. */
  60548. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  60549. /**
  60550. * Multiplies in place the current Vector4 by the given one.
  60551. * @param otherVector vector to multiple with
  60552. * @returns the updated Vector4.
  60553. */
  60554. multiplyInPlace(otherVector: Vector4): Vector4;
  60555. /**
  60556. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  60557. * @param otherVector vector to multiple with
  60558. * @returns resulting new vector
  60559. */
  60560. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  60561. /**
  60562. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  60563. * @param otherVector vector to multiple with
  60564. * @param result vector to store the result
  60565. * @returns the current Vector4.
  60566. */
  60567. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  60568. /**
  60569. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  60570. * @param x x value multiply with
  60571. * @param y y value multiply with
  60572. * @param z z value multiply with
  60573. * @param w w value multiply with
  60574. * @returns resulting new vector
  60575. */
  60576. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  60577. /**
  60578. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  60579. * @param otherVector vector to devide with
  60580. * @returns resulting new vector
  60581. */
  60582. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  60583. /**
  60584. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  60585. * @param otherVector vector to devide with
  60586. * @param result vector to store the result
  60587. * @returns the current Vector4.
  60588. */
  60589. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  60590. /**
  60591. * Divides the current Vector3 coordinates by the given ones.
  60592. * @param otherVector vector to devide with
  60593. * @returns the updated Vector3.
  60594. */
  60595. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  60596. /**
  60597. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  60598. * @param other defines the second operand
  60599. * @returns the current updated Vector4
  60600. */
  60601. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  60602. /**
  60603. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  60604. * @param other defines the second operand
  60605. * @returns the current updated Vector4
  60606. */
  60607. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  60608. /**
  60609. * Gets a new Vector4 from current Vector4 floored values
  60610. * @returns a new Vector4
  60611. */
  60612. floor(): Vector4;
  60613. /**
  60614. * Gets a new Vector4 from current Vector3 floored values
  60615. * @returns a new Vector4
  60616. */
  60617. fract(): Vector4;
  60618. /**
  60619. * Returns the Vector4 length (float).
  60620. * @returns the length
  60621. */
  60622. length(): number;
  60623. /**
  60624. * Returns the Vector4 squared length (float).
  60625. * @returns the length squared
  60626. */
  60627. lengthSquared(): number;
  60628. /**
  60629. * Normalizes in place the Vector4.
  60630. * @returns the updated Vector4.
  60631. */
  60632. normalize(): Vector4;
  60633. /**
  60634. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  60635. * @returns this converted to a new vector3
  60636. */
  60637. toVector3(): Vector3;
  60638. /**
  60639. * Returns a new Vector4 copied from the current one.
  60640. * @returns the new cloned vector
  60641. */
  60642. clone(): Vector4;
  60643. /**
  60644. * Updates the current Vector4 with the given one coordinates.
  60645. * @param source the source vector to copy from
  60646. * @returns the updated Vector4.
  60647. */
  60648. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  60649. /**
  60650. * Updates the current Vector4 coordinates with the given floats.
  60651. * @param x float to copy from
  60652. * @param y float to copy from
  60653. * @param z float to copy from
  60654. * @param w float to copy from
  60655. * @returns the updated Vector4.
  60656. */
  60657. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  60658. /**
  60659. * Updates the current Vector4 coordinates with the given floats.
  60660. * @param x float to set from
  60661. * @param y float to set from
  60662. * @param z float to set from
  60663. * @param w float to set from
  60664. * @returns the updated Vector4.
  60665. */
  60666. set(x: number, y: number, z: number, w: number): Vector4;
  60667. /**
  60668. * Copies the given float to the current Vector3 coordinates
  60669. * @param v defines the x, y, z and w coordinates of the operand
  60670. * @returns the current updated Vector3
  60671. */
  60672. setAll(v: number): Vector4;
  60673. /**
  60674. * Returns a new Vector4 set from the starting index of the given array.
  60675. * @param array the array to pull values from
  60676. * @param offset the offset into the array to start at
  60677. * @returns the new vector
  60678. */
  60679. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  60680. /**
  60681. * Updates the given vector "result" from the starting index of the given array.
  60682. * @param array the array to pull values from
  60683. * @param offset the offset into the array to start at
  60684. * @param result the vector to store the result in
  60685. */
  60686. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  60687. /**
  60688. * Updates the given vector "result" from the starting index of the given Float32Array.
  60689. * @param array the array to pull values from
  60690. * @param offset the offset into the array to start at
  60691. * @param result the vector to store the result in
  60692. */
  60693. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  60694. /**
  60695. * Updates the given vector "result" coordinates from the given floats.
  60696. * @param x float to set from
  60697. * @param y float to set from
  60698. * @param z float to set from
  60699. * @param w float to set from
  60700. * @param result the vector to the floats in
  60701. */
  60702. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  60703. /**
  60704. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  60705. * @returns the new vector
  60706. */
  60707. static Zero(): Vector4;
  60708. /**
  60709. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  60710. * @returns the new vector
  60711. */
  60712. static One(): Vector4;
  60713. /**
  60714. * Returns a new normalized Vector4 from the given one.
  60715. * @param vector the vector to normalize
  60716. * @returns the vector
  60717. */
  60718. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  60719. /**
  60720. * Updates the given vector "result" from the normalization of the given one.
  60721. * @param vector the vector to normalize
  60722. * @param result the vector to store the result in
  60723. */
  60724. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  60725. /**
  60726. * Returns a vector with the minimum values from the left and right vectors
  60727. * @param left left vector to minimize
  60728. * @param right right vector to minimize
  60729. * @returns a new vector with the minimum of the left and right vector values
  60730. */
  60731. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  60732. /**
  60733. * Returns a vector with the maximum values from the left and right vectors
  60734. * @param left left vector to maximize
  60735. * @param right right vector to maximize
  60736. * @returns a new vector with the maximum of the left and right vector values
  60737. */
  60738. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  60739. /**
  60740. * Returns the distance (float) between the vectors "value1" and "value2".
  60741. * @param value1 value to calulate the distance between
  60742. * @param value2 value to calulate the distance between
  60743. * @return the distance between the two vectors
  60744. */
  60745. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  60746. /**
  60747. * Returns the squared distance (float) between the vectors "value1" and "value2".
  60748. * @param value1 value to calulate the distance between
  60749. * @param value2 value to calulate the distance between
  60750. * @return the distance between the two vectors squared
  60751. */
  60752. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  60753. /**
  60754. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  60755. * @param value1 value to calulate the center between
  60756. * @param value2 value to calulate the center between
  60757. * @return the center between the two vectors
  60758. */
  60759. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  60760. /**
  60761. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  60762. * This methods computes transformed normalized direction vectors only.
  60763. * @param vector the vector to transform
  60764. * @param transformation the transformation matrix to apply
  60765. * @returns the new vector
  60766. */
  60767. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  60768. /**
  60769. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  60770. * This methods computes transformed normalized direction vectors only.
  60771. * @param vector the vector to transform
  60772. * @param transformation the transformation matrix to apply
  60773. * @param result the vector to store the result in
  60774. */
  60775. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  60776. /**
  60777. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  60778. * This methods computes transformed normalized direction vectors only.
  60779. * @param x value to transform
  60780. * @param y value to transform
  60781. * @param z value to transform
  60782. * @param w value to transform
  60783. * @param transformation the transformation matrix to apply
  60784. * @param result the vector to store the results in
  60785. */
  60786. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  60787. /**
  60788. * Creates a new Vector4 from a Vector3
  60789. * @param source defines the source data
  60790. * @param w defines the 4th component (default is 0)
  60791. * @returns a new Vector4
  60792. */
  60793. static FromVector3(source: Vector3, w?: number): Vector4;
  60794. }
  60795. /**
  60796. * Interface for the size containing width and height
  60797. */
  60798. export interface ISize {
  60799. /**
  60800. * Width
  60801. */
  60802. width: number;
  60803. /**
  60804. * Heighht
  60805. */
  60806. height: number;
  60807. }
  60808. /**
  60809. * Size containing widht and height
  60810. */
  60811. export class Size implements ISize {
  60812. /**
  60813. * Width
  60814. */
  60815. width: number;
  60816. /**
  60817. * Height
  60818. */
  60819. height: number;
  60820. /**
  60821. * Creates a Size object from the given width and height (floats).
  60822. * @param width width of the new size
  60823. * @param height height of the new size
  60824. */
  60825. constructor(width: number, height: number);
  60826. /**
  60827. * Returns a string with the Size width and height
  60828. * @returns a string with the Size width and height
  60829. */
  60830. toString(): string;
  60831. /**
  60832. * "Size"
  60833. * @returns the string "Size"
  60834. */
  60835. getClassName(): string;
  60836. /**
  60837. * Returns the Size hash code.
  60838. * @returns a hash code for a unique width and height
  60839. */
  60840. getHashCode(): number;
  60841. /**
  60842. * Updates the current size from the given one.
  60843. * @param src the given size
  60844. */
  60845. copyFrom(src: Size): void;
  60846. /**
  60847. * Updates in place the current Size from the given floats.
  60848. * @param width width of the new size
  60849. * @param height height of the new size
  60850. * @returns the updated Size.
  60851. */
  60852. copyFromFloats(width: number, height: number): Size;
  60853. /**
  60854. * Updates in place the current Size from the given floats.
  60855. * @param width width to set
  60856. * @param height height to set
  60857. * @returns the updated Size.
  60858. */
  60859. set(width: number, height: number): Size;
  60860. /**
  60861. * Multiplies the width and height by numbers
  60862. * @param w factor to multiple the width by
  60863. * @param h factor to multiple the height by
  60864. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  60865. */
  60866. multiplyByFloats(w: number, h: number): Size;
  60867. /**
  60868. * Clones the size
  60869. * @returns a new Size copied from the given one.
  60870. */
  60871. clone(): Size;
  60872. /**
  60873. * True if the current Size and the given one width and height are strictly equal.
  60874. * @param other the other size to compare against
  60875. * @returns True if the current Size and the given one width and height are strictly equal.
  60876. */
  60877. equals(other: Size): boolean;
  60878. /**
  60879. * The surface of the Size : width * height (float).
  60880. */
  60881. readonly surface: number;
  60882. /**
  60883. * Create a new size of zero
  60884. * @returns a new Size set to (0.0, 0.0)
  60885. */
  60886. static Zero(): Size;
  60887. /**
  60888. * Sums the width and height of two sizes
  60889. * @param otherSize size to add to this size
  60890. * @returns a new Size set as the addition result of the current Size and the given one.
  60891. */
  60892. add(otherSize: Size): Size;
  60893. /**
  60894. * Subtracts the width and height of two
  60895. * @param otherSize size to subtract to this size
  60896. * @returns a new Size set as the subtraction result of the given one from the current Size.
  60897. */
  60898. subtract(otherSize: Size): Size;
  60899. /**
  60900. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  60901. * @param start starting size to lerp between
  60902. * @param end end size to lerp between
  60903. * @param amount amount to lerp between the start and end values
  60904. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  60905. */
  60906. static Lerp(start: Size, end: Size, amount: number): Size;
  60907. }
  60908. /**
  60909. * Class used to store quaternion data
  60910. * @see https://en.wikipedia.org/wiki/Quaternion
  60911. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  60912. */
  60913. export class Quaternion {
  60914. /** defines the first component (0 by default) */
  60915. x: number;
  60916. /** defines the second component (0 by default) */
  60917. y: number;
  60918. /** defines the third component (0 by default) */
  60919. z: number;
  60920. /** defines the fourth component (1.0 by default) */
  60921. w: number;
  60922. /**
  60923. * Creates a new Quaternion from the given floats
  60924. * @param x defines the first component (0 by default)
  60925. * @param y defines the second component (0 by default)
  60926. * @param z defines the third component (0 by default)
  60927. * @param w defines the fourth component (1.0 by default)
  60928. */
  60929. constructor(
  60930. /** defines the first component (0 by default) */
  60931. x?: number,
  60932. /** defines the second component (0 by default) */
  60933. y?: number,
  60934. /** defines the third component (0 by default) */
  60935. z?: number,
  60936. /** defines the fourth component (1.0 by default) */
  60937. w?: number);
  60938. /**
  60939. * Gets a string representation for the current quaternion
  60940. * @returns a string with the Quaternion coordinates
  60941. */
  60942. toString(): string;
  60943. /**
  60944. * Gets the class name of the quaternion
  60945. * @returns the string "Quaternion"
  60946. */
  60947. getClassName(): string;
  60948. /**
  60949. * Gets a hash code for this quaternion
  60950. * @returns the quaternion hash code
  60951. */
  60952. getHashCode(): number;
  60953. /**
  60954. * Copy the quaternion to an array
  60955. * @returns a new array populated with 4 elements from the quaternion coordinates
  60956. */
  60957. asArray(): number[];
  60958. /**
  60959. * Check if two quaternions are equals
  60960. * @param otherQuaternion defines the second operand
  60961. * @return true if the current quaternion and the given one coordinates are strictly equals
  60962. */
  60963. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  60964. /**
  60965. * Clone the current quaternion
  60966. * @returns a new quaternion copied from the current one
  60967. */
  60968. clone(): Quaternion;
  60969. /**
  60970. * Copy a quaternion to the current one
  60971. * @param other defines the other quaternion
  60972. * @returns the updated current quaternion
  60973. */
  60974. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  60975. /**
  60976. * Updates the current quaternion with the given float coordinates
  60977. * @param x defines the x coordinate
  60978. * @param y defines the y coordinate
  60979. * @param z defines the z coordinate
  60980. * @param w defines the w coordinate
  60981. * @returns the updated current quaternion
  60982. */
  60983. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  60984. /**
  60985. * Updates the current quaternion from the given float coordinates
  60986. * @param x defines the x coordinate
  60987. * @param y defines the y coordinate
  60988. * @param z defines the z coordinate
  60989. * @param w defines the w coordinate
  60990. * @returns the updated current quaternion
  60991. */
  60992. set(x: number, y: number, z: number, w: number): Quaternion;
  60993. /**
  60994. * Adds two quaternions
  60995. * @param other defines the second operand
  60996. * @returns a new quaternion as the addition result of the given one and the current quaternion
  60997. */
  60998. add(other: DeepImmutable<Quaternion>): Quaternion;
  60999. /**
  61000. * Add a quaternion to the current one
  61001. * @param other defines the quaternion to add
  61002. * @returns the current quaternion
  61003. */
  61004. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  61005. /**
  61006. * Subtract two quaternions
  61007. * @param other defines the second operand
  61008. * @returns a new quaternion as the subtraction result of the given one from the current one
  61009. */
  61010. subtract(other: Quaternion): Quaternion;
  61011. /**
  61012. * Multiplies the current quaternion by a scale factor
  61013. * @param value defines the scale factor
  61014. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  61015. */
  61016. scale(value: number): Quaternion;
  61017. /**
  61018. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  61019. * @param scale defines the scale factor
  61020. * @param result defines the Quaternion object where to store the result
  61021. * @returns the unmodified current quaternion
  61022. */
  61023. scaleToRef(scale: number, result: Quaternion): Quaternion;
  61024. /**
  61025. * Multiplies in place the current quaternion by a scale factor
  61026. * @param value defines the scale factor
  61027. * @returns the current modified quaternion
  61028. */
  61029. scaleInPlace(value: number): Quaternion;
  61030. /**
  61031. * Scale the current quaternion values by a factor and add the result to a given quaternion
  61032. * @param scale defines the scale factor
  61033. * @param result defines the Quaternion object where to store the result
  61034. * @returns the unmodified current quaternion
  61035. */
  61036. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  61037. /**
  61038. * Multiplies two quaternions
  61039. * @param q1 defines the second operand
  61040. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  61041. */
  61042. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  61043. /**
  61044. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  61045. * @param q1 defines the second operand
  61046. * @param result defines the target quaternion
  61047. * @returns the current quaternion
  61048. */
  61049. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  61050. /**
  61051. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  61052. * @param q1 defines the second operand
  61053. * @returns the currentupdated quaternion
  61054. */
  61055. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  61056. /**
  61057. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  61058. * @param ref defines the target quaternion
  61059. * @returns the current quaternion
  61060. */
  61061. conjugateToRef(ref: Quaternion): Quaternion;
  61062. /**
  61063. * Conjugates in place (1-q) the current quaternion
  61064. * @returns the current updated quaternion
  61065. */
  61066. conjugateInPlace(): Quaternion;
  61067. /**
  61068. * Conjugates in place (1-q) the current quaternion
  61069. * @returns a new quaternion
  61070. */
  61071. conjugate(): Quaternion;
  61072. /**
  61073. * Gets length of current quaternion
  61074. * @returns the quaternion length (float)
  61075. */
  61076. length(): number;
  61077. /**
  61078. * Normalize in place the current quaternion
  61079. * @returns the current updated quaternion
  61080. */
  61081. normalize(): Quaternion;
  61082. /**
  61083. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  61084. * @param order is a reserved parameter and is ignore for now
  61085. * @returns a new Vector3 containing the Euler angles
  61086. */
  61087. toEulerAngles(order?: string): Vector3;
  61088. /**
  61089. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  61090. * @param result defines the vector which will be filled with the Euler angles
  61091. * @param order is a reserved parameter and is ignore for now
  61092. * @returns the current unchanged quaternion
  61093. */
  61094. toEulerAnglesToRef(result: Vector3): Quaternion;
  61095. /**
  61096. * Updates the given rotation matrix with the current quaternion values
  61097. * @param result defines the target matrix
  61098. * @returns the current unchanged quaternion
  61099. */
  61100. toRotationMatrix(result: Matrix): Quaternion;
  61101. /**
  61102. * Updates the current quaternion from the given rotation matrix values
  61103. * @param matrix defines the source matrix
  61104. * @returns the current updated quaternion
  61105. */
  61106. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  61107. /**
  61108. * Creates a new quaternion from a rotation matrix
  61109. * @param matrix defines the source matrix
  61110. * @returns a new quaternion created from the given rotation matrix values
  61111. */
  61112. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  61113. /**
  61114. * Updates the given quaternion with the given rotation matrix values
  61115. * @param matrix defines the source matrix
  61116. * @param result defines the target quaternion
  61117. */
  61118. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  61119. /**
  61120. * Returns the dot product (float) between the quaternions "left" and "right"
  61121. * @param left defines the left operand
  61122. * @param right defines the right operand
  61123. * @returns the dot product
  61124. */
  61125. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  61126. /**
  61127. * Checks if the two quaternions are close to each other
  61128. * @param quat0 defines the first quaternion to check
  61129. * @param quat1 defines the second quaternion to check
  61130. * @returns true if the two quaternions are close to each other
  61131. */
  61132. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  61133. /**
  61134. * Creates an empty quaternion
  61135. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  61136. */
  61137. static Zero(): Quaternion;
  61138. /**
  61139. * Inverse a given quaternion
  61140. * @param q defines the source quaternion
  61141. * @returns a new quaternion as the inverted current quaternion
  61142. */
  61143. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  61144. /**
  61145. * Inverse a given quaternion
  61146. * @param q defines the source quaternion
  61147. * @param result the quaternion the result will be stored in
  61148. * @returns the result quaternion
  61149. */
  61150. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  61151. /**
  61152. * Creates an identity quaternion
  61153. * @returns the identity quaternion
  61154. */
  61155. static Identity(): Quaternion;
  61156. /**
  61157. * Gets a boolean indicating if the given quaternion is identity
  61158. * @param quaternion defines the quaternion to check
  61159. * @returns true if the quaternion is identity
  61160. */
  61161. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  61162. /**
  61163. * Creates a quaternion from a rotation around an axis
  61164. * @param axis defines the axis to use
  61165. * @param angle defines the angle to use
  61166. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  61167. */
  61168. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  61169. /**
  61170. * Creates a rotation around an axis and stores it into the given quaternion
  61171. * @param axis defines the axis to use
  61172. * @param angle defines the angle to use
  61173. * @param result defines the target quaternion
  61174. * @returns the target quaternion
  61175. */
  61176. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  61177. /**
  61178. * Creates a new quaternion from data stored into an array
  61179. * @param array defines the data source
  61180. * @param offset defines the offset in the source array where the data starts
  61181. * @returns a new quaternion
  61182. */
  61183. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  61184. /**
  61185. * Create a quaternion from Euler rotation angles
  61186. * @param x Pitch
  61187. * @param y Yaw
  61188. * @param z Roll
  61189. * @returns the new Quaternion
  61190. */
  61191. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  61192. /**
  61193. * Updates a quaternion from Euler rotation angles
  61194. * @param x Pitch
  61195. * @param y Yaw
  61196. * @param z Roll
  61197. * @param result the quaternion to store the result
  61198. * @returns the updated quaternion
  61199. */
  61200. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  61201. /**
  61202. * Create a quaternion from Euler rotation vector
  61203. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  61204. * @returns the new Quaternion
  61205. */
  61206. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  61207. /**
  61208. * Updates a quaternion from Euler rotation vector
  61209. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  61210. * @param result the quaternion to store the result
  61211. * @returns the updated quaternion
  61212. */
  61213. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  61214. /**
  61215. * Creates a new quaternion from the given Euler float angles (y, x, z)
  61216. * @param yaw defines the rotation around Y axis
  61217. * @param pitch defines the rotation around X axis
  61218. * @param roll defines the rotation around Z axis
  61219. * @returns the new quaternion
  61220. */
  61221. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  61222. /**
  61223. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  61224. * @param yaw defines the rotation around Y axis
  61225. * @param pitch defines the rotation around X axis
  61226. * @param roll defines the rotation around Z axis
  61227. * @param result defines the target quaternion
  61228. */
  61229. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  61230. /**
  61231. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  61232. * @param alpha defines the rotation around first axis
  61233. * @param beta defines the rotation around second axis
  61234. * @param gamma defines the rotation around third axis
  61235. * @returns the new quaternion
  61236. */
  61237. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  61238. /**
  61239. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  61240. * @param alpha defines the rotation around first axis
  61241. * @param beta defines the rotation around second axis
  61242. * @param gamma defines the rotation around third axis
  61243. * @param result defines the target quaternion
  61244. */
  61245. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  61246. /**
  61247. * 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)
  61248. * @param axis1 defines the first axis
  61249. * @param axis2 defines the second axis
  61250. * @param axis3 defines the third axis
  61251. * @returns the new quaternion
  61252. */
  61253. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  61254. /**
  61255. * 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
  61256. * @param axis1 defines the first axis
  61257. * @param axis2 defines the second axis
  61258. * @param axis3 defines the third axis
  61259. * @param ref defines the target quaternion
  61260. */
  61261. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  61262. /**
  61263. * Interpolates between two quaternions
  61264. * @param left defines first quaternion
  61265. * @param right defines second quaternion
  61266. * @param amount defines the gradient to use
  61267. * @returns the new interpolated quaternion
  61268. */
  61269. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  61270. /**
  61271. * Interpolates between two quaternions and stores it into a target quaternion
  61272. * @param left defines first quaternion
  61273. * @param right defines second quaternion
  61274. * @param amount defines the gradient to use
  61275. * @param result defines the target quaternion
  61276. */
  61277. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  61278. /**
  61279. * Interpolate between two quaternions using Hermite interpolation
  61280. * @param value1 defines first quaternion
  61281. * @param tangent1 defines the incoming tangent
  61282. * @param value2 defines second quaternion
  61283. * @param tangent2 defines the outgoing tangent
  61284. * @param amount defines the target quaternion
  61285. * @returns the new interpolated quaternion
  61286. */
  61287. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  61288. }
  61289. /**
  61290. * Class used to store matrix data (4x4)
  61291. */
  61292. export class Matrix {
  61293. private static _updateFlagSeed;
  61294. private static _identityReadOnly;
  61295. private _isIdentity;
  61296. private _isIdentityDirty;
  61297. private _isIdentity3x2;
  61298. private _isIdentity3x2Dirty;
  61299. /**
  61300. * Gets the update flag of the matrix which is an unique number for the matrix.
  61301. * It will be incremented every time the matrix data change.
  61302. * You can use it to speed the comparison between two versions of the same matrix.
  61303. */
  61304. updateFlag: number;
  61305. private readonly _m;
  61306. /**
  61307. * Gets the internal data of the matrix
  61308. */
  61309. readonly m: DeepImmutable<Float32Array>;
  61310. /** @hidden */
  61311. _markAsUpdated(): void;
  61312. /** @hidden */
  61313. private _updateIdentityStatus;
  61314. /**
  61315. * Creates an empty matrix (filled with zeros)
  61316. */
  61317. constructor();
  61318. /**
  61319. * Check if the current matrix is identity
  61320. * @returns true is the matrix is the identity matrix
  61321. */
  61322. isIdentity(): boolean;
  61323. /**
  61324. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  61325. * @returns true is the matrix is the identity matrix
  61326. */
  61327. isIdentityAs3x2(): boolean;
  61328. /**
  61329. * Gets the determinant of the matrix
  61330. * @returns the matrix determinant
  61331. */
  61332. determinant(): number;
  61333. /**
  61334. * Returns the matrix as a Float32Array
  61335. * @returns the matrix underlying array
  61336. */
  61337. toArray(): DeepImmutable<Float32Array>;
  61338. /**
  61339. * Returns the matrix as a Float32Array
  61340. * @returns the matrix underlying array.
  61341. */
  61342. asArray(): DeepImmutable<Float32Array>;
  61343. /**
  61344. * Inverts the current matrix in place
  61345. * @returns the current inverted matrix
  61346. */
  61347. invert(): Matrix;
  61348. /**
  61349. * Sets all the matrix elements to zero
  61350. * @returns the current matrix
  61351. */
  61352. reset(): Matrix;
  61353. /**
  61354. * Adds the current matrix with a second one
  61355. * @param other defines the matrix to add
  61356. * @returns a new matrix as the addition of the current matrix and the given one
  61357. */
  61358. add(other: DeepImmutable<Matrix>): Matrix;
  61359. /**
  61360. * Sets the given matrix "result" to the addition of the current matrix and the given one
  61361. * @param other defines the matrix to add
  61362. * @param result defines the target matrix
  61363. * @returns the current matrix
  61364. */
  61365. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  61366. /**
  61367. * Adds in place the given matrix to the current matrix
  61368. * @param other defines the second operand
  61369. * @returns the current updated matrix
  61370. */
  61371. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  61372. /**
  61373. * Sets the given matrix to the current inverted Matrix
  61374. * @param other defines the target matrix
  61375. * @returns the unmodified current matrix
  61376. */
  61377. invertToRef(other: Matrix): Matrix;
  61378. /**
  61379. * add a value at the specified position in the current Matrix
  61380. * @param index the index of the value within the matrix. between 0 and 15.
  61381. * @param value the value to be added
  61382. * @returns the current updated matrix
  61383. */
  61384. addAtIndex(index: number, value: number): Matrix;
  61385. /**
  61386. * mutiply the specified position in the current Matrix by a value
  61387. * @param index the index of the value within the matrix. between 0 and 15.
  61388. * @param value the value to be added
  61389. * @returns the current updated matrix
  61390. */
  61391. multiplyAtIndex(index: number, value: number): Matrix;
  61392. /**
  61393. * Inserts the translation vector (using 3 floats) in the current matrix
  61394. * @param x defines the 1st component of the translation
  61395. * @param y defines the 2nd component of the translation
  61396. * @param z defines the 3rd component of the translation
  61397. * @returns the current updated matrix
  61398. */
  61399. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  61400. /**
  61401. * Inserts the translation vector in the current matrix
  61402. * @param vector3 defines the translation to insert
  61403. * @returns the current updated matrix
  61404. */
  61405. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  61406. /**
  61407. * Gets the translation value of the current matrix
  61408. * @returns a new Vector3 as the extracted translation from the matrix
  61409. */
  61410. getTranslation(): Vector3;
  61411. /**
  61412. * Fill a Vector3 with the extracted translation from the matrix
  61413. * @param result defines the Vector3 where to store the translation
  61414. * @returns the current matrix
  61415. */
  61416. getTranslationToRef(result: Vector3): Matrix;
  61417. /**
  61418. * Remove rotation and scaling part from the matrix
  61419. * @returns the updated matrix
  61420. */
  61421. removeRotationAndScaling(): Matrix;
  61422. /**
  61423. * Multiply two matrices
  61424. * @param other defines the second operand
  61425. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  61426. */
  61427. multiply(other: DeepImmutable<Matrix>): Matrix;
  61428. /**
  61429. * Copy the current matrix from the given one
  61430. * @param other defines the source matrix
  61431. * @returns the current updated matrix
  61432. */
  61433. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  61434. /**
  61435. * Populates the given array from the starting index with the current matrix values
  61436. * @param array defines the target array
  61437. * @param offset defines the offset in the target array where to start storing values
  61438. * @returns the current matrix
  61439. */
  61440. copyToArray(array: Float32Array, offset?: number): Matrix;
  61441. /**
  61442. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  61443. * @param other defines the second operand
  61444. * @param result defines the matrix where to store the multiplication
  61445. * @returns the current matrix
  61446. */
  61447. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  61448. /**
  61449. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  61450. * @param other defines the second operand
  61451. * @param result defines the array where to store the multiplication
  61452. * @param offset defines the offset in the target array where to start storing values
  61453. * @returns the current matrix
  61454. */
  61455. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  61456. /**
  61457. * Check equality between this matrix and a second one
  61458. * @param value defines the second matrix to compare
  61459. * @returns true is the current matrix and the given one values are strictly equal
  61460. */
  61461. equals(value: DeepImmutable<Matrix>): boolean;
  61462. /**
  61463. * Clone the current matrix
  61464. * @returns a new matrix from the current matrix
  61465. */
  61466. clone(): Matrix;
  61467. /**
  61468. * Returns the name of the current matrix class
  61469. * @returns the string "Matrix"
  61470. */
  61471. getClassName(): string;
  61472. /**
  61473. * Gets the hash code of the current matrix
  61474. * @returns the hash code
  61475. */
  61476. getHashCode(): number;
  61477. /**
  61478. * Decomposes the current Matrix into a translation, rotation and scaling components
  61479. * @param scale defines the scale vector3 given as a reference to update
  61480. * @param rotation defines the rotation quaternion given as a reference to update
  61481. * @param translation defines the translation vector3 given as a reference to update
  61482. * @returns true if operation was successful
  61483. */
  61484. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  61485. /**
  61486. * Gets specific row of the matrix
  61487. * @param index defines the number of the row to get
  61488. * @returns the index-th row of the current matrix as a new Vector4
  61489. */
  61490. getRow(index: number): Nullable<Vector4>;
  61491. /**
  61492. * Sets the index-th row of the current matrix to the vector4 values
  61493. * @param index defines the number of the row to set
  61494. * @param row defines the target vector4
  61495. * @returns the updated current matrix
  61496. */
  61497. setRow(index: number, row: Vector4): Matrix;
  61498. /**
  61499. * Compute the transpose of the matrix
  61500. * @returns the new transposed matrix
  61501. */
  61502. transpose(): Matrix;
  61503. /**
  61504. * Compute the transpose of the matrix and store it in a given matrix
  61505. * @param result defines the target matrix
  61506. * @returns the current matrix
  61507. */
  61508. transposeToRef(result: Matrix): Matrix;
  61509. /**
  61510. * Sets the index-th row of the current matrix with the given 4 x float values
  61511. * @param index defines the row index
  61512. * @param x defines the x component to set
  61513. * @param y defines the y component to set
  61514. * @param z defines the z component to set
  61515. * @param w defines the w component to set
  61516. * @returns the updated current matrix
  61517. */
  61518. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  61519. /**
  61520. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  61521. * @param scale defines the scale factor
  61522. * @returns a new matrix
  61523. */
  61524. scale(scale: number): Matrix;
  61525. /**
  61526. * Scale the current matrix values by a factor to a given result matrix
  61527. * @param scale defines the scale factor
  61528. * @param result defines the matrix to store the result
  61529. * @returns the current matrix
  61530. */
  61531. scaleToRef(scale: number, result: Matrix): Matrix;
  61532. /**
  61533. * Scale the current matrix values by a factor and add the result to a given matrix
  61534. * @param scale defines the scale factor
  61535. * @param result defines the Matrix to store the result
  61536. * @returns the current matrix
  61537. */
  61538. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  61539. /**
  61540. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  61541. * @param ref matrix to store the result
  61542. */
  61543. toNormalMatrix(ref: Matrix): void;
  61544. /**
  61545. * Gets only rotation part of the current matrix
  61546. * @returns a new matrix sets to the extracted rotation matrix from the current one
  61547. */
  61548. getRotationMatrix(): Matrix;
  61549. /**
  61550. * Extracts the rotation matrix from the current one and sets it as the given "result"
  61551. * @param result defines the target matrix to store data to
  61552. * @returns the current matrix
  61553. */
  61554. getRotationMatrixToRef(result: Matrix): Matrix;
  61555. /**
  61556. * Toggles model matrix from being right handed to left handed in place and vice versa
  61557. */
  61558. toggleModelMatrixHandInPlace(): void;
  61559. /**
  61560. * Toggles projection matrix from being right handed to left handed in place and vice versa
  61561. */
  61562. toggleProjectionMatrixHandInPlace(): void;
  61563. /**
  61564. * Creates a matrix from an array
  61565. * @param array defines the source array
  61566. * @param offset defines an offset in the source array
  61567. * @returns a new Matrix set from the starting index of the given array
  61568. */
  61569. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  61570. /**
  61571. * Copy the content of an array into a given matrix
  61572. * @param array defines the source array
  61573. * @param offset defines an offset in the source array
  61574. * @param result defines the target matrix
  61575. */
  61576. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  61577. /**
  61578. * Stores an array into a matrix after having multiplied each component by a given factor
  61579. * @param array defines the source array
  61580. * @param offset defines the offset in the source array
  61581. * @param scale defines the scaling factor
  61582. * @param result defines the target matrix
  61583. */
  61584. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  61585. /**
  61586. * Gets an identity matrix that must not be updated
  61587. */
  61588. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  61589. /**
  61590. * Stores a list of values (16) inside a given matrix
  61591. * @param initialM11 defines 1st value of 1st row
  61592. * @param initialM12 defines 2nd value of 1st row
  61593. * @param initialM13 defines 3rd value of 1st row
  61594. * @param initialM14 defines 4th value of 1st row
  61595. * @param initialM21 defines 1st value of 2nd row
  61596. * @param initialM22 defines 2nd value of 2nd row
  61597. * @param initialM23 defines 3rd value of 2nd row
  61598. * @param initialM24 defines 4th value of 2nd row
  61599. * @param initialM31 defines 1st value of 3rd row
  61600. * @param initialM32 defines 2nd value of 3rd row
  61601. * @param initialM33 defines 3rd value of 3rd row
  61602. * @param initialM34 defines 4th value of 3rd row
  61603. * @param initialM41 defines 1st value of 4th row
  61604. * @param initialM42 defines 2nd value of 4th row
  61605. * @param initialM43 defines 3rd value of 4th row
  61606. * @param initialM44 defines 4th value of 4th row
  61607. * @param result defines the target matrix
  61608. */
  61609. 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;
  61610. /**
  61611. * Creates new matrix from a list of values (16)
  61612. * @param initialM11 defines 1st value of 1st row
  61613. * @param initialM12 defines 2nd value of 1st row
  61614. * @param initialM13 defines 3rd value of 1st row
  61615. * @param initialM14 defines 4th value of 1st row
  61616. * @param initialM21 defines 1st value of 2nd row
  61617. * @param initialM22 defines 2nd value of 2nd row
  61618. * @param initialM23 defines 3rd value of 2nd row
  61619. * @param initialM24 defines 4th value of 2nd row
  61620. * @param initialM31 defines 1st value of 3rd row
  61621. * @param initialM32 defines 2nd value of 3rd row
  61622. * @param initialM33 defines 3rd value of 3rd row
  61623. * @param initialM34 defines 4th value of 3rd row
  61624. * @param initialM41 defines 1st value of 4th row
  61625. * @param initialM42 defines 2nd value of 4th row
  61626. * @param initialM43 defines 3rd value of 4th row
  61627. * @param initialM44 defines 4th value of 4th row
  61628. * @returns the new matrix
  61629. */
  61630. 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;
  61631. /**
  61632. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  61633. * @param scale defines the scale vector3
  61634. * @param rotation defines the rotation quaternion
  61635. * @param translation defines the translation vector3
  61636. * @returns a new matrix
  61637. */
  61638. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  61639. /**
  61640. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  61641. * @param scale defines the scale vector3
  61642. * @param rotation defines the rotation quaternion
  61643. * @param translation defines the translation vector3
  61644. * @param result defines the target matrix
  61645. */
  61646. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  61647. /**
  61648. * Creates a new identity matrix
  61649. * @returns a new identity matrix
  61650. */
  61651. static Identity(): Matrix;
  61652. /**
  61653. * Creates a new identity matrix and stores the result in a given matrix
  61654. * @param result defines the target matrix
  61655. */
  61656. static IdentityToRef(result: Matrix): void;
  61657. /**
  61658. * Creates a new zero matrix
  61659. * @returns a new zero matrix
  61660. */
  61661. static Zero(): Matrix;
  61662. /**
  61663. * Creates a new rotation matrix for "angle" radians around the X axis
  61664. * @param angle defines the angle (in radians) to use
  61665. * @return the new matrix
  61666. */
  61667. static RotationX(angle: number): Matrix;
  61668. /**
  61669. * Creates a new matrix as the invert of a given matrix
  61670. * @param source defines the source matrix
  61671. * @returns the new matrix
  61672. */
  61673. static Invert(source: DeepImmutable<Matrix>): Matrix;
  61674. /**
  61675. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  61676. * @param angle defines the angle (in radians) to use
  61677. * @param result defines the target matrix
  61678. */
  61679. static RotationXToRef(angle: number, result: Matrix): void;
  61680. /**
  61681. * Creates a new rotation matrix for "angle" radians around the Y axis
  61682. * @param angle defines the angle (in radians) to use
  61683. * @return the new matrix
  61684. */
  61685. static RotationY(angle: number): Matrix;
  61686. /**
  61687. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  61688. * @param angle defines the angle (in radians) to use
  61689. * @param result defines the target matrix
  61690. */
  61691. static RotationYToRef(angle: number, result: Matrix): void;
  61692. /**
  61693. * Creates a new rotation matrix for "angle" radians around the Z axis
  61694. * @param angle defines the angle (in radians) to use
  61695. * @return the new matrix
  61696. */
  61697. static RotationZ(angle: number): Matrix;
  61698. /**
  61699. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  61700. * @param angle defines the angle (in radians) to use
  61701. * @param result defines the target matrix
  61702. */
  61703. static RotationZToRef(angle: number, result: Matrix): void;
  61704. /**
  61705. * Creates a new rotation matrix for "angle" radians around the given axis
  61706. * @param axis defines the axis to use
  61707. * @param angle defines the angle (in radians) to use
  61708. * @return the new matrix
  61709. */
  61710. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  61711. /**
  61712. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  61713. * @param axis defines the axis to use
  61714. * @param angle defines the angle (in radians) to use
  61715. * @param result defines the target matrix
  61716. */
  61717. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  61718. /**
  61719. * Creates a rotation matrix
  61720. * @param yaw defines the yaw angle in radians (Y axis)
  61721. * @param pitch defines the pitch angle in radians (X axis)
  61722. * @param roll defines the roll angle in radians (X axis)
  61723. * @returns the new rotation matrix
  61724. */
  61725. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  61726. /**
  61727. * Creates a rotation matrix and stores it in a given matrix
  61728. * @param yaw defines the yaw angle in radians (Y axis)
  61729. * @param pitch defines the pitch angle in radians (X axis)
  61730. * @param roll defines the roll angle in radians (X axis)
  61731. * @param result defines the target matrix
  61732. */
  61733. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  61734. /**
  61735. * Creates a scaling matrix
  61736. * @param x defines the scale factor on X axis
  61737. * @param y defines the scale factor on Y axis
  61738. * @param z defines the scale factor on Z axis
  61739. * @returns the new matrix
  61740. */
  61741. static Scaling(x: number, y: number, z: number): Matrix;
  61742. /**
  61743. * Creates a scaling matrix and stores it in a given matrix
  61744. * @param x defines the scale factor on X axis
  61745. * @param y defines the scale factor on Y axis
  61746. * @param z defines the scale factor on Z axis
  61747. * @param result defines the target matrix
  61748. */
  61749. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  61750. /**
  61751. * Creates a translation matrix
  61752. * @param x defines the translation on X axis
  61753. * @param y defines the translation on Y axis
  61754. * @param z defines the translationon Z axis
  61755. * @returns the new matrix
  61756. */
  61757. static Translation(x: number, y: number, z: number): Matrix;
  61758. /**
  61759. * Creates a translation matrix and stores it in a given matrix
  61760. * @param x defines the translation on X axis
  61761. * @param y defines the translation on Y axis
  61762. * @param z defines the translationon Z axis
  61763. * @param result defines the target matrix
  61764. */
  61765. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  61766. /**
  61767. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  61768. * @param startValue defines the start value
  61769. * @param endValue defines the end value
  61770. * @param gradient defines the gradient factor
  61771. * @returns the new matrix
  61772. */
  61773. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  61774. /**
  61775. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  61776. * @param startValue defines the start value
  61777. * @param endValue defines the end value
  61778. * @param gradient defines the gradient factor
  61779. * @param result defines the Matrix object where to store data
  61780. */
  61781. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  61782. /**
  61783. * Builds a new matrix whose values are computed by:
  61784. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  61785. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  61786. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  61787. * @param startValue defines the first matrix
  61788. * @param endValue defines the second matrix
  61789. * @param gradient defines the gradient between the two matrices
  61790. * @returns the new matrix
  61791. */
  61792. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  61793. /**
  61794. * Update a matrix to values which are computed by:
  61795. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  61796. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  61797. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  61798. * @param startValue defines the first matrix
  61799. * @param endValue defines the second matrix
  61800. * @param gradient defines the gradient between the two matrices
  61801. * @param result defines the target matrix
  61802. */
  61803. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  61804. /**
  61805. * 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"
  61806. * This function works in left handed mode
  61807. * @param eye defines the final position of the entity
  61808. * @param target defines where the entity should look at
  61809. * @param up defines the up vector for the entity
  61810. * @returns the new matrix
  61811. */
  61812. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  61813. /**
  61814. * 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".
  61815. * This function works in left handed mode
  61816. * @param eye defines the final position of the entity
  61817. * @param target defines where the entity should look at
  61818. * @param up defines the up vector for the entity
  61819. * @param result defines the target matrix
  61820. */
  61821. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  61822. /**
  61823. * 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"
  61824. * This function works in right handed mode
  61825. * @param eye defines the final position of the entity
  61826. * @param target defines where the entity should look at
  61827. * @param up defines the up vector for the entity
  61828. * @returns the new matrix
  61829. */
  61830. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  61831. /**
  61832. * 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".
  61833. * This function works in right handed mode
  61834. * @param eye defines the final position of the entity
  61835. * @param target defines where the entity should look at
  61836. * @param up defines the up vector for the entity
  61837. * @param result defines the target matrix
  61838. */
  61839. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  61840. /**
  61841. * Create a left-handed orthographic projection matrix
  61842. * @param width defines the viewport width
  61843. * @param height defines the viewport height
  61844. * @param znear defines the near clip plane
  61845. * @param zfar defines the far clip plane
  61846. * @returns a new matrix as a left-handed orthographic projection matrix
  61847. */
  61848. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  61849. /**
  61850. * Store a left-handed orthographic projection to a given matrix
  61851. * @param width defines the viewport width
  61852. * @param height defines the viewport height
  61853. * @param znear defines the near clip plane
  61854. * @param zfar defines the far clip plane
  61855. * @param result defines the target matrix
  61856. */
  61857. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  61858. /**
  61859. * Create a left-handed orthographic projection matrix
  61860. * @param left defines the viewport left coordinate
  61861. * @param right defines the viewport right coordinate
  61862. * @param bottom defines the viewport bottom coordinate
  61863. * @param top defines the viewport top coordinate
  61864. * @param znear defines the near clip plane
  61865. * @param zfar defines the far clip plane
  61866. * @returns a new matrix as a left-handed orthographic projection matrix
  61867. */
  61868. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  61869. /**
  61870. * Stores a left-handed orthographic projection into a given matrix
  61871. * @param left defines the viewport left coordinate
  61872. * @param right defines the viewport right coordinate
  61873. * @param bottom defines the viewport bottom coordinate
  61874. * @param top defines the viewport top coordinate
  61875. * @param znear defines the near clip plane
  61876. * @param zfar defines the far clip plane
  61877. * @param result defines the target matrix
  61878. */
  61879. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  61880. /**
  61881. * Creates a right-handed orthographic projection matrix
  61882. * @param left defines the viewport left coordinate
  61883. * @param right defines the viewport right coordinate
  61884. * @param bottom defines the viewport bottom coordinate
  61885. * @param top defines the viewport top coordinate
  61886. * @param znear defines the near clip plane
  61887. * @param zfar defines the far clip plane
  61888. * @returns a new matrix as a right-handed orthographic projection matrix
  61889. */
  61890. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  61891. /**
  61892. * Stores a right-handed orthographic projection into a given matrix
  61893. * @param left defines the viewport left coordinate
  61894. * @param right defines the viewport right coordinate
  61895. * @param bottom defines the viewport bottom coordinate
  61896. * @param top defines the viewport top coordinate
  61897. * @param znear defines the near clip plane
  61898. * @param zfar defines the far clip plane
  61899. * @param result defines the target matrix
  61900. */
  61901. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  61902. /**
  61903. * Creates a left-handed perspective projection matrix
  61904. * @param width defines the viewport width
  61905. * @param height defines the viewport height
  61906. * @param znear defines the near clip plane
  61907. * @param zfar defines the far clip plane
  61908. * @returns a new matrix as a left-handed perspective projection matrix
  61909. */
  61910. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  61911. /**
  61912. * Creates a left-handed perspective projection matrix
  61913. * @param fov defines the horizontal field of view
  61914. * @param aspect defines the aspect ratio
  61915. * @param znear defines the near clip plane
  61916. * @param zfar defines the far clip plane
  61917. * @returns a new matrix as a left-handed perspective projection matrix
  61918. */
  61919. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  61920. /**
  61921. * Stores a left-handed perspective projection into a given matrix
  61922. * @param fov defines the horizontal field of view
  61923. * @param aspect defines the aspect ratio
  61924. * @param znear defines the near clip plane
  61925. * @param zfar defines the far clip plane
  61926. * @param result defines the target matrix
  61927. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  61928. */
  61929. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  61930. /**
  61931. * Creates a right-handed perspective projection matrix
  61932. * @param fov defines the horizontal field of view
  61933. * @param aspect defines the aspect ratio
  61934. * @param znear defines the near clip plane
  61935. * @param zfar defines the far clip plane
  61936. * @returns a new matrix as a right-handed perspective projection matrix
  61937. */
  61938. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  61939. /**
  61940. * Stores a right-handed perspective projection into a given matrix
  61941. * @param fov defines the horizontal field of view
  61942. * @param aspect defines the aspect ratio
  61943. * @param znear defines the near clip plane
  61944. * @param zfar defines the far clip plane
  61945. * @param result defines the target matrix
  61946. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  61947. */
  61948. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  61949. /**
  61950. * Stores a perspective projection for WebVR info a given matrix
  61951. * @param fov defines the field of view
  61952. * @param znear defines the near clip plane
  61953. * @param zfar defines the far clip plane
  61954. * @param result defines the target matrix
  61955. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  61956. */
  61957. static PerspectiveFovWebVRToRef(fov: {
  61958. upDegrees: number;
  61959. downDegrees: number;
  61960. leftDegrees: number;
  61961. rightDegrees: number;
  61962. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  61963. /**
  61964. * Computes a complete transformation matrix
  61965. * @param viewport defines the viewport to use
  61966. * @param world defines the world matrix
  61967. * @param view defines the view matrix
  61968. * @param projection defines the projection matrix
  61969. * @param zmin defines the near clip plane
  61970. * @param zmax defines the far clip plane
  61971. * @returns the transformation matrix
  61972. */
  61973. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  61974. /**
  61975. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  61976. * @param matrix defines the matrix to use
  61977. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  61978. */
  61979. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  61980. /**
  61981. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  61982. * @param matrix defines the matrix to use
  61983. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  61984. */
  61985. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  61986. /**
  61987. * Compute the transpose of a given matrix
  61988. * @param matrix defines the matrix to transpose
  61989. * @returns the new matrix
  61990. */
  61991. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  61992. /**
  61993. * Compute the transpose of a matrix and store it in a target matrix
  61994. * @param matrix defines the matrix to transpose
  61995. * @param result defines the target matrix
  61996. */
  61997. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  61998. /**
  61999. * Computes a reflection matrix from a plane
  62000. * @param plane defines the reflection plane
  62001. * @returns a new matrix
  62002. */
  62003. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  62004. /**
  62005. * Computes a reflection matrix from a plane
  62006. * @param plane defines the reflection plane
  62007. * @param result defines the target matrix
  62008. */
  62009. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  62010. /**
  62011. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  62012. * @param xaxis defines the value of the 1st axis
  62013. * @param yaxis defines the value of the 2nd axis
  62014. * @param zaxis defines the value of the 3rd axis
  62015. * @param result defines the target matrix
  62016. */
  62017. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  62018. /**
  62019. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  62020. * @param quat defines the quaternion to use
  62021. * @param result defines the target matrix
  62022. */
  62023. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  62024. }
  62025. /**
  62026. * Represens a plane by the equation ax + by + cz + d = 0
  62027. */
  62028. export class Plane {
  62029. /**
  62030. * Normal of the plane (a,b,c)
  62031. */
  62032. normal: Vector3;
  62033. /**
  62034. * d component of the plane
  62035. */
  62036. d: number;
  62037. /**
  62038. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  62039. * @param a a component of the plane
  62040. * @param b b component of the plane
  62041. * @param c c component of the plane
  62042. * @param d d component of the plane
  62043. */
  62044. constructor(a: number, b: number, c: number, d: number);
  62045. /**
  62046. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  62047. */
  62048. asArray(): number[];
  62049. /**
  62050. * @returns a new plane copied from the current Plane.
  62051. */
  62052. clone(): Plane;
  62053. /**
  62054. * @returns the string "Plane".
  62055. */
  62056. getClassName(): string;
  62057. /**
  62058. * @returns the Plane hash code.
  62059. */
  62060. getHashCode(): number;
  62061. /**
  62062. * Normalize the current Plane in place.
  62063. * @returns the updated Plane.
  62064. */
  62065. normalize(): Plane;
  62066. /**
  62067. * Applies a transformation the plane and returns the result
  62068. * @param transformation the transformation matrix to be applied to the plane
  62069. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  62070. */
  62071. transform(transformation: DeepImmutable<Matrix>): Plane;
  62072. /**
  62073. * Calcualtte the dot product between the point and the plane normal
  62074. * @param point point to calculate the dot product with
  62075. * @returns the dot product (float) of the point coordinates and the plane normal.
  62076. */
  62077. dotCoordinate(point: DeepImmutable<Vector3>): number;
  62078. /**
  62079. * Updates the current Plane from the plane defined by the three given points.
  62080. * @param point1 one of the points used to contruct the plane
  62081. * @param point2 one of the points used to contruct the plane
  62082. * @param point3 one of the points used to contruct the plane
  62083. * @returns the updated Plane.
  62084. */
  62085. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  62086. /**
  62087. * Checks if the plane is facing a given direction
  62088. * @param direction the direction to check if the plane is facing
  62089. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  62090. * @returns True is the vector "direction" is the same side than the plane normal.
  62091. */
  62092. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  62093. /**
  62094. * Calculates the distance to a point
  62095. * @param point point to calculate distance to
  62096. * @returns the signed distance (float) from the given point to the Plane.
  62097. */
  62098. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  62099. /**
  62100. * Creates a plane from an array
  62101. * @param array the array to create a plane from
  62102. * @returns a new Plane from the given array.
  62103. */
  62104. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  62105. /**
  62106. * Creates a plane from three points
  62107. * @param point1 point used to create the plane
  62108. * @param point2 point used to create the plane
  62109. * @param point3 point used to create the plane
  62110. * @returns a new Plane defined by the three given points.
  62111. */
  62112. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  62113. /**
  62114. * Creates a plane from an origin point and a normal
  62115. * @param origin origin of the plane to be constructed
  62116. * @param normal normal of the plane to be constructed
  62117. * @returns a new Plane the normal vector to this plane at the given origin point.
  62118. * Note : the vector "normal" is updated because normalized.
  62119. */
  62120. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  62121. /**
  62122. * Calculates the distance from a plane and a point
  62123. * @param origin origin of the plane to be constructed
  62124. * @param normal normal of the plane to be constructed
  62125. * @param point point to calculate distance to
  62126. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  62127. */
  62128. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  62129. }
  62130. /**
  62131. * Class used to represent a viewport on screen
  62132. */
  62133. export class Viewport {
  62134. /** viewport left coordinate */
  62135. x: number;
  62136. /** viewport top coordinate */
  62137. y: number;
  62138. /**viewport width */
  62139. width: number;
  62140. /** viewport height */
  62141. height: number;
  62142. /**
  62143. * Creates a Viewport object located at (x, y) and sized (width, height)
  62144. * @param x defines viewport left coordinate
  62145. * @param y defines viewport top coordinate
  62146. * @param width defines the viewport width
  62147. * @param height defines the viewport height
  62148. */
  62149. constructor(
  62150. /** viewport left coordinate */
  62151. x: number,
  62152. /** viewport top coordinate */
  62153. y: number,
  62154. /**viewport width */
  62155. width: number,
  62156. /** viewport height */
  62157. height: number);
  62158. /**
  62159. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  62160. * @param renderWidth defines the rendering width
  62161. * @param renderHeight defines the rendering height
  62162. * @returns a new Viewport
  62163. */
  62164. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  62165. /**
  62166. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  62167. * @param renderWidth defines the rendering width
  62168. * @param renderHeight defines the rendering height
  62169. * @param ref defines the target viewport
  62170. * @returns the current viewport
  62171. */
  62172. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  62173. /**
  62174. * Returns a new Viewport copied from the current one
  62175. * @returns a new Viewport
  62176. */
  62177. clone(): Viewport;
  62178. }
  62179. /**
  62180. * Reprasents a camera frustum
  62181. */
  62182. export class Frustum {
  62183. /**
  62184. * Gets the planes representing the frustum
  62185. * @param transform matrix to be applied to the returned planes
  62186. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  62187. */
  62188. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  62189. /**
  62190. * Gets the near frustum plane transformed by the transform matrix
  62191. * @param transform transformation matrix to be applied to the resulting frustum plane
  62192. * @param frustumPlane the resuling frustum plane
  62193. */
  62194. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62195. /**
  62196. * Gets the far frustum plane transformed by the transform matrix
  62197. * @param transform transformation matrix to be applied to the resulting frustum plane
  62198. * @param frustumPlane the resuling frustum plane
  62199. */
  62200. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62201. /**
  62202. * Gets the left frustum plane transformed by the transform matrix
  62203. * @param transform transformation matrix to be applied to the resulting frustum plane
  62204. * @param frustumPlane the resuling frustum plane
  62205. */
  62206. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62207. /**
  62208. * Gets the right frustum plane transformed by the transform matrix
  62209. * @param transform transformation matrix to be applied to the resulting frustum plane
  62210. * @param frustumPlane the resuling frustum plane
  62211. */
  62212. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62213. /**
  62214. * Gets the top frustum plane transformed by the transform matrix
  62215. * @param transform transformation matrix to be applied to the resulting frustum plane
  62216. * @param frustumPlane the resuling frustum plane
  62217. */
  62218. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62219. /**
  62220. * Gets the bottom frustum plane transformed by the transform matrix
  62221. * @param transform transformation matrix to be applied to the resulting frustum plane
  62222. * @param frustumPlane the resuling frustum plane
  62223. */
  62224. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62225. /**
  62226. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  62227. * @param transform transformation matrix to be applied to the resulting frustum planes
  62228. * @param frustumPlanes the resuling frustum planes
  62229. */
  62230. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  62231. }
  62232. /** Defines supported spaces */
  62233. export enum Space {
  62234. /** Local (object) space */
  62235. LOCAL = 0,
  62236. /** World space */
  62237. WORLD = 1,
  62238. /** Bone space */
  62239. BONE = 2
  62240. }
  62241. /** Defines the 3 main axes */
  62242. export class Axis {
  62243. /** X axis */
  62244. static X: Vector3;
  62245. /** Y axis */
  62246. static Y: Vector3;
  62247. /** Z axis */
  62248. static Z: Vector3;
  62249. }
  62250. /** Class used to represent a Bezier curve */
  62251. export class BezierCurve {
  62252. /**
  62253. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  62254. * @param t defines the time
  62255. * @param x1 defines the left coordinate on X axis
  62256. * @param y1 defines the left coordinate on Y axis
  62257. * @param x2 defines the right coordinate on X axis
  62258. * @param y2 defines the right coordinate on Y axis
  62259. * @returns the interpolated value
  62260. */
  62261. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  62262. }
  62263. /**
  62264. * Defines potential orientation for back face culling
  62265. */
  62266. export enum Orientation {
  62267. /**
  62268. * Clockwise
  62269. */
  62270. CW = 0,
  62271. /** Counter clockwise */
  62272. CCW = 1
  62273. }
  62274. /**
  62275. * Defines angle representation
  62276. */
  62277. export class Angle {
  62278. private _radians;
  62279. /**
  62280. * Creates an Angle object of "radians" radians (float).
  62281. * @param radians the angle in radians
  62282. */
  62283. constructor(radians: number);
  62284. /**
  62285. * Get value in degrees
  62286. * @returns the Angle value in degrees (float)
  62287. */
  62288. degrees(): number;
  62289. /**
  62290. * Get value in radians
  62291. * @returns the Angle value in radians (float)
  62292. */
  62293. radians(): number;
  62294. /**
  62295. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  62296. * @param a defines first vector
  62297. * @param b defines second vector
  62298. * @returns a new Angle
  62299. */
  62300. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  62301. /**
  62302. * Gets a new Angle object from the given float in radians
  62303. * @param radians defines the angle value in radians
  62304. * @returns a new Angle
  62305. */
  62306. static FromRadians(radians: number): Angle;
  62307. /**
  62308. * Gets a new Angle object from the given float in degrees
  62309. * @param degrees defines the angle value in degrees
  62310. * @returns a new Angle
  62311. */
  62312. static FromDegrees(degrees: number): Angle;
  62313. }
  62314. /**
  62315. * This represents an arc in a 2d space.
  62316. */
  62317. export class Arc2 {
  62318. /** Defines the start point of the arc */
  62319. startPoint: Vector2;
  62320. /** Defines the mid point of the arc */
  62321. midPoint: Vector2;
  62322. /** Defines the end point of the arc */
  62323. endPoint: Vector2;
  62324. /**
  62325. * Defines the center point of the arc.
  62326. */
  62327. centerPoint: Vector2;
  62328. /**
  62329. * Defines the radius of the arc.
  62330. */
  62331. radius: number;
  62332. /**
  62333. * Defines the angle of the arc (from mid point to end point).
  62334. */
  62335. angle: Angle;
  62336. /**
  62337. * Defines the start angle of the arc (from start point to middle point).
  62338. */
  62339. startAngle: Angle;
  62340. /**
  62341. * Defines the orientation of the arc (clock wise/counter clock wise).
  62342. */
  62343. orientation: Orientation;
  62344. /**
  62345. * Creates an Arc object from the three given points : start, middle and end.
  62346. * @param startPoint Defines the start point of the arc
  62347. * @param midPoint Defines the midlle point of the arc
  62348. * @param endPoint Defines the end point of the arc
  62349. */
  62350. constructor(
  62351. /** Defines the start point of the arc */
  62352. startPoint: Vector2,
  62353. /** Defines the mid point of the arc */
  62354. midPoint: Vector2,
  62355. /** Defines the end point of the arc */
  62356. endPoint: Vector2);
  62357. }
  62358. /**
  62359. * Represents a 2D path made up of multiple 2D points
  62360. */
  62361. export class Path2 {
  62362. private _points;
  62363. private _length;
  62364. /**
  62365. * If the path start and end point are the same
  62366. */
  62367. closed: boolean;
  62368. /**
  62369. * Creates a Path2 object from the starting 2D coordinates x and y.
  62370. * @param x the starting points x value
  62371. * @param y the starting points y value
  62372. */
  62373. constructor(x: number, y: number);
  62374. /**
  62375. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  62376. * @param x the added points x value
  62377. * @param y the added points y value
  62378. * @returns the updated Path2.
  62379. */
  62380. addLineTo(x: number, y: number): Path2;
  62381. /**
  62382. * 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.
  62383. * @param midX middle point x value
  62384. * @param midY middle point y value
  62385. * @param endX end point x value
  62386. * @param endY end point y value
  62387. * @param numberOfSegments (default: 36)
  62388. * @returns the updated Path2.
  62389. */
  62390. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  62391. /**
  62392. * Closes the Path2.
  62393. * @returns the Path2.
  62394. */
  62395. close(): Path2;
  62396. /**
  62397. * Gets the sum of the distance between each sequential point in the path
  62398. * @returns the Path2 total length (float).
  62399. */
  62400. length(): number;
  62401. /**
  62402. * Gets the points which construct the path
  62403. * @returns the Path2 internal array of points.
  62404. */
  62405. getPoints(): Vector2[];
  62406. /**
  62407. * Retreives the point at the distance aways from the starting point
  62408. * @param normalizedLengthPosition the length along the path to retreive the point from
  62409. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  62410. */
  62411. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  62412. /**
  62413. * Creates a new path starting from an x and y position
  62414. * @param x starting x value
  62415. * @param y starting y value
  62416. * @returns a new Path2 starting at the coordinates (x, y).
  62417. */
  62418. static StartingAt(x: number, y: number): Path2;
  62419. }
  62420. /**
  62421. * Represents a 3D path made up of multiple 3D points
  62422. */
  62423. export class Path3D {
  62424. /**
  62425. * an array of Vector3, the curve axis of the Path3D
  62426. */
  62427. path: Vector3[];
  62428. private _curve;
  62429. private _distances;
  62430. private _tangents;
  62431. private _normals;
  62432. private _binormals;
  62433. private _raw;
  62434. /**
  62435. * new Path3D(path, normal, raw)
  62436. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  62437. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  62438. * @param path an array of Vector3, the curve axis of the Path3D
  62439. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  62440. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  62441. */
  62442. constructor(
  62443. /**
  62444. * an array of Vector3, the curve axis of the Path3D
  62445. */
  62446. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  62447. /**
  62448. * Returns the Path3D array of successive Vector3 designing its curve.
  62449. * @returns the Path3D array of successive Vector3 designing its curve.
  62450. */
  62451. getCurve(): Vector3[];
  62452. /**
  62453. * Returns an array populated with tangent vectors on each Path3D curve point.
  62454. * @returns an array populated with tangent vectors on each Path3D curve point.
  62455. */
  62456. getTangents(): Vector3[];
  62457. /**
  62458. * Returns an array populated with normal vectors on each Path3D curve point.
  62459. * @returns an array populated with normal vectors on each Path3D curve point.
  62460. */
  62461. getNormals(): Vector3[];
  62462. /**
  62463. * Returns an array populated with binormal vectors on each Path3D curve point.
  62464. * @returns an array populated with binormal vectors on each Path3D curve point.
  62465. */
  62466. getBinormals(): Vector3[];
  62467. /**
  62468. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  62469. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  62470. */
  62471. getDistances(): number[];
  62472. /**
  62473. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  62474. * @param path path which all values are copied into the curves points
  62475. * @param firstNormal which should be projected onto the curve
  62476. * @returns the same object updated.
  62477. */
  62478. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  62479. private _compute;
  62480. private _getFirstNonNullVector;
  62481. private _getLastNonNullVector;
  62482. private _normalVector;
  62483. }
  62484. /**
  62485. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  62486. * A Curve3 is designed from a series of successive Vector3.
  62487. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  62488. */
  62489. export class Curve3 {
  62490. private _points;
  62491. private _length;
  62492. /**
  62493. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  62494. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  62495. * @param v1 (Vector3) the control point
  62496. * @param v2 (Vector3) the end point of the Quadratic Bezier
  62497. * @param nbPoints (integer) the wanted number of points in the curve
  62498. * @returns the created Curve3
  62499. */
  62500. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  62501. /**
  62502. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  62503. * @param v0 (Vector3) the origin point of the Cubic Bezier
  62504. * @param v1 (Vector3) the first control point
  62505. * @param v2 (Vector3) the second control point
  62506. * @param v3 (Vector3) the end point of the Cubic Bezier
  62507. * @param nbPoints (integer) the wanted number of points in the curve
  62508. * @returns the created Curve3
  62509. */
  62510. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  62511. /**
  62512. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  62513. * @param p1 (Vector3) the origin point of the Hermite Spline
  62514. * @param t1 (Vector3) the tangent vector at the origin point
  62515. * @param p2 (Vector3) the end point of the Hermite Spline
  62516. * @param t2 (Vector3) the tangent vector at the end point
  62517. * @param nbPoints (integer) the wanted number of points in the curve
  62518. * @returns the created Curve3
  62519. */
  62520. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  62521. /**
  62522. * Returns a Curve3 object along a CatmullRom Spline curve :
  62523. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  62524. * @param nbPoints (integer) the wanted number of points between each curve control points
  62525. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  62526. * @returns the created Curve3
  62527. */
  62528. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  62529. /**
  62530. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  62531. * A Curve3 is designed from a series of successive Vector3.
  62532. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  62533. * @param points points which make up the curve
  62534. */
  62535. constructor(points: Vector3[]);
  62536. /**
  62537. * @returns the Curve3 stored array of successive Vector3
  62538. */
  62539. getPoints(): Vector3[];
  62540. /**
  62541. * @returns the computed length (float) of the curve.
  62542. */
  62543. length(): number;
  62544. /**
  62545. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  62546. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  62547. * curveA and curveB keep unchanged.
  62548. * @param curve the curve to continue from this curve
  62549. * @returns the newly constructed curve
  62550. */
  62551. continue(curve: DeepImmutable<Curve3>): Curve3;
  62552. private _computeLength;
  62553. }
  62554. /**
  62555. * Contains position and normal vectors for a vertex
  62556. */
  62557. export class PositionNormalVertex {
  62558. /** the position of the vertex (defaut: 0,0,0) */
  62559. position: Vector3;
  62560. /** the normal of the vertex (defaut: 0,1,0) */
  62561. normal: Vector3;
  62562. /**
  62563. * Creates a PositionNormalVertex
  62564. * @param position the position of the vertex (defaut: 0,0,0)
  62565. * @param normal the normal of the vertex (defaut: 0,1,0)
  62566. */
  62567. constructor(
  62568. /** the position of the vertex (defaut: 0,0,0) */
  62569. position?: Vector3,
  62570. /** the normal of the vertex (defaut: 0,1,0) */
  62571. normal?: Vector3);
  62572. /**
  62573. * Clones the PositionNormalVertex
  62574. * @returns the cloned PositionNormalVertex
  62575. */
  62576. clone(): PositionNormalVertex;
  62577. }
  62578. /**
  62579. * Contains position, normal and uv vectors for a vertex
  62580. */
  62581. export class PositionNormalTextureVertex {
  62582. /** the position of the vertex (defaut: 0,0,0) */
  62583. position: Vector3;
  62584. /** the normal of the vertex (defaut: 0,1,0) */
  62585. normal: Vector3;
  62586. /** the uv of the vertex (default: 0,0) */
  62587. uv: Vector2;
  62588. /**
  62589. * Creates a PositionNormalTextureVertex
  62590. * @param position the position of the vertex (defaut: 0,0,0)
  62591. * @param normal the normal of the vertex (defaut: 0,1,0)
  62592. * @param uv the uv of the vertex (default: 0,0)
  62593. */
  62594. constructor(
  62595. /** the position of the vertex (defaut: 0,0,0) */
  62596. position?: Vector3,
  62597. /** the normal of the vertex (defaut: 0,1,0) */
  62598. normal?: Vector3,
  62599. /** the uv of the vertex (default: 0,0) */
  62600. uv?: Vector2);
  62601. /**
  62602. * Clones the PositionNormalTextureVertex
  62603. * @returns the cloned PositionNormalTextureVertex
  62604. */
  62605. clone(): PositionNormalTextureVertex;
  62606. }
  62607. /**
  62608. * @hidden
  62609. */
  62610. export class Tmp {
  62611. static Color3: Color3[];
  62612. static Color4: Color4[];
  62613. static Vector2: Vector2[];
  62614. static Vector3: Vector3[];
  62615. static Vector4: Vector4[];
  62616. static Quaternion: Quaternion[];
  62617. static Matrix: Matrix[];
  62618. }
  62619. }
  62620. declare module BABYLON {
  62621. /**
  62622. * Class used to enable access to offline support
  62623. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  62624. */
  62625. export interface IOfflineProvider {
  62626. /**
  62627. * Gets a boolean indicating if scene must be saved in the database
  62628. */
  62629. enableSceneOffline: boolean;
  62630. /**
  62631. * Gets a boolean indicating if textures must be saved in the database
  62632. */
  62633. enableTexturesOffline: boolean;
  62634. /**
  62635. * Open the offline support and make it available
  62636. * @param successCallback defines the callback to call on success
  62637. * @param errorCallback defines the callback to call on error
  62638. */
  62639. open(successCallback: () => void, errorCallback: () => void): void;
  62640. /**
  62641. * Loads an image from the offline support
  62642. * @param url defines the url to load from
  62643. * @param image defines the target DOM image
  62644. */
  62645. loadImage(url: string, image: HTMLImageElement): void;
  62646. /**
  62647. * Loads a file from offline support
  62648. * @param url defines the URL to load from
  62649. * @param sceneLoaded defines a callback to call on success
  62650. * @param progressCallBack defines a callback to call when progress changed
  62651. * @param errorCallback defines a callback to call on error
  62652. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  62653. */
  62654. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  62655. }
  62656. }
  62657. declare module BABYLON {
  62658. /**
  62659. * A class serves as a medium between the observable and its observers
  62660. */
  62661. export class EventState {
  62662. /**
  62663. * Create a new EventState
  62664. * @param mask defines the mask associated with this state
  62665. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  62666. * @param target defines the original target of the state
  62667. * @param currentTarget defines the current target of the state
  62668. */
  62669. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  62670. /**
  62671. * Initialize the current event state
  62672. * @param mask defines the mask associated with this state
  62673. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  62674. * @param target defines the original target of the state
  62675. * @param currentTarget defines the current target of the state
  62676. * @returns the current event state
  62677. */
  62678. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  62679. /**
  62680. * An Observer can set this property to true to prevent subsequent observers of being notified
  62681. */
  62682. skipNextObservers: boolean;
  62683. /**
  62684. * Get the mask value that were used to trigger the event corresponding to this EventState object
  62685. */
  62686. mask: number;
  62687. /**
  62688. * The object that originally notified the event
  62689. */
  62690. target?: any;
  62691. /**
  62692. * The current object in the bubbling phase
  62693. */
  62694. currentTarget?: any;
  62695. /**
  62696. * This will be populated with the return value of the last function that was executed.
  62697. * If it is the first function in the callback chain it will be the event data.
  62698. */
  62699. lastReturnValue?: any;
  62700. }
  62701. /**
  62702. * Represent an Observer registered to a given Observable object.
  62703. */
  62704. export class Observer<T> {
  62705. /**
  62706. * Defines the callback to call when the observer is notified
  62707. */
  62708. callback: (eventData: T, eventState: EventState) => void;
  62709. /**
  62710. * Defines the mask of the observer (used to filter notifications)
  62711. */
  62712. mask: number;
  62713. /**
  62714. * Defines the current scope used to restore the JS context
  62715. */
  62716. scope: any;
  62717. /** @hidden */
  62718. _willBeUnregistered: boolean;
  62719. /**
  62720. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  62721. */
  62722. unregisterOnNextCall: boolean;
  62723. /**
  62724. * Creates a new observer
  62725. * @param callback defines the callback to call when the observer is notified
  62726. * @param mask defines the mask of the observer (used to filter notifications)
  62727. * @param scope defines the current scope used to restore the JS context
  62728. */
  62729. constructor(
  62730. /**
  62731. * Defines the callback to call when the observer is notified
  62732. */
  62733. callback: (eventData: T, eventState: EventState) => void,
  62734. /**
  62735. * Defines the mask of the observer (used to filter notifications)
  62736. */
  62737. mask: number,
  62738. /**
  62739. * Defines the current scope used to restore the JS context
  62740. */
  62741. scope?: any);
  62742. }
  62743. /**
  62744. * Represent a list of observers registered to multiple Observables object.
  62745. */
  62746. export class MultiObserver<T> {
  62747. private _observers;
  62748. private _observables;
  62749. /**
  62750. * Release associated resources
  62751. */
  62752. dispose(): void;
  62753. /**
  62754. * Raise a callback when one of the observable will notify
  62755. * @param observables defines a list of observables to watch
  62756. * @param callback defines the callback to call on notification
  62757. * @param mask defines the mask used to filter notifications
  62758. * @param scope defines the current scope used to restore the JS context
  62759. * @returns the new MultiObserver
  62760. */
  62761. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  62762. }
  62763. /**
  62764. * The Observable class is a simple implementation of the Observable pattern.
  62765. *
  62766. * 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.
  62767. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  62768. * 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).
  62769. * 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.
  62770. */
  62771. export class Observable<T> {
  62772. private _observers;
  62773. private _eventState;
  62774. private _onObserverAdded;
  62775. /**
  62776. * Creates a new observable
  62777. * @param onObserverAdded defines a callback to call when a new observer is added
  62778. */
  62779. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  62780. /**
  62781. * Create a new Observer with the specified callback
  62782. * @param callback the callback that will be executed for that Observer
  62783. * @param mask the mask used to filter observers
  62784. * @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.
  62785. * @param scope optional scope for the callback to be called from
  62786. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  62787. * @returns the new observer created for the callback
  62788. */
  62789. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  62790. /**
  62791. * Create a new Observer with the specified callback and unregisters after the next notification
  62792. * @param callback the callback that will be executed for that Observer
  62793. * @returns the new observer created for the callback
  62794. */
  62795. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  62796. /**
  62797. * Remove an Observer from the Observable object
  62798. * @param observer the instance of the Observer to remove
  62799. * @returns false if it doesn't belong to this Observable
  62800. */
  62801. remove(observer: Nullable<Observer<T>>): boolean;
  62802. /**
  62803. * Remove a callback from the Observable object
  62804. * @param callback the callback to remove
  62805. * @param scope optional scope. If used only the callbacks with this scope will be removed
  62806. * @returns false if it doesn't belong to this Observable
  62807. */
  62808. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  62809. private _deferUnregister;
  62810. private _remove;
  62811. /**
  62812. * Moves the observable to the top of the observer list making it get called first when notified
  62813. * @param observer the observer to move
  62814. */
  62815. makeObserverTopPriority(observer: Observer<T>): void;
  62816. /**
  62817. * Moves the observable to the bottom of the observer list making it get called last when notified
  62818. * @param observer the observer to move
  62819. */
  62820. makeObserverBottomPriority(observer: Observer<T>): void;
  62821. /**
  62822. * Notify all Observers by calling their respective callback with the given data
  62823. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  62824. * @param eventData defines the data to send to all observers
  62825. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  62826. * @param target defines the original target of the state
  62827. * @param currentTarget defines the current target of the state
  62828. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  62829. */
  62830. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  62831. /**
  62832. * Calling this will execute each callback, expecting it to be a promise or return a value.
  62833. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  62834. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  62835. * and it is crucial that all callbacks will be executed.
  62836. * The order of the callbacks is kept, callbacks are not executed parallel.
  62837. *
  62838. * @param eventData The data to be sent to each callback
  62839. * @param mask is used to filter observers defaults to -1
  62840. * @param target defines the callback target (see EventState)
  62841. * @param currentTarget defines he current object in the bubbling phase
  62842. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  62843. */
  62844. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  62845. /**
  62846. * Notify a specific observer
  62847. * @param observer defines the observer to notify
  62848. * @param eventData defines the data to be sent to each callback
  62849. * @param mask is used to filter observers defaults to -1
  62850. */
  62851. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  62852. /**
  62853. * Gets a boolean indicating if the observable has at least one observer
  62854. * @returns true is the Observable has at least one Observer registered
  62855. */
  62856. hasObservers(): boolean;
  62857. /**
  62858. * Clear the list of observers
  62859. */
  62860. clear(): void;
  62861. /**
  62862. * Clone the current observable
  62863. * @returns a new observable
  62864. */
  62865. clone(): Observable<T>;
  62866. /**
  62867. * Does this observable handles observer registered with a given mask
  62868. * @param mask defines the mask to be tested
  62869. * @return whether or not one observer registered with the given mask is handeled
  62870. **/
  62871. hasSpecificMask(mask?: number): boolean;
  62872. }
  62873. }
  62874. declare module BABYLON {
  62875. /**
  62876. * Class used to help managing file picking and drag'n'drop
  62877. * File Storage
  62878. */
  62879. export class FilesInputStore {
  62880. /**
  62881. * List of files ready to be loaded
  62882. */
  62883. static FilesToLoad: {
  62884. [key: string]: File;
  62885. };
  62886. }
  62887. }
  62888. declare module BABYLON {
  62889. /** Defines the cross module used constants to avoid circular dependncies */
  62890. export class Constants {
  62891. /** Defines that alpha blending is disabled */
  62892. static readonly ALPHA_DISABLE: number;
  62893. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  62894. static readonly ALPHA_ADD: number;
  62895. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  62896. static readonly ALPHA_COMBINE: number;
  62897. /** Defines that alpha blending to DEST - SRC * DEST */
  62898. static readonly ALPHA_SUBTRACT: number;
  62899. /** Defines that alpha blending to SRC * DEST */
  62900. static readonly ALPHA_MULTIPLY: number;
  62901. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  62902. static readonly ALPHA_MAXIMIZED: number;
  62903. /** Defines that alpha blending to SRC + DEST */
  62904. static readonly ALPHA_ONEONE: number;
  62905. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  62906. static readonly ALPHA_PREMULTIPLIED: number;
  62907. /**
  62908. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  62909. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  62910. */
  62911. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  62912. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  62913. static readonly ALPHA_INTERPOLATE: number;
  62914. /**
  62915. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  62916. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  62917. */
  62918. static readonly ALPHA_SCREENMODE: number;
  62919. /** Defines that the ressource is not delayed*/
  62920. static readonly DELAYLOADSTATE_NONE: number;
  62921. /** Defines that the ressource was successfully delay loaded */
  62922. static readonly DELAYLOADSTATE_LOADED: number;
  62923. /** Defines that the ressource is currently delay loading */
  62924. static readonly DELAYLOADSTATE_LOADING: number;
  62925. /** Defines that the ressource is delayed and has not started loading */
  62926. static readonly DELAYLOADSTATE_NOTLOADED: number;
  62927. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  62928. static readonly NEVER: number;
  62929. /** 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 */
  62930. static readonly ALWAYS: number;
  62931. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  62932. static readonly LESS: number;
  62933. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  62934. static readonly EQUAL: number;
  62935. /** 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 */
  62936. static readonly LEQUAL: number;
  62937. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  62938. static readonly GREATER: number;
  62939. /** 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 */
  62940. static readonly GEQUAL: number;
  62941. /** 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 */
  62942. static readonly NOTEQUAL: number;
  62943. /** Passed to stencilOperation to specify that stencil value must be kept */
  62944. static readonly KEEP: number;
  62945. /** Passed to stencilOperation to specify that stencil value must be replaced */
  62946. static readonly REPLACE: number;
  62947. /** Passed to stencilOperation to specify that stencil value must be incremented */
  62948. static readonly INCR: number;
  62949. /** Passed to stencilOperation to specify that stencil value must be decremented */
  62950. static readonly DECR: number;
  62951. /** Passed to stencilOperation to specify that stencil value must be inverted */
  62952. static readonly INVERT: number;
  62953. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  62954. static readonly INCR_WRAP: number;
  62955. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  62956. static readonly DECR_WRAP: number;
  62957. /** Texture is not repeating outside of 0..1 UVs */
  62958. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  62959. /** Texture is repeating outside of 0..1 UVs */
  62960. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  62961. /** Texture is repeating and mirrored */
  62962. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  62963. /** ALPHA */
  62964. static readonly TEXTUREFORMAT_ALPHA: number;
  62965. /** LUMINANCE */
  62966. static readonly TEXTUREFORMAT_LUMINANCE: number;
  62967. /** LUMINANCE_ALPHA */
  62968. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  62969. /** RGB */
  62970. static readonly TEXTUREFORMAT_RGB: number;
  62971. /** RGBA */
  62972. static readonly TEXTUREFORMAT_RGBA: number;
  62973. /** RED */
  62974. static readonly TEXTUREFORMAT_RED: number;
  62975. /** RED (2nd reference) */
  62976. static readonly TEXTUREFORMAT_R: number;
  62977. /** RG */
  62978. static readonly TEXTUREFORMAT_RG: number;
  62979. /** RED_INTEGER */
  62980. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  62981. /** RED_INTEGER (2nd reference) */
  62982. static readonly TEXTUREFORMAT_R_INTEGER: number;
  62983. /** RG_INTEGER */
  62984. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  62985. /** RGB_INTEGER */
  62986. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  62987. /** RGBA_INTEGER */
  62988. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  62989. /** UNSIGNED_BYTE */
  62990. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  62991. /** UNSIGNED_BYTE (2nd reference) */
  62992. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  62993. /** FLOAT */
  62994. static readonly TEXTURETYPE_FLOAT: number;
  62995. /** HALF_FLOAT */
  62996. static readonly TEXTURETYPE_HALF_FLOAT: number;
  62997. /** BYTE */
  62998. static readonly TEXTURETYPE_BYTE: number;
  62999. /** SHORT */
  63000. static readonly TEXTURETYPE_SHORT: number;
  63001. /** UNSIGNED_SHORT */
  63002. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  63003. /** INT */
  63004. static readonly TEXTURETYPE_INT: number;
  63005. /** UNSIGNED_INT */
  63006. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  63007. /** UNSIGNED_SHORT_4_4_4_4 */
  63008. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  63009. /** UNSIGNED_SHORT_5_5_5_1 */
  63010. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  63011. /** UNSIGNED_SHORT_5_6_5 */
  63012. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  63013. /** UNSIGNED_INT_2_10_10_10_REV */
  63014. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  63015. /** UNSIGNED_INT_24_8 */
  63016. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  63017. /** UNSIGNED_INT_10F_11F_11F_REV */
  63018. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  63019. /** UNSIGNED_INT_5_9_9_9_REV */
  63020. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  63021. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  63022. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  63023. /** nearest is mag = nearest and min = nearest and mip = linear */
  63024. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  63025. /** Bilinear is mag = linear and min = linear and mip = nearest */
  63026. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  63027. /** Trilinear is mag = linear and min = linear and mip = linear */
  63028. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  63029. /** nearest is mag = nearest and min = nearest and mip = linear */
  63030. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  63031. /** Bilinear is mag = linear and min = linear and mip = nearest */
  63032. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  63033. /** Trilinear is mag = linear and min = linear and mip = linear */
  63034. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  63035. /** mag = nearest and min = nearest and mip = nearest */
  63036. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  63037. /** mag = nearest and min = linear and mip = nearest */
  63038. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  63039. /** mag = nearest and min = linear and mip = linear */
  63040. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  63041. /** mag = nearest and min = linear and mip = none */
  63042. static readonly TEXTURE_NEAREST_LINEAR: number;
  63043. /** mag = nearest and min = nearest and mip = none */
  63044. static readonly TEXTURE_NEAREST_NEAREST: number;
  63045. /** mag = linear and min = nearest and mip = nearest */
  63046. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  63047. /** mag = linear and min = nearest and mip = linear */
  63048. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  63049. /** mag = linear and min = linear and mip = none */
  63050. static readonly TEXTURE_LINEAR_LINEAR: number;
  63051. /** mag = linear and min = nearest and mip = none */
  63052. static readonly TEXTURE_LINEAR_NEAREST: number;
  63053. /** Explicit coordinates mode */
  63054. static readonly TEXTURE_EXPLICIT_MODE: number;
  63055. /** Spherical coordinates mode */
  63056. static readonly TEXTURE_SPHERICAL_MODE: number;
  63057. /** Planar coordinates mode */
  63058. static readonly TEXTURE_PLANAR_MODE: number;
  63059. /** Cubic coordinates mode */
  63060. static readonly TEXTURE_CUBIC_MODE: number;
  63061. /** Projection coordinates mode */
  63062. static readonly TEXTURE_PROJECTION_MODE: number;
  63063. /** Skybox coordinates mode */
  63064. static readonly TEXTURE_SKYBOX_MODE: number;
  63065. /** Inverse Cubic coordinates mode */
  63066. static readonly TEXTURE_INVCUBIC_MODE: number;
  63067. /** Equirectangular coordinates mode */
  63068. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  63069. /** Equirectangular Fixed coordinates mode */
  63070. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  63071. /** Equirectangular Fixed Mirrored coordinates mode */
  63072. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  63073. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  63074. static readonly SCALEMODE_FLOOR: number;
  63075. /** Defines that texture rescaling will look for the nearest power of 2 size */
  63076. static readonly SCALEMODE_NEAREST: number;
  63077. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  63078. static readonly SCALEMODE_CEILING: number;
  63079. /**
  63080. * The dirty texture flag value
  63081. */
  63082. static readonly MATERIAL_TextureDirtyFlag: number;
  63083. /**
  63084. * The dirty light flag value
  63085. */
  63086. static readonly MATERIAL_LightDirtyFlag: number;
  63087. /**
  63088. * The dirty fresnel flag value
  63089. */
  63090. static readonly MATERIAL_FresnelDirtyFlag: number;
  63091. /**
  63092. * The dirty attribute flag value
  63093. */
  63094. static readonly MATERIAL_AttributesDirtyFlag: number;
  63095. /**
  63096. * The dirty misc flag value
  63097. */
  63098. static readonly MATERIAL_MiscDirtyFlag: number;
  63099. /**
  63100. * The all dirty flag value
  63101. */
  63102. static readonly MATERIAL_AllDirtyFlag: number;
  63103. /**
  63104. * Returns the triangle fill mode
  63105. */
  63106. static readonly MATERIAL_TriangleFillMode: number;
  63107. /**
  63108. * Returns the wireframe mode
  63109. */
  63110. static readonly MATERIAL_WireFrameFillMode: number;
  63111. /**
  63112. * Returns the point fill mode
  63113. */
  63114. static readonly MATERIAL_PointFillMode: number;
  63115. /**
  63116. * Returns the point list draw mode
  63117. */
  63118. static readonly MATERIAL_PointListDrawMode: number;
  63119. /**
  63120. * Returns the line list draw mode
  63121. */
  63122. static readonly MATERIAL_LineListDrawMode: number;
  63123. /**
  63124. * Returns the line loop draw mode
  63125. */
  63126. static readonly MATERIAL_LineLoopDrawMode: number;
  63127. /**
  63128. * Returns the line strip draw mode
  63129. */
  63130. static readonly MATERIAL_LineStripDrawMode: number;
  63131. /**
  63132. * Returns the triangle strip draw mode
  63133. */
  63134. static readonly MATERIAL_TriangleStripDrawMode: number;
  63135. /**
  63136. * Returns the triangle fan draw mode
  63137. */
  63138. static readonly MATERIAL_TriangleFanDrawMode: number;
  63139. /**
  63140. * Stores the clock-wise side orientation
  63141. */
  63142. static readonly MATERIAL_ClockWiseSideOrientation: number;
  63143. /**
  63144. * Stores the counter clock-wise side orientation
  63145. */
  63146. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  63147. /**
  63148. * Nothing
  63149. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63150. */
  63151. static readonly ACTION_NothingTrigger: number;
  63152. /**
  63153. * On pick
  63154. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63155. */
  63156. static readonly ACTION_OnPickTrigger: number;
  63157. /**
  63158. * On left pick
  63159. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63160. */
  63161. static readonly ACTION_OnLeftPickTrigger: number;
  63162. /**
  63163. * On right pick
  63164. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63165. */
  63166. static readonly ACTION_OnRightPickTrigger: number;
  63167. /**
  63168. * On center pick
  63169. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63170. */
  63171. static readonly ACTION_OnCenterPickTrigger: number;
  63172. /**
  63173. * On pick down
  63174. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63175. */
  63176. static readonly ACTION_OnPickDownTrigger: number;
  63177. /**
  63178. * On double pick
  63179. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63180. */
  63181. static readonly ACTION_OnDoublePickTrigger: number;
  63182. /**
  63183. * On pick up
  63184. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63185. */
  63186. static readonly ACTION_OnPickUpTrigger: number;
  63187. /**
  63188. * On pick out.
  63189. * This trigger will only be raised if you also declared a OnPickDown
  63190. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63191. */
  63192. static readonly ACTION_OnPickOutTrigger: number;
  63193. /**
  63194. * On long press
  63195. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63196. */
  63197. static readonly ACTION_OnLongPressTrigger: number;
  63198. /**
  63199. * On pointer over
  63200. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63201. */
  63202. static readonly ACTION_OnPointerOverTrigger: number;
  63203. /**
  63204. * On pointer out
  63205. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63206. */
  63207. static readonly ACTION_OnPointerOutTrigger: number;
  63208. /**
  63209. * On every frame
  63210. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63211. */
  63212. static readonly ACTION_OnEveryFrameTrigger: number;
  63213. /**
  63214. * On intersection enter
  63215. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63216. */
  63217. static readonly ACTION_OnIntersectionEnterTrigger: number;
  63218. /**
  63219. * On intersection exit
  63220. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63221. */
  63222. static readonly ACTION_OnIntersectionExitTrigger: number;
  63223. /**
  63224. * On key down
  63225. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63226. */
  63227. static readonly ACTION_OnKeyDownTrigger: number;
  63228. /**
  63229. * On key up
  63230. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63231. */
  63232. static readonly ACTION_OnKeyUpTrigger: number;
  63233. /**
  63234. * Billboard mode will only apply to Y axis
  63235. */
  63236. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  63237. /**
  63238. * Billboard mode will apply to all axes
  63239. */
  63240. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  63241. /**
  63242. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  63243. */
  63244. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  63245. /**
  63246. * Gets or sets base Assets URL
  63247. */
  63248. static readonly PARTICLES_BaseAssetsUrl: string;
  63249. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  63250. * Test order :
  63251. * Is the bounding sphere outside the frustum ?
  63252. * If not, are the bounding box vertices outside the frustum ?
  63253. * It not, then the cullable object is in the frustum.
  63254. */
  63255. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  63256. /** Culling strategy : Bounding Sphere Only.
  63257. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  63258. * It's also less accurate than the standard because some not visible objects can still be selected.
  63259. * Test : is the bounding sphere outside the frustum ?
  63260. * If not, then the cullable object is in the frustum.
  63261. */
  63262. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  63263. /** Culling strategy : Optimistic Inclusion.
  63264. * This in an inclusion test first, then the standard exclusion test.
  63265. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  63266. * 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.
  63267. * Anyway, it's as accurate as the standard strategy.
  63268. * Test :
  63269. * Is the cullable object bounding sphere center in the frustum ?
  63270. * If not, apply the default culling strategy.
  63271. */
  63272. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  63273. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  63274. * This in an inclusion test first, then the bounding sphere only exclusion test.
  63275. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  63276. * 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.
  63277. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  63278. * Test :
  63279. * Is the cullable object bounding sphere center in the frustum ?
  63280. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  63281. */
  63282. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  63283. /**
  63284. * No logging while loading
  63285. */
  63286. static readonly SCENELOADER_NO_LOGGING: number;
  63287. /**
  63288. * Minimal logging while loading
  63289. */
  63290. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  63291. /**
  63292. * Summary logging while loading
  63293. */
  63294. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  63295. /**
  63296. * Detailled logging while loading
  63297. */
  63298. static readonly SCENELOADER_DETAILED_LOGGING: number;
  63299. }
  63300. }
  63301. declare module BABYLON {
  63302. /**
  63303. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  63304. * Babylon.js
  63305. */
  63306. export class DomManagement {
  63307. /**
  63308. * Checks if the window object exists
  63309. * @returns true if the window object exists
  63310. */
  63311. static IsWindowObjectExist(): boolean;
  63312. /**
  63313. * Extracts text content from a DOM element hierarchy
  63314. * @param element defines the root element
  63315. * @returns a string
  63316. */
  63317. static GetDOMTextContent(element: HTMLElement): string;
  63318. }
  63319. }
  63320. declare module BABYLON {
  63321. /**
  63322. * Logger used througouht the application to allow configuration of
  63323. * the log level required for the messages.
  63324. */
  63325. export class Logger {
  63326. /**
  63327. * No log
  63328. */
  63329. static readonly NoneLogLevel: number;
  63330. /**
  63331. * Only message logs
  63332. */
  63333. static readonly MessageLogLevel: number;
  63334. /**
  63335. * Only warning logs
  63336. */
  63337. static readonly WarningLogLevel: number;
  63338. /**
  63339. * Only error logs
  63340. */
  63341. static readonly ErrorLogLevel: number;
  63342. /**
  63343. * All logs
  63344. */
  63345. static readonly AllLogLevel: number;
  63346. private static _LogCache;
  63347. /**
  63348. * Gets a value indicating the number of loading errors
  63349. * @ignorenaming
  63350. */
  63351. static errorsCount: number;
  63352. /**
  63353. * Callback called when a new log is added
  63354. */
  63355. static OnNewCacheEntry: (entry: string) => void;
  63356. private static _AddLogEntry;
  63357. private static _FormatMessage;
  63358. private static _LogDisabled;
  63359. private static _LogEnabled;
  63360. private static _WarnDisabled;
  63361. private static _WarnEnabled;
  63362. private static _ErrorDisabled;
  63363. private static _ErrorEnabled;
  63364. /**
  63365. * Log a message to the console
  63366. */
  63367. static Log: (message: string) => void;
  63368. /**
  63369. * Write a warning message to the console
  63370. */
  63371. static Warn: (message: string) => void;
  63372. /**
  63373. * Write an error message to the console
  63374. */
  63375. static Error: (message: string) => void;
  63376. /**
  63377. * Gets current log cache (list of logs)
  63378. */
  63379. static readonly LogCache: string;
  63380. /**
  63381. * Clears the log cache
  63382. */
  63383. static ClearLogCache(): void;
  63384. /**
  63385. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  63386. */
  63387. static LogLevels: number;
  63388. }
  63389. }
  63390. declare module BABYLON {
  63391. /** @hidden */
  63392. export class _TypeStore {
  63393. /** @hidden */
  63394. static RegisteredTypes: {
  63395. [key: string]: Object;
  63396. };
  63397. /** @hidden */
  63398. static GetClass(fqdn: string): any;
  63399. }
  63400. }
  63401. declare module BABYLON {
  63402. /**
  63403. * Class containing a set of static utilities functions for deep copy.
  63404. */
  63405. export class DeepCopier {
  63406. /**
  63407. * Tries to copy an object by duplicating every property
  63408. * @param source defines the source object
  63409. * @param destination defines the target object
  63410. * @param doNotCopyList defines a list of properties to avoid
  63411. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  63412. */
  63413. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  63414. }
  63415. }
  63416. declare module BABYLON {
  63417. /**
  63418. * Class containing a set of static utilities functions for precision date
  63419. */
  63420. export class PrecisionDate {
  63421. /**
  63422. * Gets either window.performance.now() if supported or Date.now() else
  63423. */
  63424. static readonly Now: number;
  63425. }
  63426. }
  63427. declare module BABYLON {
  63428. /** @hidden */
  63429. export class _DevTools {
  63430. static WarnImport(name: string): string;
  63431. }
  63432. }
  63433. declare module BABYLON {
  63434. /**
  63435. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  63436. */
  63437. export class WebRequest {
  63438. private _xhr;
  63439. /**
  63440. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  63441. * i.e. when loading files, where the server/service expects an Authorization header
  63442. */
  63443. static CustomRequestHeaders: {
  63444. [key: string]: string;
  63445. };
  63446. /**
  63447. * Add callback functions in this array to update all the requests before they get sent to the network
  63448. */
  63449. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  63450. private _injectCustomRequestHeaders;
  63451. /**
  63452. * Gets or sets a function to be called when loading progress changes
  63453. */
  63454. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  63455. /**
  63456. * Returns client's state
  63457. */
  63458. readonly readyState: number;
  63459. /**
  63460. * Returns client's status
  63461. */
  63462. readonly status: number;
  63463. /**
  63464. * Returns client's status as a text
  63465. */
  63466. readonly statusText: string;
  63467. /**
  63468. * Returns client's response
  63469. */
  63470. readonly response: any;
  63471. /**
  63472. * Returns client's response url
  63473. */
  63474. readonly responseURL: string;
  63475. /**
  63476. * Returns client's response as text
  63477. */
  63478. readonly responseText: string;
  63479. /**
  63480. * Gets or sets the expected response type
  63481. */
  63482. responseType: XMLHttpRequestResponseType;
  63483. /** @hidden */
  63484. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  63485. /** @hidden */
  63486. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  63487. /**
  63488. * Cancels any network activity
  63489. */
  63490. abort(): void;
  63491. /**
  63492. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  63493. * @param body defines an optional request body
  63494. */
  63495. send(body?: Document | BodyInit | null): void;
  63496. /**
  63497. * Sets the request method, request URL
  63498. * @param method defines the method to use (GET, POST, etc..)
  63499. * @param url defines the url to connect with
  63500. */
  63501. open(method: string, url: string): void;
  63502. }
  63503. }
  63504. declare module BABYLON {
  63505. /**
  63506. * Class used to evalaute queries containing `and` and `or` operators
  63507. */
  63508. export class AndOrNotEvaluator {
  63509. /**
  63510. * Evaluate a query
  63511. * @param query defines the query to evaluate
  63512. * @param evaluateCallback defines the callback used to filter result
  63513. * @returns true if the query matches
  63514. */
  63515. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  63516. private static _HandleParenthesisContent;
  63517. private static _SimplifyNegation;
  63518. }
  63519. }
  63520. declare module BABYLON {
  63521. /**
  63522. * Class used to store custom tags
  63523. */
  63524. export class Tags {
  63525. /**
  63526. * Adds support for tags on the given object
  63527. * @param obj defines the object to use
  63528. */
  63529. static EnableFor(obj: any): void;
  63530. /**
  63531. * Removes tags support
  63532. * @param obj defines the object to use
  63533. */
  63534. static DisableFor(obj: any): void;
  63535. /**
  63536. * Gets a boolean indicating if the given object has tags
  63537. * @param obj defines the object to use
  63538. * @returns a boolean
  63539. */
  63540. static HasTags(obj: any): boolean;
  63541. /**
  63542. * Gets the tags available on a given object
  63543. * @param obj defines the object to use
  63544. * @param asString defines if the tags must be returned as a string instead of an array of strings
  63545. * @returns the tags
  63546. */
  63547. static GetTags(obj: any, asString?: boolean): any;
  63548. /**
  63549. * Adds tags to an object
  63550. * @param obj defines the object to use
  63551. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  63552. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  63553. */
  63554. static AddTagsTo(obj: any, tagsString: string): void;
  63555. /**
  63556. * @hidden
  63557. */
  63558. static _AddTagTo(obj: any, tag: string): void;
  63559. /**
  63560. * Removes specific tags from a specific object
  63561. * @param obj defines the object to use
  63562. * @param tagsString defines the tags to remove
  63563. */
  63564. static RemoveTagsFrom(obj: any, tagsString: string): void;
  63565. /**
  63566. * @hidden
  63567. */
  63568. static _RemoveTagFrom(obj: any, tag: string): void;
  63569. /**
  63570. * Defines if tags hosted on an object match a given query
  63571. * @param obj defines the object to use
  63572. * @param tagsQuery defines the tag query
  63573. * @returns a boolean
  63574. */
  63575. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  63576. }
  63577. }
  63578. declare module BABYLON {
  63579. /**
  63580. * Manages the defines for the Material
  63581. */
  63582. export class MaterialDefines {
  63583. private _keys;
  63584. private _isDirty;
  63585. /** @hidden */
  63586. _renderId: number;
  63587. /** @hidden */
  63588. _areLightsDirty: boolean;
  63589. /** @hidden */
  63590. _areAttributesDirty: boolean;
  63591. /** @hidden */
  63592. _areTexturesDirty: boolean;
  63593. /** @hidden */
  63594. _areFresnelDirty: boolean;
  63595. /** @hidden */
  63596. _areMiscDirty: boolean;
  63597. /** @hidden */
  63598. _areImageProcessingDirty: boolean;
  63599. /** @hidden */
  63600. _normals: boolean;
  63601. /** @hidden */
  63602. _uvs: boolean;
  63603. /** @hidden */
  63604. _needNormals: boolean;
  63605. /** @hidden */
  63606. _needUVs: boolean;
  63607. /**
  63608. * Specifies if the material needs to be re-calculated
  63609. */
  63610. readonly isDirty: boolean;
  63611. /**
  63612. * Marks the material to indicate that it has been re-calculated
  63613. */
  63614. markAsProcessed(): void;
  63615. /**
  63616. * Marks the material to indicate that it needs to be re-calculated
  63617. */
  63618. markAsUnprocessed(): void;
  63619. /**
  63620. * Marks the material to indicate all of its defines need to be re-calculated
  63621. */
  63622. markAllAsDirty(): void;
  63623. /**
  63624. * Marks the material to indicate that image processing needs to be re-calculated
  63625. */
  63626. markAsImageProcessingDirty(): void;
  63627. /**
  63628. * Marks the material to indicate the lights need to be re-calculated
  63629. */
  63630. markAsLightDirty(): void;
  63631. /**
  63632. * Marks the attribute state as changed
  63633. */
  63634. markAsAttributesDirty(): void;
  63635. /**
  63636. * Marks the texture state as changed
  63637. */
  63638. markAsTexturesDirty(): void;
  63639. /**
  63640. * Marks the fresnel state as changed
  63641. */
  63642. markAsFresnelDirty(): void;
  63643. /**
  63644. * Marks the misc state as changed
  63645. */
  63646. markAsMiscDirty(): void;
  63647. /**
  63648. * Rebuilds the material defines
  63649. */
  63650. rebuild(): void;
  63651. /**
  63652. * Specifies if two material defines are equal
  63653. * @param other - A material define instance to compare to
  63654. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  63655. */
  63656. isEqual(other: MaterialDefines): boolean;
  63657. /**
  63658. * Clones this instance's defines to another instance
  63659. * @param other - material defines to clone values to
  63660. */
  63661. cloneTo(other: MaterialDefines): void;
  63662. /**
  63663. * Resets the material define values
  63664. */
  63665. reset(): void;
  63666. /**
  63667. * Converts the material define values to a string
  63668. * @returns - String of material define information
  63669. */
  63670. toString(): string;
  63671. }
  63672. }
  63673. declare module BABYLON {
  63674. /**
  63675. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  63676. */
  63677. export class PerformanceMonitor {
  63678. private _enabled;
  63679. private _rollingFrameTime;
  63680. private _lastFrameTimeMs;
  63681. /**
  63682. * constructor
  63683. * @param frameSampleSize The number of samples required to saturate the sliding window
  63684. */
  63685. constructor(frameSampleSize?: number);
  63686. /**
  63687. * Samples current frame
  63688. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  63689. */
  63690. sampleFrame(timeMs?: number): void;
  63691. /**
  63692. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  63693. */
  63694. readonly averageFrameTime: number;
  63695. /**
  63696. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  63697. */
  63698. readonly averageFrameTimeVariance: number;
  63699. /**
  63700. * Returns the frame time of the most recent frame
  63701. */
  63702. readonly instantaneousFrameTime: number;
  63703. /**
  63704. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  63705. */
  63706. readonly averageFPS: number;
  63707. /**
  63708. * Returns the average framerate in frames per second using the most recent frame time
  63709. */
  63710. readonly instantaneousFPS: number;
  63711. /**
  63712. * Returns true if enough samples have been taken to completely fill the sliding window
  63713. */
  63714. readonly isSaturated: boolean;
  63715. /**
  63716. * Enables contributions to the sliding window sample set
  63717. */
  63718. enable(): void;
  63719. /**
  63720. * Disables contributions to the sliding window sample set
  63721. * Samples will not be interpolated over the disabled period
  63722. */
  63723. disable(): void;
  63724. /**
  63725. * Returns true if sampling is enabled
  63726. */
  63727. readonly isEnabled: boolean;
  63728. /**
  63729. * Resets performance monitor
  63730. */
  63731. reset(): void;
  63732. }
  63733. /**
  63734. * RollingAverage
  63735. *
  63736. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  63737. */
  63738. export class RollingAverage {
  63739. /**
  63740. * Current average
  63741. */
  63742. average: number;
  63743. /**
  63744. * Current variance
  63745. */
  63746. variance: number;
  63747. protected _samples: Array<number>;
  63748. protected _sampleCount: number;
  63749. protected _pos: number;
  63750. protected _m2: number;
  63751. /**
  63752. * constructor
  63753. * @param length The number of samples required to saturate the sliding window
  63754. */
  63755. constructor(length: number);
  63756. /**
  63757. * Adds a sample to the sample set
  63758. * @param v The sample value
  63759. */
  63760. add(v: number): void;
  63761. /**
  63762. * Returns previously added values or null if outside of history or outside the sliding window domain
  63763. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  63764. * @return Value previously recorded with add() or null if outside of range
  63765. */
  63766. history(i: number): number;
  63767. /**
  63768. * Returns true if enough samples have been taken to completely fill the sliding window
  63769. * @return true if sample-set saturated
  63770. */
  63771. isSaturated(): boolean;
  63772. /**
  63773. * Resets the rolling average (equivalent to 0 samples taken so far)
  63774. */
  63775. reset(): void;
  63776. /**
  63777. * Wraps a value around the sample range boundaries
  63778. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  63779. * @return Wrapped position in sample range
  63780. */
  63781. protected _wrapPosition(i: number): number;
  63782. }
  63783. }
  63784. declare module BABYLON {
  63785. /**
  63786. * This class implement a typical dictionary using a string as key and the generic type T as value.
  63787. * The underlying implementation relies on an associative array to ensure the best performances.
  63788. * The value can be anything including 'null' but except 'undefined'
  63789. */
  63790. export class StringDictionary<T> {
  63791. /**
  63792. * This will clear this dictionary and copy the content from the 'source' one.
  63793. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  63794. * @param source the dictionary to take the content from and copy to this dictionary
  63795. */
  63796. copyFrom(source: StringDictionary<T>): void;
  63797. /**
  63798. * Get a value based from its key
  63799. * @param key the given key to get the matching value from
  63800. * @return the value if found, otherwise undefined is returned
  63801. */
  63802. get(key: string): T | undefined;
  63803. /**
  63804. * Get a value from its key or add it if it doesn't exist.
  63805. * This method will ensure you that a given key/data will be present in the dictionary.
  63806. * @param key the given key to get the matching value from
  63807. * @param factory the factory that will create the value if the key is not present in the dictionary.
  63808. * The factory will only be invoked if there's no data for the given key.
  63809. * @return the value corresponding to the key.
  63810. */
  63811. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  63812. /**
  63813. * Get a value from its key if present in the dictionary otherwise add it
  63814. * @param key the key to get the value from
  63815. * @param val if there's no such key/value pair in the dictionary add it with this value
  63816. * @return the value corresponding to the key
  63817. */
  63818. getOrAdd(key: string, val: T): T;
  63819. /**
  63820. * Check if there's a given key in the dictionary
  63821. * @param key the key to check for
  63822. * @return true if the key is present, false otherwise
  63823. */
  63824. contains(key: string): boolean;
  63825. /**
  63826. * Add a new key and its corresponding value
  63827. * @param key the key to add
  63828. * @param value the value corresponding to the key
  63829. * @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
  63830. */
  63831. add(key: string, value: T): boolean;
  63832. /**
  63833. * Update a specific value associated to a key
  63834. * @param key defines the key to use
  63835. * @param value defines the value to store
  63836. * @returns true if the value was updated (or false if the key was not found)
  63837. */
  63838. set(key: string, value: T): boolean;
  63839. /**
  63840. * Get the element of the given key and remove it from the dictionary
  63841. * @param key defines the key to search
  63842. * @returns the value associated with the key or null if not found
  63843. */
  63844. getAndRemove(key: string): Nullable<T>;
  63845. /**
  63846. * Remove a key/value from the dictionary.
  63847. * @param key the key to remove
  63848. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  63849. */
  63850. remove(key: string): boolean;
  63851. /**
  63852. * Clear the whole content of the dictionary
  63853. */
  63854. clear(): void;
  63855. /**
  63856. * Gets the current count
  63857. */
  63858. readonly count: number;
  63859. /**
  63860. * Execute a callback on each key/val of the dictionary.
  63861. * Note that you can remove any element in this dictionary in the callback implementation
  63862. * @param callback the callback to execute on a given key/value pair
  63863. */
  63864. forEach(callback: (key: string, val: T) => void): void;
  63865. /**
  63866. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  63867. * If the callback returns null or undefined the method will iterate to the next key/value pair
  63868. * Note that you can remove any element in this dictionary in the callback implementation
  63869. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  63870. * @returns the first item
  63871. */
  63872. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  63873. private _count;
  63874. private _data;
  63875. }
  63876. }
  63877. declare module BABYLON {
  63878. /**
  63879. * Helper class that provides a small promise polyfill
  63880. */
  63881. export class PromisePolyfill {
  63882. /**
  63883. * Static function used to check if the polyfill is required
  63884. * If this is the case then the function will inject the polyfill to window.Promise
  63885. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  63886. */
  63887. static Apply(force?: boolean): void;
  63888. }
  63889. }
  63890. declare module BABYLON {
  63891. /**
  63892. * Class used to store data that will be store in GPU memory
  63893. */
  63894. export class Buffer {
  63895. private _engine;
  63896. private _buffer;
  63897. /** @hidden */
  63898. _data: Nullable<DataArray>;
  63899. private _updatable;
  63900. private _instanced;
  63901. /**
  63902. * Gets the byte stride.
  63903. */
  63904. readonly byteStride: number;
  63905. /**
  63906. * Constructor
  63907. * @param engine the engine
  63908. * @param data the data to use for this buffer
  63909. * @param updatable whether the data is updatable
  63910. * @param stride the stride (optional)
  63911. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  63912. * @param instanced whether the buffer is instanced (optional)
  63913. * @param useBytes set to true if the stride in in bytes (optional)
  63914. */
  63915. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  63916. /**
  63917. * Create a new VertexBuffer based on the current buffer
  63918. * @param kind defines the vertex buffer kind (position, normal, etc.)
  63919. * @param offset defines offset in the buffer (0 by default)
  63920. * @param size defines the size in floats of attributes (position is 3 for instance)
  63921. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  63922. * @param instanced defines if the vertex buffer contains indexed data
  63923. * @param useBytes defines if the offset and stride are in bytes
  63924. * @returns the new vertex buffer
  63925. */
  63926. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  63927. /**
  63928. * Gets a boolean indicating if the Buffer is updatable?
  63929. * @returns true if the buffer is updatable
  63930. */
  63931. isUpdatable(): boolean;
  63932. /**
  63933. * Gets current buffer's data
  63934. * @returns a DataArray or null
  63935. */
  63936. getData(): Nullable<DataArray>;
  63937. /**
  63938. * Gets underlying native buffer
  63939. * @returns underlying native buffer
  63940. */
  63941. getBuffer(): Nullable<WebGLBuffer>;
  63942. /**
  63943. * Gets the stride in float32 units (i.e. byte stride / 4).
  63944. * May not be an integer if the byte stride is not divisible by 4.
  63945. * DEPRECATED. Use byteStride instead.
  63946. * @returns the stride in float32 units
  63947. */
  63948. getStrideSize(): number;
  63949. /**
  63950. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  63951. * @param data defines the data to store
  63952. */
  63953. create(data?: Nullable<DataArray>): void;
  63954. /** @hidden */
  63955. _rebuild(): void;
  63956. /**
  63957. * Update current buffer data
  63958. * @param data defines the data to store
  63959. */
  63960. update(data: DataArray): void;
  63961. /**
  63962. * Updates the data directly.
  63963. * @param data the new data
  63964. * @param offset the new offset
  63965. * @param vertexCount the vertex count (optional)
  63966. * @param useBytes set to true if the offset is in bytes
  63967. */
  63968. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  63969. /**
  63970. * Release all resources
  63971. */
  63972. dispose(): void;
  63973. }
  63974. /**
  63975. * Specialized buffer used to store vertex data
  63976. */
  63977. export class VertexBuffer {
  63978. /** @hidden */
  63979. _buffer: Buffer;
  63980. private _kind;
  63981. private _size;
  63982. private _ownsBuffer;
  63983. private _instanced;
  63984. private _instanceDivisor;
  63985. /**
  63986. * The byte type.
  63987. */
  63988. static readonly BYTE: number;
  63989. /**
  63990. * The unsigned byte type.
  63991. */
  63992. static readonly UNSIGNED_BYTE: number;
  63993. /**
  63994. * The short type.
  63995. */
  63996. static readonly SHORT: number;
  63997. /**
  63998. * The unsigned short type.
  63999. */
  64000. static readonly UNSIGNED_SHORT: number;
  64001. /**
  64002. * The integer type.
  64003. */
  64004. static readonly INT: number;
  64005. /**
  64006. * The unsigned integer type.
  64007. */
  64008. static readonly UNSIGNED_INT: number;
  64009. /**
  64010. * The float type.
  64011. */
  64012. static readonly FLOAT: number;
  64013. /**
  64014. * Gets or sets the instance divisor when in instanced mode
  64015. */
  64016. instanceDivisor: number;
  64017. /**
  64018. * Gets the byte stride.
  64019. */
  64020. readonly byteStride: number;
  64021. /**
  64022. * Gets the byte offset.
  64023. */
  64024. readonly byteOffset: number;
  64025. /**
  64026. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  64027. */
  64028. readonly normalized: boolean;
  64029. /**
  64030. * Gets the data type of each component in the array.
  64031. */
  64032. readonly type: number;
  64033. /**
  64034. * Constructor
  64035. * @param engine the engine
  64036. * @param data the data to use for this vertex buffer
  64037. * @param kind the vertex buffer kind
  64038. * @param updatable whether the data is updatable
  64039. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  64040. * @param stride the stride (optional)
  64041. * @param instanced whether the buffer is instanced (optional)
  64042. * @param offset the offset of the data (optional)
  64043. * @param size the number of components (optional)
  64044. * @param type the type of the component (optional)
  64045. * @param normalized whether the data contains normalized data (optional)
  64046. * @param useBytes set to true if stride and offset are in bytes (optional)
  64047. */
  64048. 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);
  64049. /** @hidden */
  64050. _rebuild(): void;
  64051. /**
  64052. * Returns the kind of the VertexBuffer (string)
  64053. * @returns a string
  64054. */
  64055. getKind(): string;
  64056. /**
  64057. * Gets a boolean indicating if the VertexBuffer is updatable?
  64058. * @returns true if the buffer is updatable
  64059. */
  64060. isUpdatable(): boolean;
  64061. /**
  64062. * Gets current buffer's data
  64063. * @returns a DataArray or null
  64064. */
  64065. getData(): Nullable<DataArray>;
  64066. /**
  64067. * Gets underlying native buffer
  64068. * @returns underlying native buffer
  64069. */
  64070. getBuffer(): Nullable<WebGLBuffer>;
  64071. /**
  64072. * Gets the stride in float32 units (i.e. byte stride / 4).
  64073. * May not be an integer if the byte stride is not divisible by 4.
  64074. * DEPRECATED. Use byteStride instead.
  64075. * @returns the stride in float32 units
  64076. */
  64077. getStrideSize(): number;
  64078. /**
  64079. * Returns the offset as a multiple of the type byte length.
  64080. * DEPRECATED. Use byteOffset instead.
  64081. * @returns the offset in bytes
  64082. */
  64083. getOffset(): number;
  64084. /**
  64085. * Returns the number of components per vertex attribute (integer)
  64086. * @returns the size in float
  64087. */
  64088. getSize(): number;
  64089. /**
  64090. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  64091. * @returns true if this buffer is instanced
  64092. */
  64093. getIsInstanced(): boolean;
  64094. /**
  64095. * Returns the instancing divisor, zero for non-instanced (integer).
  64096. * @returns a number
  64097. */
  64098. getInstanceDivisor(): number;
  64099. /**
  64100. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  64101. * @param data defines the data to store
  64102. */
  64103. create(data?: DataArray): void;
  64104. /**
  64105. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  64106. * This function will create a new buffer if the current one is not updatable
  64107. * @param data defines the data to store
  64108. */
  64109. update(data: DataArray): void;
  64110. /**
  64111. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  64112. * Returns the directly updated WebGLBuffer.
  64113. * @param data the new data
  64114. * @param offset the new offset
  64115. * @param useBytes set to true if the offset is in bytes
  64116. */
  64117. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  64118. /**
  64119. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  64120. */
  64121. dispose(): void;
  64122. /**
  64123. * Enumerates each value of this vertex buffer as numbers.
  64124. * @param count the number of values to enumerate
  64125. * @param callback the callback function called for each value
  64126. */
  64127. forEach(count: number, callback: (value: number, index: number) => void): void;
  64128. /**
  64129. * Positions
  64130. */
  64131. static readonly PositionKind: string;
  64132. /**
  64133. * Normals
  64134. */
  64135. static readonly NormalKind: string;
  64136. /**
  64137. * Tangents
  64138. */
  64139. static readonly TangentKind: string;
  64140. /**
  64141. * Texture coordinates
  64142. */
  64143. static readonly UVKind: string;
  64144. /**
  64145. * Texture coordinates 2
  64146. */
  64147. static readonly UV2Kind: string;
  64148. /**
  64149. * Texture coordinates 3
  64150. */
  64151. static readonly UV3Kind: string;
  64152. /**
  64153. * Texture coordinates 4
  64154. */
  64155. static readonly UV4Kind: string;
  64156. /**
  64157. * Texture coordinates 5
  64158. */
  64159. static readonly UV5Kind: string;
  64160. /**
  64161. * Texture coordinates 6
  64162. */
  64163. static readonly UV6Kind: string;
  64164. /**
  64165. * Colors
  64166. */
  64167. static readonly ColorKind: string;
  64168. /**
  64169. * Matrix indices (for bones)
  64170. */
  64171. static readonly MatricesIndicesKind: string;
  64172. /**
  64173. * Matrix weights (for bones)
  64174. */
  64175. static readonly MatricesWeightsKind: string;
  64176. /**
  64177. * Additional matrix indices (for bones)
  64178. */
  64179. static readonly MatricesIndicesExtraKind: string;
  64180. /**
  64181. * Additional matrix weights (for bones)
  64182. */
  64183. static readonly MatricesWeightsExtraKind: string;
  64184. /**
  64185. * Deduces the stride given a kind.
  64186. * @param kind The kind string to deduce
  64187. * @returns The deduced stride
  64188. */
  64189. static DeduceStride(kind: string): number;
  64190. /**
  64191. * Gets the byte length of the given type.
  64192. * @param type the type
  64193. * @returns the number of bytes
  64194. */
  64195. static GetTypeByteLength(type: number): number;
  64196. /**
  64197. * Enumerates each value of the given parameters as numbers.
  64198. * @param data the data to enumerate
  64199. * @param byteOffset the byte offset of the data
  64200. * @param byteStride the byte stride of the data
  64201. * @param componentCount the number of components per element
  64202. * @param componentType the type of the component
  64203. * @param count the total number of components
  64204. * @param normalized whether the data is normalized
  64205. * @param callback the callback function called for each value
  64206. */
  64207. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  64208. private static _GetFloatValue;
  64209. }
  64210. }
  64211. declare module BABYLON {
  64212. /**
  64213. * Class representing spherical polynomial coefficients to the 3rd degree
  64214. */
  64215. export class SphericalPolynomial {
  64216. /**
  64217. * The x coefficients of the spherical polynomial
  64218. */
  64219. x: Vector3;
  64220. /**
  64221. * The y coefficients of the spherical polynomial
  64222. */
  64223. y: Vector3;
  64224. /**
  64225. * The z coefficients of the spherical polynomial
  64226. */
  64227. z: Vector3;
  64228. /**
  64229. * The xx coefficients of the spherical polynomial
  64230. */
  64231. xx: Vector3;
  64232. /**
  64233. * The yy coefficients of the spherical polynomial
  64234. */
  64235. yy: Vector3;
  64236. /**
  64237. * The zz coefficients of the spherical polynomial
  64238. */
  64239. zz: Vector3;
  64240. /**
  64241. * The xy coefficients of the spherical polynomial
  64242. */
  64243. xy: Vector3;
  64244. /**
  64245. * The yz coefficients of the spherical polynomial
  64246. */
  64247. yz: Vector3;
  64248. /**
  64249. * The zx coefficients of the spherical polynomial
  64250. */
  64251. zx: Vector3;
  64252. /**
  64253. * Adds an ambient color to the spherical polynomial
  64254. * @param color the color to add
  64255. */
  64256. addAmbient(color: Color3): void;
  64257. /**
  64258. * Scales the spherical polynomial by the given amount
  64259. * @param scale the amount to scale
  64260. */
  64261. scale(scale: number): void;
  64262. /**
  64263. * Gets the spherical polynomial from harmonics
  64264. * @param harmonics the spherical harmonics
  64265. * @returns the spherical polynomial
  64266. */
  64267. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  64268. /**
  64269. * Constructs a spherical polynomial from an array.
  64270. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  64271. * @returns the spherical polynomial
  64272. */
  64273. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  64274. }
  64275. /**
  64276. * Class representing spherical harmonics coefficients to the 3rd degree
  64277. */
  64278. export class SphericalHarmonics {
  64279. /**
  64280. * The l0,0 coefficients of the spherical harmonics
  64281. */
  64282. l00: Vector3;
  64283. /**
  64284. * The l1,-1 coefficients of the spherical harmonics
  64285. */
  64286. l1_1: Vector3;
  64287. /**
  64288. * The l1,0 coefficients of the spherical harmonics
  64289. */
  64290. l10: Vector3;
  64291. /**
  64292. * The l1,1 coefficients of the spherical harmonics
  64293. */
  64294. l11: Vector3;
  64295. /**
  64296. * The l2,-2 coefficients of the spherical harmonics
  64297. */
  64298. l2_2: Vector3;
  64299. /**
  64300. * The l2,-1 coefficients of the spherical harmonics
  64301. */
  64302. l2_1: Vector3;
  64303. /**
  64304. * The l2,0 coefficients of the spherical harmonics
  64305. */
  64306. l20: Vector3;
  64307. /**
  64308. * The l2,1 coefficients of the spherical harmonics
  64309. */
  64310. l21: Vector3;
  64311. /**
  64312. * The l2,2 coefficients of the spherical harmonics
  64313. */
  64314. lL22: Vector3;
  64315. /**
  64316. * Adds a light to the spherical harmonics
  64317. * @param direction the direction of the light
  64318. * @param color the color of the light
  64319. * @param deltaSolidAngle the delta solid angle of the light
  64320. */
  64321. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  64322. /**
  64323. * Scales the spherical harmonics by the given amount
  64324. * @param scale the amount to scale
  64325. */
  64326. scale(scale: number): void;
  64327. /**
  64328. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  64329. *
  64330. * ```
  64331. * E_lm = A_l * L_lm
  64332. * ```
  64333. *
  64334. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  64335. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  64336. * the scaling factors are given in equation 9.
  64337. */
  64338. convertIncidentRadianceToIrradiance(): void;
  64339. /**
  64340. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  64341. *
  64342. * ```
  64343. * L = (1/pi) * E * rho
  64344. * ```
  64345. *
  64346. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  64347. */
  64348. convertIrradianceToLambertianRadiance(): void;
  64349. /**
  64350. * Gets the spherical harmonics from polynomial
  64351. * @param polynomial the spherical polynomial
  64352. * @returns the spherical harmonics
  64353. */
  64354. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  64355. /**
  64356. * Constructs a spherical harmonics from an array.
  64357. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  64358. * @returns the spherical harmonics
  64359. */
  64360. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  64361. }
  64362. }
  64363. declare module BABYLON {
  64364. /**
  64365. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  64366. */
  64367. export interface CubeMapInfo {
  64368. /**
  64369. * The pixel array for the front face.
  64370. * This is stored in format, left to right, up to down format.
  64371. */
  64372. front: Nullable<ArrayBufferView>;
  64373. /**
  64374. * The pixel array for the back face.
  64375. * This is stored in format, left to right, up to down format.
  64376. */
  64377. back: Nullable<ArrayBufferView>;
  64378. /**
  64379. * The pixel array for the left face.
  64380. * This is stored in format, left to right, up to down format.
  64381. */
  64382. left: Nullable<ArrayBufferView>;
  64383. /**
  64384. * The pixel array for the right face.
  64385. * This is stored in format, left to right, up to down format.
  64386. */
  64387. right: Nullable<ArrayBufferView>;
  64388. /**
  64389. * The pixel array for the up face.
  64390. * This is stored in format, left to right, up to down format.
  64391. */
  64392. up: Nullable<ArrayBufferView>;
  64393. /**
  64394. * The pixel array for the down face.
  64395. * This is stored in format, left to right, up to down format.
  64396. */
  64397. down: Nullable<ArrayBufferView>;
  64398. /**
  64399. * The size of the cubemap stored.
  64400. *
  64401. * Each faces will be size * size pixels.
  64402. */
  64403. size: number;
  64404. /**
  64405. * The format of the texture.
  64406. *
  64407. * RGBA, RGB.
  64408. */
  64409. format: number;
  64410. /**
  64411. * The type of the texture data.
  64412. *
  64413. * UNSIGNED_INT, FLOAT.
  64414. */
  64415. type: number;
  64416. /**
  64417. * Specifies whether the texture is in gamma space.
  64418. */
  64419. gammaSpace: boolean;
  64420. }
  64421. /**
  64422. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  64423. */
  64424. export class PanoramaToCubeMapTools {
  64425. private static FACE_FRONT;
  64426. private static FACE_BACK;
  64427. private static FACE_RIGHT;
  64428. private static FACE_LEFT;
  64429. private static FACE_DOWN;
  64430. private static FACE_UP;
  64431. /**
  64432. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  64433. *
  64434. * @param float32Array The source data.
  64435. * @param inputWidth The width of the input panorama.
  64436. * @param inputHeight The height of the input panorama.
  64437. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  64438. * @return The cubemap data
  64439. */
  64440. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  64441. private static CreateCubemapTexture;
  64442. private static CalcProjectionSpherical;
  64443. }
  64444. }
  64445. declare module BABYLON {
  64446. /**
  64447. * Helper class dealing with the extraction of spherical polynomial dataArray
  64448. * from a cube map.
  64449. */
  64450. export class CubeMapToSphericalPolynomialTools {
  64451. private static FileFaces;
  64452. /**
  64453. * Converts a texture to the according Spherical Polynomial data.
  64454. * This extracts the first 3 orders only as they are the only one used in the lighting.
  64455. *
  64456. * @param texture The texture to extract the information from.
  64457. * @return The Spherical Polynomial data.
  64458. */
  64459. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  64460. /**
  64461. * Converts a cubemap to the according Spherical Polynomial data.
  64462. * This extracts the first 3 orders only as they are the only one used in the lighting.
  64463. *
  64464. * @param cubeInfo The Cube map to extract the information from.
  64465. * @return The Spherical Polynomial data.
  64466. */
  64467. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  64468. }
  64469. }
  64470. declare module BABYLON {
  64471. /**
  64472. * The engine store class is responsible to hold all the instances of Engine and Scene created
  64473. * during the life time of the application.
  64474. */
  64475. export class EngineStore {
  64476. /** Gets the list of created engines */
  64477. static Instances: Engine[];
  64478. /**
  64479. * Gets the latest created engine
  64480. */
  64481. static readonly LastCreatedEngine: Nullable<Engine>;
  64482. /**
  64483. * Gets the latest created scene
  64484. */
  64485. static readonly LastCreatedScene: Nullable<Scene>;
  64486. }
  64487. }
  64488. declare module BABYLON {
  64489. /**
  64490. * Define options used to create a render target texture
  64491. */
  64492. export class RenderTargetCreationOptions {
  64493. /**
  64494. * Specifies is mipmaps must be generated
  64495. */
  64496. generateMipMaps?: boolean;
  64497. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  64498. generateDepthBuffer?: boolean;
  64499. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  64500. generateStencilBuffer?: boolean;
  64501. /** Defines texture type (int by default) */
  64502. type?: number;
  64503. /** Defines sampling mode (trilinear by default) */
  64504. samplingMode?: number;
  64505. /** Defines format (RGBA by default) */
  64506. format?: number;
  64507. }
  64508. }
  64509. declare module BABYLON {
  64510. /**
  64511. * @hidden
  64512. **/
  64513. export class _AlphaState {
  64514. private _isAlphaBlendDirty;
  64515. private _isBlendFunctionParametersDirty;
  64516. private _isBlendEquationParametersDirty;
  64517. private _isBlendConstantsDirty;
  64518. private _alphaBlend;
  64519. private _blendFunctionParameters;
  64520. private _blendEquationParameters;
  64521. private _blendConstants;
  64522. /**
  64523. * Initializes the state.
  64524. */
  64525. constructor();
  64526. readonly isDirty: boolean;
  64527. alphaBlend: boolean;
  64528. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  64529. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  64530. setAlphaEquationParameters(rgb: number, alpha: number): void;
  64531. reset(): void;
  64532. apply(gl: WebGLRenderingContext): void;
  64533. }
  64534. }
  64535. declare module BABYLON {
  64536. /**
  64537. * @hidden
  64538. **/
  64539. export class _DepthCullingState {
  64540. private _isDepthTestDirty;
  64541. private _isDepthMaskDirty;
  64542. private _isDepthFuncDirty;
  64543. private _isCullFaceDirty;
  64544. private _isCullDirty;
  64545. private _isZOffsetDirty;
  64546. private _isFrontFaceDirty;
  64547. private _depthTest;
  64548. private _depthMask;
  64549. private _depthFunc;
  64550. private _cull;
  64551. private _cullFace;
  64552. private _zOffset;
  64553. private _frontFace;
  64554. /**
  64555. * Initializes the state.
  64556. */
  64557. constructor();
  64558. readonly isDirty: boolean;
  64559. zOffset: number;
  64560. cullFace: Nullable<number>;
  64561. cull: Nullable<boolean>;
  64562. depthFunc: Nullable<number>;
  64563. depthMask: boolean;
  64564. depthTest: boolean;
  64565. frontFace: Nullable<number>;
  64566. reset(): void;
  64567. apply(gl: WebGLRenderingContext): void;
  64568. }
  64569. }
  64570. declare module BABYLON {
  64571. /**
  64572. * @hidden
  64573. **/
  64574. export class _StencilState {
  64575. /** 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 */
  64576. static readonly ALWAYS: number;
  64577. /** Passed to stencilOperation to specify that stencil value must be kept */
  64578. static readonly KEEP: number;
  64579. /** Passed to stencilOperation to specify that stencil value must be replaced */
  64580. static readonly REPLACE: number;
  64581. private _isStencilTestDirty;
  64582. private _isStencilMaskDirty;
  64583. private _isStencilFuncDirty;
  64584. private _isStencilOpDirty;
  64585. private _stencilTest;
  64586. private _stencilMask;
  64587. private _stencilFunc;
  64588. private _stencilFuncRef;
  64589. private _stencilFuncMask;
  64590. private _stencilOpStencilFail;
  64591. private _stencilOpDepthFail;
  64592. private _stencilOpStencilDepthPass;
  64593. readonly isDirty: boolean;
  64594. stencilFunc: number;
  64595. stencilFuncRef: number;
  64596. stencilFuncMask: number;
  64597. stencilOpStencilFail: number;
  64598. stencilOpDepthFail: number;
  64599. stencilOpStencilDepthPass: number;
  64600. stencilMask: number;
  64601. stencilTest: boolean;
  64602. constructor();
  64603. reset(): void;
  64604. apply(gl: WebGLRenderingContext): void;
  64605. }
  64606. }
  64607. declare module BABYLON {
  64608. /**
  64609. * @hidden
  64610. **/
  64611. export class _TimeToken {
  64612. _startTimeQuery: Nullable<WebGLQuery>;
  64613. _endTimeQuery: Nullable<WebGLQuery>;
  64614. _timeElapsedQuery: Nullable<WebGLQuery>;
  64615. _timeElapsedQueryEnded: boolean;
  64616. }
  64617. }
  64618. declare module BABYLON {
  64619. /**
  64620. * Internal interface used to track InternalTexture already bound to the GL context
  64621. */
  64622. export interface IInternalTextureTracker {
  64623. /**
  64624. * Gets or set the previous tracker in the list
  64625. */
  64626. previous: Nullable<IInternalTextureTracker>;
  64627. /**
  64628. * Gets or set the next tracker in the list
  64629. */
  64630. next: Nullable<IInternalTextureTracker>;
  64631. }
  64632. /**
  64633. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  64634. */
  64635. export class DummyInternalTextureTracker {
  64636. /**
  64637. * Gets or set the previous tracker in the list
  64638. */
  64639. previous: Nullable<IInternalTextureTracker>;
  64640. /**
  64641. * Gets or set the next tracker in the list
  64642. */
  64643. next: Nullable<IInternalTextureTracker>;
  64644. }
  64645. }
  64646. declare module BABYLON {
  64647. /**
  64648. * Class used to store data associated with WebGL texture data for the engine
  64649. * This class should not be used directly
  64650. */
  64651. export class InternalTexture implements IInternalTextureTracker {
  64652. /** hidden */
  64653. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  64654. /**
  64655. * The source of the texture data is unknown
  64656. */
  64657. static DATASOURCE_UNKNOWN: number;
  64658. /**
  64659. * Texture data comes from an URL
  64660. */
  64661. static DATASOURCE_URL: number;
  64662. /**
  64663. * Texture data is only used for temporary storage
  64664. */
  64665. static DATASOURCE_TEMP: number;
  64666. /**
  64667. * Texture data comes from raw data (ArrayBuffer)
  64668. */
  64669. static DATASOURCE_RAW: number;
  64670. /**
  64671. * Texture content is dynamic (video or dynamic texture)
  64672. */
  64673. static DATASOURCE_DYNAMIC: number;
  64674. /**
  64675. * Texture content is generated by rendering to it
  64676. */
  64677. static DATASOURCE_RENDERTARGET: number;
  64678. /**
  64679. * Texture content is part of a multi render target process
  64680. */
  64681. static DATASOURCE_MULTIRENDERTARGET: number;
  64682. /**
  64683. * Texture data comes from a cube data file
  64684. */
  64685. static DATASOURCE_CUBE: number;
  64686. /**
  64687. * Texture data comes from a raw cube data
  64688. */
  64689. static DATASOURCE_CUBERAW: number;
  64690. /**
  64691. * Texture data come from a prefiltered cube data file
  64692. */
  64693. static DATASOURCE_CUBEPREFILTERED: number;
  64694. /**
  64695. * Texture content is raw 3D data
  64696. */
  64697. static DATASOURCE_RAW3D: number;
  64698. /**
  64699. * Texture content is a depth texture
  64700. */
  64701. static DATASOURCE_DEPTHTEXTURE: number;
  64702. /**
  64703. * Texture data comes from a raw cube data encoded with RGBD
  64704. */
  64705. static DATASOURCE_CUBERAW_RGBD: number;
  64706. /**
  64707. * Defines if the texture is ready
  64708. */
  64709. isReady: boolean;
  64710. /**
  64711. * Defines if the texture is a cube texture
  64712. */
  64713. isCube: boolean;
  64714. /**
  64715. * Defines if the texture contains 3D data
  64716. */
  64717. is3D: boolean;
  64718. /**
  64719. * Gets the URL used to load this texture
  64720. */
  64721. url: string;
  64722. /**
  64723. * Gets the sampling mode of the texture
  64724. */
  64725. samplingMode: number;
  64726. /**
  64727. * Gets a boolean indicating if the texture needs mipmaps generation
  64728. */
  64729. generateMipMaps: boolean;
  64730. /**
  64731. * Gets the number of samples used by the texture (WebGL2+ only)
  64732. */
  64733. samples: number;
  64734. /**
  64735. * Gets the type of the texture (int, float...)
  64736. */
  64737. type: number;
  64738. /**
  64739. * Gets the format of the texture (RGB, RGBA...)
  64740. */
  64741. format: number;
  64742. /**
  64743. * Observable called when the texture is loaded
  64744. */
  64745. onLoadedObservable: Observable<InternalTexture>;
  64746. /**
  64747. * Gets the width of the texture
  64748. */
  64749. width: number;
  64750. /**
  64751. * Gets the height of the texture
  64752. */
  64753. height: number;
  64754. /**
  64755. * Gets the depth of the texture
  64756. */
  64757. depth: number;
  64758. /**
  64759. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  64760. */
  64761. baseWidth: number;
  64762. /**
  64763. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  64764. */
  64765. baseHeight: number;
  64766. /**
  64767. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  64768. */
  64769. baseDepth: number;
  64770. /**
  64771. * Gets a boolean indicating if the texture is inverted on Y axis
  64772. */
  64773. invertY: boolean;
  64774. /**
  64775. * Gets or set the previous tracker in the list
  64776. */
  64777. previous: Nullable<IInternalTextureTracker>;
  64778. /**
  64779. * Gets or set the next tracker in the list
  64780. */
  64781. next: Nullable<IInternalTextureTracker>;
  64782. /** @hidden */
  64783. _invertVScale: boolean;
  64784. /** @hidden */
  64785. _initialSlot: number;
  64786. /** @hidden */
  64787. _designatedSlot: number;
  64788. /** @hidden */
  64789. _dataSource: number;
  64790. /** @hidden */
  64791. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  64792. /** @hidden */
  64793. _bufferView: Nullable<ArrayBufferView>;
  64794. /** @hidden */
  64795. _bufferViewArray: Nullable<ArrayBufferView[]>;
  64796. /** @hidden */
  64797. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  64798. /** @hidden */
  64799. _size: number;
  64800. /** @hidden */
  64801. _extension: string;
  64802. /** @hidden */
  64803. _files: Nullable<string[]>;
  64804. /** @hidden */
  64805. _workingCanvas: HTMLCanvasElement;
  64806. /** @hidden */
  64807. _workingContext: CanvasRenderingContext2D;
  64808. /** @hidden */
  64809. _framebuffer: Nullable<WebGLFramebuffer>;
  64810. /** @hidden */
  64811. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  64812. /** @hidden */
  64813. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  64814. /** @hidden */
  64815. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  64816. /** @hidden */
  64817. _attachments: Nullable<number[]>;
  64818. /** @hidden */
  64819. _cachedCoordinatesMode: Nullable<number>;
  64820. /** @hidden */
  64821. _cachedWrapU: Nullable<number>;
  64822. /** @hidden */
  64823. _cachedWrapV: Nullable<number>;
  64824. /** @hidden */
  64825. _cachedWrapR: Nullable<number>;
  64826. /** @hidden */
  64827. _cachedAnisotropicFilteringLevel: Nullable<number>;
  64828. /** @hidden */
  64829. _isDisabled: boolean;
  64830. /** @hidden */
  64831. _compression: Nullable<string>;
  64832. /** @hidden */
  64833. _generateStencilBuffer: boolean;
  64834. /** @hidden */
  64835. _generateDepthBuffer: boolean;
  64836. /** @hidden */
  64837. _comparisonFunction: number;
  64838. /** @hidden */
  64839. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  64840. /** @hidden */
  64841. _lodGenerationScale: number;
  64842. /** @hidden */
  64843. _lodGenerationOffset: number;
  64844. /** @hidden */
  64845. _lodTextureHigh: BaseTexture;
  64846. /** @hidden */
  64847. _lodTextureMid: BaseTexture;
  64848. /** @hidden */
  64849. _lodTextureLow: BaseTexture;
  64850. /** @hidden */
  64851. _isRGBD: boolean;
  64852. /** @hidden */
  64853. _webGLTexture: Nullable<WebGLTexture>;
  64854. /** @hidden */
  64855. _references: number;
  64856. private _engine;
  64857. /**
  64858. * Gets the Engine the texture belongs to.
  64859. * @returns The babylon engine
  64860. */
  64861. getEngine(): Engine;
  64862. /**
  64863. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  64864. */
  64865. readonly dataSource: number;
  64866. /**
  64867. * Creates a new InternalTexture
  64868. * @param engine defines the engine to use
  64869. * @param dataSource defines the type of data that will be used
  64870. * @param delayAllocation if the texture allocation should be delayed (default: false)
  64871. */
  64872. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  64873. /**
  64874. * Increments the number of references (ie. the number of Texture that point to it)
  64875. */
  64876. incrementReferences(): void;
  64877. /**
  64878. * Change the size of the texture (not the size of the content)
  64879. * @param width defines the new width
  64880. * @param height defines the new height
  64881. * @param depth defines the new depth (1 by default)
  64882. */
  64883. updateSize(width: int, height: int, depth?: int): void;
  64884. /** @hidden */
  64885. _rebuild(): void;
  64886. /** @hidden */
  64887. _swapAndDie(target: InternalTexture): void;
  64888. /**
  64889. * Dispose the current allocated resources
  64890. */
  64891. dispose(): void;
  64892. }
  64893. }
  64894. declare module BABYLON {
  64895. /**
  64896. * This represents the main contract an easing function should follow.
  64897. * Easing functions are used throughout the animation system.
  64898. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64899. */
  64900. export interface IEasingFunction {
  64901. /**
  64902. * Given an input gradient between 0 and 1, this returns the corrseponding value
  64903. * of the easing function.
  64904. * The link below provides some of the most common examples of easing functions.
  64905. * @see https://easings.net/
  64906. * @param gradient Defines the value between 0 and 1 we want the easing value for
  64907. * @returns the corresponding value on the curve defined by the easing function
  64908. */
  64909. ease(gradient: number): number;
  64910. }
  64911. /**
  64912. * Base class used for every default easing function.
  64913. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64914. */
  64915. export class EasingFunction implements IEasingFunction {
  64916. /**
  64917. * Interpolation follows the mathematical formula associated with the easing function.
  64918. */
  64919. static readonly EASINGMODE_EASEIN: number;
  64920. /**
  64921. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  64922. */
  64923. static readonly EASINGMODE_EASEOUT: number;
  64924. /**
  64925. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  64926. */
  64927. static readonly EASINGMODE_EASEINOUT: number;
  64928. private _easingMode;
  64929. /**
  64930. * Sets the easing mode of the current function.
  64931. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  64932. */
  64933. setEasingMode(easingMode: number): void;
  64934. /**
  64935. * Gets the current easing mode.
  64936. * @returns the easing mode
  64937. */
  64938. getEasingMode(): number;
  64939. /**
  64940. * @hidden
  64941. */
  64942. easeInCore(gradient: number): number;
  64943. /**
  64944. * Given an input gradient between 0 and 1, this returns the corrseponding value
  64945. * of the easing function.
  64946. * @param gradient Defines the value between 0 and 1 we want the easing value for
  64947. * @returns the corresponding value on the curve defined by the easing function
  64948. */
  64949. ease(gradient: number): number;
  64950. }
  64951. /**
  64952. * Easing function with a circle shape (see link below).
  64953. * @see https://easings.net/#easeInCirc
  64954. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64955. */
  64956. export class CircleEase extends EasingFunction implements IEasingFunction {
  64957. /** @hidden */
  64958. easeInCore(gradient: number): number;
  64959. }
  64960. /**
  64961. * Easing function with a ease back shape (see link below).
  64962. * @see https://easings.net/#easeInBack
  64963. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64964. */
  64965. export class BackEase extends EasingFunction implements IEasingFunction {
  64966. /** Defines the amplitude of the function */
  64967. amplitude: number;
  64968. /**
  64969. * Instantiates a back ease easing
  64970. * @see https://easings.net/#easeInBack
  64971. * @param amplitude Defines the amplitude of the function
  64972. */
  64973. constructor(
  64974. /** Defines the amplitude of the function */
  64975. amplitude?: number);
  64976. /** @hidden */
  64977. easeInCore(gradient: number): number;
  64978. }
  64979. /**
  64980. * Easing function with a bouncing shape (see link below).
  64981. * @see https://easings.net/#easeInBounce
  64982. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64983. */
  64984. export class BounceEase extends EasingFunction implements IEasingFunction {
  64985. /** Defines the number of bounces */
  64986. bounces: number;
  64987. /** Defines the amplitude of the bounce */
  64988. bounciness: number;
  64989. /**
  64990. * Instantiates a bounce easing
  64991. * @see https://easings.net/#easeInBounce
  64992. * @param bounces Defines the number of bounces
  64993. * @param bounciness Defines the amplitude of the bounce
  64994. */
  64995. constructor(
  64996. /** Defines the number of bounces */
  64997. bounces?: number,
  64998. /** Defines the amplitude of the bounce */
  64999. bounciness?: number);
  65000. /** @hidden */
  65001. easeInCore(gradient: number): number;
  65002. }
  65003. /**
  65004. * Easing function with a power of 3 shape (see link below).
  65005. * @see https://easings.net/#easeInCubic
  65006. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65007. */
  65008. export class CubicEase extends EasingFunction implements IEasingFunction {
  65009. /** @hidden */
  65010. easeInCore(gradient: number): number;
  65011. }
  65012. /**
  65013. * Easing function with an elastic shape (see link below).
  65014. * @see https://easings.net/#easeInElastic
  65015. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65016. */
  65017. export class ElasticEase extends EasingFunction implements IEasingFunction {
  65018. /** Defines the number of oscillations*/
  65019. oscillations: number;
  65020. /** Defines the amplitude of the oscillations*/
  65021. springiness: number;
  65022. /**
  65023. * Instantiates an elastic easing function
  65024. * @see https://easings.net/#easeInElastic
  65025. * @param oscillations Defines the number of oscillations
  65026. * @param springiness Defines the amplitude of the oscillations
  65027. */
  65028. constructor(
  65029. /** Defines the number of oscillations*/
  65030. oscillations?: number,
  65031. /** Defines the amplitude of the oscillations*/
  65032. springiness?: number);
  65033. /** @hidden */
  65034. easeInCore(gradient: number): number;
  65035. }
  65036. /**
  65037. * Easing function with an exponential shape (see link below).
  65038. * @see https://easings.net/#easeInExpo
  65039. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65040. */
  65041. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  65042. /** Defines the exponent of the function */
  65043. exponent: number;
  65044. /**
  65045. * Instantiates an exponential easing function
  65046. * @see https://easings.net/#easeInExpo
  65047. * @param exponent Defines the exponent of the function
  65048. */
  65049. constructor(
  65050. /** Defines the exponent of the function */
  65051. exponent?: number);
  65052. /** @hidden */
  65053. easeInCore(gradient: number): number;
  65054. }
  65055. /**
  65056. * Easing function with a power shape (see link below).
  65057. * @see https://easings.net/#easeInQuad
  65058. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65059. */
  65060. export class PowerEase extends EasingFunction implements IEasingFunction {
  65061. /** Defines the power of the function */
  65062. power: number;
  65063. /**
  65064. * Instantiates an power base easing function
  65065. * @see https://easings.net/#easeInQuad
  65066. * @param power Defines the power of the function
  65067. */
  65068. constructor(
  65069. /** Defines the power of the function */
  65070. power?: number);
  65071. /** @hidden */
  65072. easeInCore(gradient: number): number;
  65073. }
  65074. /**
  65075. * Easing function with a power of 2 shape (see link below).
  65076. * @see https://easings.net/#easeInQuad
  65077. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65078. */
  65079. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  65080. /** @hidden */
  65081. easeInCore(gradient: number): number;
  65082. }
  65083. /**
  65084. * Easing function with a power of 4 shape (see link below).
  65085. * @see https://easings.net/#easeInQuart
  65086. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65087. */
  65088. export class QuarticEase extends EasingFunction implements IEasingFunction {
  65089. /** @hidden */
  65090. easeInCore(gradient: number): number;
  65091. }
  65092. /**
  65093. * Easing function with a power of 5 shape (see link below).
  65094. * @see https://easings.net/#easeInQuint
  65095. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65096. */
  65097. export class QuinticEase extends EasingFunction implements IEasingFunction {
  65098. /** @hidden */
  65099. easeInCore(gradient: number): number;
  65100. }
  65101. /**
  65102. * Easing function with a sin shape (see link below).
  65103. * @see https://easings.net/#easeInSine
  65104. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65105. */
  65106. export class SineEase extends EasingFunction implements IEasingFunction {
  65107. /** @hidden */
  65108. easeInCore(gradient: number): number;
  65109. }
  65110. /**
  65111. * Easing function with a bezier shape (see link below).
  65112. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  65113. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65114. */
  65115. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  65116. /** Defines the x component of the start tangent in the bezier curve */
  65117. x1: number;
  65118. /** Defines the y component of the start tangent in the bezier curve */
  65119. y1: number;
  65120. /** Defines the x component of the end tangent in the bezier curve */
  65121. x2: number;
  65122. /** Defines the y component of the end tangent in the bezier curve */
  65123. y2: number;
  65124. /**
  65125. * Instantiates a bezier function
  65126. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  65127. * @param x1 Defines the x component of the start tangent in the bezier curve
  65128. * @param y1 Defines the y component of the start tangent in the bezier curve
  65129. * @param x2 Defines the x component of the end tangent in the bezier curve
  65130. * @param y2 Defines the y component of the end tangent in the bezier curve
  65131. */
  65132. constructor(
  65133. /** Defines the x component of the start tangent in the bezier curve */
  65134. x1?: number,
  65135. /** Defines the y component of the start tangent in the bezier curve */
  65136. y1?: number,
  65137. /** Defines the x component of the end tangent in the bezier curve */
  65138. x2?: number,
  65139. /** Defines the y component of the end tangent in the bezier curve */
  65140. y2?: number);
  65141. /** @hidden */
  65142. easeInCore(gradient: number): number;
  65143. }
  65144. }
  65145. declare module BABYLON {
  65146. /**
  65147. * Defines an interface which represents an animation key frame
  65148. */
  65149. export interface IAnimationKey {
  65150. /**
  65151. * Frame of the key frame
  65152. */
  65153. frame: number;
  65154. /**
  65155. * Value at the specifies key frame
  65156. */
  65157. value: any;
  65158. /**
  65159. * The input tangent for the cubic hermite spline
  65160. */
  65161. inTangent?: any;
  65162. /**
  65163. * The output tangent for the cubic hermite spline
  65164. */
  65165. outTangent?: any;
  65166. /**
  65167. * The animation interpolation type
  65168. */
  65169. interpolation?: AnimationKeyInterpolation;
  65170. }
  65171. /**
  65172. * Enum for the animation key frame interpolation type
  65173. */
  65174. export enum AnimationKeyInterpolation {
  65175. /**
  65176. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  65177. */
  65178. STEP = 1
  65179. }
  65180. }
  65181. declare module BABYLON {
  65182. /**
  65183. * Represents the range of an animation
  65184. */
  65185. export class AnimationRange {
  65186. /**The name of the animation range**/
  65187. name: string;
  65188. /**The starting frame of the animation */
  65189. from: number;
  65190. /**The ending frame of the animation*/
  65191. to: number;
  65192. /**
  65193. * Initializes the range of an animation
  65194. * @param name The name of the animation range
  65195. * @param from The starting frame of the animation
  65196. * @param to The ending frame of the animation
  65197. */
  65198. constructor(
  65199. /**The name of the animation range**/
  65200. name: string,
  65201. /**The starting frame of the animation */
  65202. from: number,
  65203. /**The ending frame of the animation*/
  65204. to: number);
  65205. /**
  65206. * Makes a copy of the animation range
  65207. * @returns A copy of the animation range
  65208. */
  65209. clone(): AnimationRange;
  65210. }
  65211. }
  65212. declare module BABYLON {
  65213. /**
  65214. * Composed of a frame, and an action function
  65215. */
  65216. export class AnimationEvent {
  65217. /** The frame for which the event is triggered **/
  65218. frame: number;
  65219. /** The event to perform when triggered **/
  65220. action: (currentFrame: number) => void;
  65221. /** Specifies if the event should be triggered only once**/
  65222. onlyOnce?: boolean | undefined;
  65223. /**
  65224. * Specifies if the animation event is done
  65225. */
  65226. isDone: boolean;
  65227. /**
  65228. * Initializes the animation event
  65229. * @param frame The frame for which the event is triggered
  65230. * @param action The event to perform when triggered
  65231. * @param onlyOnce Specifies if the event should be triggered only once
  65232. */
  65233. constructor(
  65234. /** The frame for which the event is triggered **/
  65235. frame: number,
  65236. /** The event to perform when triggered **/
  65237. action: (currentFrame: number) => void,
  65238. /** Specifies if the event should be triggered only once**/
  65239. onlyOnce?: boolean | undefined);
  65240. /** @hidden */
  65241. _clone(): AnimationEvent;
  65242. }
  65243. }
  65244. declare module BABYLON {
  65245. /**
  65246. * Interface used to define a behavior
  65247. */
  65248. export interface Behavior<T> {
  65249. /** gets or sets behavior's name */
  65250. name: string;
  65251. /**
  65252. * Function called when the behavior needs to be initialized (after attaching it to a target)
  65253. */
  65254. init(): void;
  65255. /**
  65256. * Called when the behavior is attached to a target
  65257. * @param target defines the target where the behavior is attached to
  65258. */
  65259. attach(target: T): void;
  65260. /**
  65261. * Called when the behavior is detached from its target
  65262. */
  65263. detach(): void;
  65264. }
  65265. /**
  65266. * Interface implemented by classes supporting behaviors
  65267. */
  65268. export interface IBehaviorAware<T> {
  65269. /**
  65270. * Attach a behavior
  65271. * @param behavior defines the behavior to attach
  65272. * @returns the current host
  65273. */
  65274. addBehavior(behavior: Behavior<T>): T;
  65275. /**
  65276. * Remove a behavior from the current object
  65277. * @param behavior defines the behavior to detach
  65278. * @returns the current host
  65279. */
  65280. removeBehavior(behavior: Behavior<T>): T;
  65281. /**
  65282. * Gets a behavior using its name to search
  65283. * @param name defines the name to search
  65284. * @returns the behavior or null if not found
  65285. */
  65286. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  65287. }
  65288. }
  65289. declare module BABYLON {
  65290. /**
  65291. * @hidden
  65292. */
  65293. export class IntersectionInfo {
  65294. bu: Nullable<number>;
  65295. bv: Nullable<number>;
  65296. distance: number;
  65297. faceId: number;
  65298. subMeshId: number;
  65299. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  65300. }
  65301. }
  65302. declare module BABYLON {
  65303. /**
  65304. * Class used to store bounding sphere information
  65305. */
  65306. export class BoundingSphere {
  65307. /**
  65308. * Gets the center of the bounding sphere in local space
  65309. */
  65310. readonly center: Vector3;
  65311. /**
  65312. * Radius of the bounding sphere in local space
  65313. */
  65314. radius: number;
  65315. /**
  65316. * Gets the center of the bounding sphere in world space
  65317. */
  65318. readonly centerWorld: Vector3;
  65319. /**
  65320. * Radius of the bounding sphere in world space
  65321. */
  65322. radiusWorld: number;
  65323. /**
  65324. * Gets the minimum vector in local space
  65325. */
  65326. readonly minimum: Vector3;
  65327. /**
  65328. * Gets the maximum vector in local space
  65329. */
  65330. readonly maximum: Vector3;
  65331. private _worldMatrix;
  65332. private static readonly TmpVector3;
  65333. /**
  65334. * Creates a new bounding sphere
  65335. * @param min defines the minimum vector (in local space)
  65336. * @param max defines the maximum vector (in local space)
  65337. * @param worldMatrix defines the new world matrix
  65338. */
  65339. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  65340. /**
  65341. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  65342. * @param min defines the new minimum vector (in local space)
  65343. * @param max defines the new maximum vector (in local space)
  65344. * @param worldMatrix defines the new world matrix
  65345. */
  65346. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  65347. /**
  65348. * Scale the current bounding sphere by applying a scale factor
  65349. * @param factor defines the scale factor to apply
  65350. * @returns the current bounding box
  65351. */
  65352. scale(factor: number): BoundingSphere;
  65353. /**
  65354. * Gets the world matrix of the bounding box
  65355. * @returns a matrix
  65356. */
  65357. getWorldMatrix(): DeepImmutable<Matrix>;
  65358. /** @hidden */
  65359. _update(worldMatrix: DeepImmutable<Matrix>): void;
  65360. /**
  65361. * Tests if the bounding sphere is intersecting the frustum planes
  65362. * @param frustumPlanes defines the frustum planes to test
  65363. * @returns true if there is an intersection
  65364. */
  65365. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65366. /**
  65367. * Tests if the bounding sphere center is in between the frustum planes.
  65368. * Used for optimistic fast inclusion.
  65369. * @param frustumPlanes defines the frustum planes to test
  65370. * @returns true if the sphere center is in between the frustum planes
  65371. */
  65372. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65373. /**
  65374. * Tests if a point is inside the bounding sphere
  65375. * @param point defines the point to test
  65376. * @returns true if the point is inside the bounding sphere
  65377. */
  65378. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  65379. /**
  65380. * Checks if two sphere intersct
  65381. * @param sphere0 sphere 0
  65382. * @param sphere1 sphere 1
  65383. * @returns true if the speres intersect
  65384. */
  65385. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  65386. }
  65387. }
  65388. declare module BABYLON {
  65389. /**
  65390. * Class used to store bounding box information
  65391. */
  65392. export class BoundingBox implements ICullable {
  65393. /**
  65394. * Gets the 8 vectors representing the bounding box in local space
  65395. */
  65396. readonly vectors: Vector3[];
  65397. /**
  65398. * Gets the center of the bounding box in local space
  65399. */
  65400. readonly center: Vector3;
  65401. /**
  65402. * Gets the center of the bounding box in world space
  65403. */
  65404. readonly centerWorld: Vector3;
  65405. /**
  65406. * Gets the extend size in local space
  65407. */
  65408. readonly extendSize: Vector3;
  65409. /**
  65410. * Gets the extend size in world space
  65411. */
  65412. readonly extendSizeWorld: Vector3;
  65413. /**
  65414. * Gets the OBB (object bounding box) directions
  65415. */
  65416. readonly directions: Vector3[];
  65417. /**
  65418. * Gets the 8 vectors representing the bounding box in world space
  65419. */
  65420. readonly vectorsWorld: Vector3[];
  65421. /**
  65422. * Gets the minimum vector in world space
  65423. */
  65424. readonly minimumWorld: Vector3;
  65425. /**
  65426. * Gets the maximum vector in world space
  65427. */
  65428. readonly maximumWorld: Vector3;
  65429. /**
  65430. * Gets the minimum vector in local space
  65431. */
  65432. readonly minimum: Vector3;
  65433. /**
  65434. * Gets the maximum vector in local space
  65435. */
  65436. readonly maximum: Vector3;
  65437. private _worldMatrix;
  65438. private static readonly TmpVector3;
  65439. /**
  65440. * @hidden
  65441. */
  65442. _tag: number;
  65443. /**
  65444. * Creates a new bounding box
  65445. * @param min defines the minimum vector (in local space)
  65446. * @param max defines the maximum vector (in local space)
  65447. * @param worldMatrix defines the new world matrix
  65448. */
  65449. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  65450. /**
  65451. * Recreates the entire bounding box from scratch as if we call the constructor in place
  65452. * @param min defines the new minimum vector (in local space)
  65453. * @param max defines the new maximum vector (in local space)
  65454. * @param worldMatrix defines the new world matrix
  65455. */
  65456. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  65457. /**
  65458. * Scale the current bounding box by applying a scale factor
  65459. * @param factor defines the scale factor to apply
  65460. * @returns the current bounding box
  65461. */
  65462. scale(factor: number): BoundingBox;
  65463. /**
  65464. * Gets the world matrix of the bounding box
  65465. * @returns a matrix
  65466. */
  65467. getWorldMatrix(): DeepImmutable<Matrix>;
  65468. /** @hidden */
  65469. _update(world: DeepImmutable<Matrix>): void;
  65470. /**
  65471. * Tests if the bounding box is intersecting the frustum planes
  65472. * @param frustumPlanes defines the frustum planes to test
  65473. * @returns true if there is an intersection
  65474. */
  65475. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65476. /**
  65477. * Tests if the bounding box is entirely inside the frustum planes
  65478. * @param frustumPlanes defines the frustum planes to test
  65479. * @returns true if there is an inclusion
  65480. */
  65481. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65482. /**
  65483. * Tests if a point is inside the bounding box
  65484. * @param point defines the point to test
  65485. * @returns true if the point is inside the bounding box
  65486. */
  65487. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  65488. /**
  65489. * Tests if the bounding box intersects with a bounding sphere
  65490. * @param sphere defines the sphere to test
  65491. * @returns true if there is an intersection
  65492. */
  65493. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  65494. /**
  65495. * Tests if the bounding box intersects with a box defined by a min and max vectors
  65496. * @param min defines the min vector to use
  65497. * @param max defines the max vector to use
  65498. * @returns true if there is an intersection
  65499. */
  65500. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  65501. /**
  65502. * Tests if two bounding boxes are intersections
  65503. * @param box0 defines the first box to test
  65504. * @param box1 defines the second box to test
  65505. * @returns true if there is an intersection
  65506. */
  65507. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  65508. /**
  65509. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  65510. * @param minPoint defines the minimum vector of the bounding box
  65511. * @param maxPoint defines the maximum vector of the bounding box
  65512. * @param sphereCenter defines the sphere center
  65513. * @param sphereRadius defines the sphere radius
  65514. * @returns true if there is an intersection
  65515. */
  65516. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  65517. /**
  65518. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  65519. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  65520. * @param frustumPlanes defines the frustum planes to test
  65521. * @return true if there is an inclusion
  65522. */
  65523. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65524. /**
  65525. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  65526. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  65527. * @param frustumPlanes defines the frustum planes to test
  65528. * @return true if there is an intersection
  65529. */
  65530. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65531. }
  65532. }
  65533. declare module BABYLON {
  65534. /** @hidden */
  65535. export class Collider {
  65536. /** Define if a collision was found */
  65537. collisionFound: boolean;
  65538. /**
  65539. * Define last intersection point in local space
  65540. */
  65541. intersectionPoint: Vector3;
  65542. /**
  65543. * Define last collided mesh
  65544. */
  65545. collidedMesh: Nullable<AbstractMesh>;
  65546. private _collisionPoint;
  65547. private _planeIntersectionPoint;
  65548. private _tempVector;
  65549. private _tempVector2;
  65550. private _tempVector3;
  65551. private _tempVector4;
  65552. private _edge;
  65553. private _baseToVertex;
  65554. private _destinationPoint;
  65555. private _slidePlaneNormal;
  65556. private _displacementVector;
  65557. /** @hidden */
  65558. _radius: Vector3;
  65559. /** @hidden */
  65560. _retry: number;
  65561. private _velocity;
  65562. private _basePoint;
  65563. private _epsilon;
  65564. /** @hidden */
  65565. _velocityWorldLength: number;
  65566. /** @hidden */
  65567. _basePointWorld: Vector3;
  65568. private _velocityWorld;
  65569. private _normalizedVelocity;
  65570. /** @hidden */
  65571. _initialVelocity: Vector3;
  65572. /** @hidden */
  65573. _initialPosition: Vector3;
  65574. private _nearestDistance;
  65575. private _collisionMask;
  65576. collisionMask: number;
  65577. /**
  65578. * Gets the plane normal used to compute the sliding response (in local space)
  65579. */
  65580. readonly slidePlaneNormal: Vector3;
  65581. /** @hidden */
  65582. _initialize(source: Vector3, dir: Vector3, e: number): void;
  65583. /** @hidden */
  65584. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  65585. /** @hidden */
  65586. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  65587. /** @hidden */
  65588. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  65589. /** @hidden */
  65590. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  65591. /** @hidden */
  65592. _getResponse(pos: Vector3, vel: Vector3): void;
  65593. }
  65594. }
  65595. declare module BABYLON {
  65596. /**
  65597. * Interface for cullable objects
  65598. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  65599. */
  65600. export interface ICullable {
  65601. /**
  65602. * Checks if the object or part of the object is in the frustum
  65603. * @param frustumPlanes Camera near/planes
  65604. * @returns true if the object is in frustum otherwise false
  65605. */
  65606. isInFrustum(frustumPlanes: Plane[]): boolean;
  65607. /**
  65608. * Checks if a cullable object (mesh...) is in the camera frustum
  65609. * Unlike isInFrustum this cheks the full bounding box
  65610. * @param frustumPlanes Camera near/planes
  65611. * @returns true if the object is in frustum otherwise false
  65612. */
  65613. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  65614. }
  65615. /**
  65616. * Info for a bounding data of a mesh
  65617. */
  65618. export class BoundingInfo implements ICullable {
  65619. /**
  65620. * Bounding box for the mesh
  65621. */
  65622. readonly boundingBox: BoundingBox;
  65623. /**
  65624. * Bounding sphere for the mesh
  65625. */
  65626. readonly boundingSphere: BoundingSphere;
  65627. private _isLocked;
  65628. private static readonly TmpVector3;
  65629. /**
  65630. * Constructs bounding info
  65631. * @param minimum min vector of the bounding box/sphere
  65632. * @param maximum max vector of the bounding box/sphere
  65633. * @param worldMatrix defines the new world matrix
  65634. */
  65635. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  65636. /**
  65637. * Recreates the entire bounding info from scratch as if we call the constructor in place
  65638. * @param min defines the new minimum vector (in local space)
  65639. * @param max defines the new maximum vector (in local space)
  65640. * @param worldMatrix defines the new world matrix
  65641. */
  65642. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  65643. /**
  65644. * min vector of the bounding box/sphere
  65645. */
  65646. readonly minimum: Vector3;
  65647. /**
  65648. * max vector of the bounding box/sphere
  65649. */
  65650. readonly maximum: Vector3;
  65651. /**
  65652. * If the info is locked and won't be updated to avoid perf overhead
  65653. */
  65654. isLocked: boolean;
  65655. /**
  65656. * Updates the bounding sphere and box
  65657. * @param world world matrix to be used to update
  65658. */
  65659. update(world: DeepImmutable<Matrix>): void;
  65660. /**
  65661. * Recreate the bounding info to be centered around a specific point given a specific extend.
  65662. * @param center New center of the bounding info
  65663. * @param extend New extend of the bounding info
  65664. * @returns the current bounding info
  65665. */
  65666. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  65667. /**
  65668. * Scale the current bounding info by applying a scale factor
  65669. * @param factor defines the scale factor to apply
  65670. * @returns the current bounding info
  65671. */
  65672. scale(factor: number): BoundingInfo;
  65673. /**
  65674. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  65675. * @param frustumPlanes defines the frustum to test
  65676. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  65677. * @returns true if the bounding info is in the frustum planes
  65678. */
  65679. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  65680. /**
  65681. * Gets the world distance between the min and max points of the bounding box
  65682. */
  65683. readonly diagonalLength: number;
  65684. /**
  65685. * Checks if a cullable object (mesh...) is in the camera frustum
  65686. * Unlike isInFrustum this cheks the full bounding box
  65687. * @param frustumPlanes Camera near/planes
  65688. * @returns true if the object is in frustum otherwise false
  65689. */
  65690. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65691. /** @hidden */
  65692. _checkCollision(collider: Collider): boolean;
  65693. /**
  65694. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  65695. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  65696. * @param point the point to check intersection with
  65697. * @returns if the point intersects
  65698. */
  65699. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  65700. /**
  65701. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  65702. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  65703. * @param boundingInfo the bounding info to check intersection with
  65704. * @param precise if the intersection should be done using OBB
  65705. * @returns if the bounding info intersects
  65706. */
  65707. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  65708. }
  65709. }
  65710. declare module BABYLON {
  65711. /**
  65712. * Defines an array and its length.
  65713. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  65714. */
  65715. export interface ISmartArrayLike<T> {
  65716. /**
  65717. * The data of the array.
  65718. */
  65719. data: Array<T>;
  65720. /**
  65721. * The active length of the array.
  65722. */
  65723. length: number;
  65724. }
  65725. /**
  65726. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  65727. */
  65728. export class SmartArray<T> implements ISmartArrayLike<T> {
  65729. /**
  65730. * The full set of data from the array.
  65731. */
  65732. data: Array<T>;
  65733. /**
  65734. * The active length of the array.
  65735. */
  65736. length: number;
  65737. protected _id: number;
  65738. /**
  65739. * Instantiates a Smart Array.
  65740. * @param capacity defines the default capacity of the array.
  65741. */
  65742. constructor(capacity: number);
  65743. /**
  65744. * Pushes a value at the end of the active data.
  65745. * @param value defines the object to push in the array.
  65746. */
  65747. push(value: T): void;
  65748. /**
  65749. * Iterates over the active data and apply the lambda to them.
  65750. * @param func defines the action to apply on each value.
  65751. */
  65752. forEach(func: (content: T) => void): void;
  65753. /**
  65754. * Sorts the full sets of data.
  65755. * @param compareFn defines the comparison function to apply.
  65756. */
  65757. sort(compareFn: (a: T, b: T) => number): void;
  65758. /**
  65759. * Resets the active data to an empty array.
  65760. */
  65761. reset(): void;
  65762. /**
  65763. * Releases all the data from the array as well as the array.
  65764. */
  65765. dispose(): void;
  65766. /**
  65767. * Concats the active data with a given array.
  65768. * @param array defines the data to concatenate with.
  65769. */
  65770. concat(array: any): void;
  65771. /**
  65772. * Returns the position of a value in the active data.
  65773. * @param value defines the value to find the index for
  65774. * @returns the index if found in the active data otherwise -1
  65775. */
  65776. indexOf(value: T): number;
  65777. /**
  65778. * Returns whether an element is part of the active data.
  65779. * @param value defines the value to look for
  65780. * @returns true if found in the active data otherwise false
  65781. */
  65782. contains(value: T): boolean;
  65783. private static _GlobalId;
  65784. }
  65785. /**
  65786. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  65787. * The data in this array can only be present once
  65788. */
  65789. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  65790. private _duplicateId;
  65791. /**
  65792. * Pushes a value at the end of the active data.
  65793. * THIS DOES NOT PREVENT DUPPLICATE DATA
  65794. * @param value defines the object to push in the array.
  65795. */
  65796. push(value: T): void;
  65797. /**
  65798. * Pushes a value at the end of the active data.
  65799. * If the data is already present, it won t be added again
  65800. * @param value defines the object to push in the array.
  65801. * @returns true if added false if it was already present
  65802. */
  65803. pushNoDuplicate(value: T): boolean;
  65804. /**
  65805. * Resets the active data to an empty array.
  65806. */
  65807. reset(): void;
  65808. /**
  65809. * Concats the active data with a given array.
  65810. * This ensures no dupplicate will be present in the result.
  65811. * @param array defines the data to concatenate with.
  65812. */
  65813. concatWithNoDuplicate(array: any): void;
  65814. }
  65815. }
  65816. declare module BABYLON {
  65817. /**
  65818. * A multi-material is used to apply different materials to different parts of the same object without the need of
  65819. * separate meshes. This can be use to improve performances.
  65820. * @see http://doc.babylonjs.com/how_to/multi_materials
  65821. */
  65822. export class MultiMaterial extends Material {
  65823. private _subMaterials;
  65824. /**
  65825. * Gets or Sets the list of Materials used within the multi material.
  65826. * They need to be ordered according to the submeshes order in the associated mesh
  65827. */
  65828. subMaterials: Nullable<Material>[];
  65829. /**
  65830. * Function used to align with Node.getChildren()
  65831. * @returns the list of Materials used within the multi material
  65832. */
  65833. getChildren(): Nullable<Material>[];
  65834. /**
  65835. * Instantiates a new Multi Material
  65836. * A multi-material is used to apply different materials to different parts of the same object without the need of
  65837. * separate meshes. This can be use to improve performances.
  65838. * @see http://doc.babylonjs.com/how_to/multi_materials
  65839. * @param name Define the name in the scene
  65840. * @param scene Define the scene the material belongs to
  65841. */
  65842. constructor(name: string, scene: Scene);
  65843. private _hookArray;
  65844. /**
  65845. * Get one of the submaterial by its index in the submaterials array
  65846. * @param index The index to look the sub material at
  65847. * @returns The Material if the index has been defined
  65848. */
  65849. getSubMaterial(index: number): Nullable<Material>;
  65850. /**
  65851. * Get the list of active textures for the whole sub materials list.
  65852. * @returns All the textures that will be used during the rendering
  65853. */
  65854. getActiveTextures(): BaseTexture[];
  65855. /**
  65856. * Gets the current class name of the material e.g. "MultiMaterial"
  65857. * Mainly use in serialization.
  65858. * @returns the class name
  65859. */
  65860. getClassName(): string;
  65861. /**
  65862. * Checks if the material is ready to render the requested sub mesh
  65863. * @param mesh Define the mesh the submesh belongs to
  65864. * @param subMesh Define the sub mesh to look readyness for
  65865. * @param useInstances Define whether or not the material is used with instances
  65866. * @returns true if ready, otherwise false
  65867. */
  65868. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  65869. /**
  65870. * Clones the current material and its related sub materials
  65871. * @param name Define the name of the newly cloned material
  65872. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  65873. * @returns the cloned material
  65874. */
  65875. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  65876. /**
  65877. * Serializes the materials into a JSON representation.
  65878. * @returns the JSON representation
  65879. */
  65880. serialize(): any;
  65881. /**
  65882. * Dispose the material and release its associated resources
  65883. * @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)
  65884. * @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)
  65885. * @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)
  65886. */
  65887. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  65888. /**
  65889. * Creates a MultiMaterial from parsed MultiMaterial data.
  65890. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  65891. * @param scene defines the hosting scene
  65892. * @returns a new MultiMaterial
  65893. */
  65894. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  65895. }
  65896. }
  65897. declare module BABYLON {
  65898. /**
  65899. * Class used to represent data loading progression
  65900. */
  65901. export class SceneLoaderFlags {
  65902. private static _ForceFullSceneLoadingForIncremental;
  65903. private static _ShowLoadingScreen;
  65904. private static _CleanBoneMatrixWeights;
  65905. private static _loggingLevel;
  65906. /**
  65907. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  65908. */
  65909. static ForceFullSceneLoadingForIncremental: boolean;
  65910. /**
  65911. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  65912. */
  65913. static ShowLoadingScreen: boolean;
  65914. /**
  65915. * Defines the current logging level (while loading the scene)
  65916. * @ignorenaming
  65917. */
  65918. static loggingLevel: number;
  65919. /**
  65920. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  65921. */
  65922. static CleanBoneMatrixWeights: boolean;
  65923. }
  65924. }
  65925. declare module BABYLON {
  65926. /**
  65927. * 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.
  65928. * @see https://doc.babylonjs.com/how_to/transformnode
  65929. */
  65930. export class TransformNode extends Node {
  65931. /**
  65932. * Object will not rotate to face the camera
  65933. */
  65934. static BILLBOARDMODE_NONE: number;
  65935. /**
  65936. * Object will rotate to face the camera but only on the x axis
  65937. */
  65938. static BILLBOARDMODE_X: number;
  65939. /**
  65940. * Object will rotate to face the camera but only on the y axis
  65941. */
  65942. static BILLBOARDMODE_Y: number;
  65943. /**
  65944. * Object will rotate to face the camera but only on the z axis
  65945. */
  65946. static BILLBOARDMODE_Z: number;
  65947. /**
  65948. * Object will rotate to face the camera
  65949. */
  65950. static BILLBOARDMODE_ALL: number;
  65951. private _forward;
  65952. private _forwardInverted;
  65953. private _up;
  65954. private _right;
  65955. private _rightInverted;
  65956. private _position;
  65957. private _rotation;
  65958. private _rotationQuaternion;
  65959. protected _scaling: Vector3;
  65960. protected _isDirty: boolean;
  65961. private _transformToBoneReferal;
  65962. /**
  65963. * Set the billboard mode. Default is 0.
  65964. *
  65965. * | Value | Type | Description |
  65966. * | --- | --- | --- |
  65967. * | 0 | BILLBOARDMODE_NONE | |
  65968. * | 1 | BILLBOARDMODE_X | |
  65969. * | 2 | BILLBOARDMODE_Y | |
  65970. * | 4 | BILLBOARDMODE_Z | |
  65971. * | 7 | BILLBOARDMODE_ALL | |
  65972. *
  65973. */
  65974. billboardMode: number;
  65975. /**
  65976. * 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
  65977. */
  65978. scalingDeterminant: number;
  65979. /**
  65980. * Sets the distance of the object to max, often used by skybox
  65981. */
  65982. infiniteDistance: boolean;
  65983. /**
  65984. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  65985. * By default the system will update normals to compensate
  65986. */
  65987. ignoreNonUniformScaling: boolean;
  65988. /** @hidden */
  65989. _poseMatrix: Matrix;
  65990. /** @hidden */
  65991. _localMatrix: Matrix;
  65992. private _absolutePosition;
  65993. private _pivotMatrix;
  65994. private _pivotMatrixInverse;
  65995. protected _postMultiplyPivotMatrix: boolean;
  65996. private _tempMatrix;
  65997. private _tempMatrix2;
  65998. protected _isWorldMatrixFrozen: boolean;
  65999. /** @hidden */
  66000. _indexInSceneTransformNodesArray: number;
  66001. /**
  66002. * An event triggered after the world matrix is updated
  66003. */
  66004. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  66005. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  66006. /**
  66007. * Gets a string identifying the name of the class
  66008. * @returns "TransformNode" string
  66009. */
  66010. getClassName(): string;
  66011. /**
  66012. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  66013. */
  66014. position: Vector3;
  66015. /**
  66016. * 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)).
  66017. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  66018. */
  66019. rotation: Vector3;
  66020. /**
  66021. * 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)).
  66022. */
  66023. scaling: Vector3;
  66024. /**
  66025. * 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).
  66026. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  66027. */
  66028. rotationQuaternion: Nullable<Quaternion>;
  66029. /**
  66030. * The forward direction of that transform in world space.
  66031. */
  66032. readonly forward: Vector3;
  66033. /**
  66034. * The up direction of that transform in world space.
  66035. */
  66036. readonly up: Vector3;
  66037. /**
  66038. * The right direction of that transform in world space.
  66039. */
  66040. readonly right: Vector3;
  66041. /**
  66042. * Copies the parameter passed Matrix into the mesh Pose matrix.
  66043. * @param matrix the matrix to copy the pose from
  66044. * @returns this TransformNode.
  66045. */
  66046. updatePoseMatrix(matrix: Matrix): TransformNode;
  66047. /**
  66048. * Returns the mesh Pose matrix.
  66049. * @returns the pose matrix
  66050. */
  66051. getPoseMatrix(): Matrix;
  66052. /** @hidden */
  66053. _isSynchronized(): boolean;
  66054. /** @hidden */
  66055. _initCache(): void;
  66056. /**
  66057. * Flag the transform node as dirty (Forcing it to update everything)
  66058. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  66059. * @returns this transform node
  66060. */
  66061. markAsDirty(property: string): TransformNode;
  66062. /**
  66063. * Returns the current mesh absolute position.
  66064. * Returns a Vector3.
  66065. */
  66066. readonly absolutePosition: Vector3;
  66067. /**
  66068. * Sets a new matrix to apply before all other transformation
  66069. * @param matrix defines the transform matrix
  66070. * @returns the current TransformNode
  66071. */
  66072. setPreTransformMatrix(matrix: Matrix): TransformNode;
  66073. /**
  66074. * Sets a new pivot matrix to the current node
  66075. * @param matrix defines the new pivot matrix to use
  66076. * @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
  66077. * @returns the current TransformNode
  66078. */
  66079. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  66080. /**
  66081. * Returns the mesh pivot matrix.
  66082. * Default : Identity.
  66083. * @returns the matrix
  66084. */
  66085. getPivotMatrix(): Matrix;
  66086. /**
  66087. * Prevents the World matrix to be computed any longer.
  66088. * @returns the TransformNode.
  66089. */
  66090. freezeWorldMatrix(): TransformNode;
  66091. /**
  66092. * Allows back the World matrix computation.
  66093. * @returns the TransformNode.
  66094. */
  66095. unfreezeWorldMatrix(): this;
  66096. /**
  66097. * True if the World matrix has been frozen.
  66098. */
  66099. readonly isWorldMatrixFrozen: boolean;
  66100. /**
  66101. * Retuns the mesh absolute position in the World.
  66102. * @returns a Vector3.
  66103. */
  66104. getAbsolutePosition(): Vector3;
  66105. /**
  66106. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  66107. * @param absolutePosition the absolute position to set
  66108. * @returns the TransformNode.
  66109. */
  66110. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  66111. /**
  66112. * Sets the mesh position in its local space.
  66113. * @param vector3 the position to set in localspace
  66114. * @returns the TransformNode.
  66115. */
  66116. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  66117. /**
  66118. * Returns the mesh position in the local space from the current World matrix values.
  66119. * @returns a new Vector3.
  66120. */
  66121. getPositionExpressedInLocalSpace(): Vector3;
  66122. /**
  66123. * Translates the mesh along the passed Vector3 in its local space.
  66124. * @param vector3 the distance to translate in localspace
  66125. * @returns the TransformNode.
  66126. */
  66127. locallyTranslate(vector3: Vector3): TransformNode;
  66128. private static _lookAtVectorCache;
  66129. /**
  66130. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  66131. * @param targetPoint the position (must be in same space as current mesh) to look at
  66132. * @param yawCor optional yaw (y-axis) correction in radians
  66133. * @param pitchCor optional pitch (x-axis) correction in radians
  66134. * @param rollCor optional roll (z-axis) correction in radians
  66135. * @param space the choosen space of the target
  66136. * @returns the TransformNode.
  66137. */
  66138. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  66139. /**
  66140. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  66141. * This Vector3 is expressed in the World space.
  66142. * @param localAxis axis to rotate
  66143. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  66144. */
  66145. getDirection(localAxis: Vector3): Vector3;
  66146. /**
  66147. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  66148. * localAxis is expressed in the mesh local space.
  66149. * result is computed in the Wordl space from the mesh World matrix.
  66150. * @param localAxis axis to rotate
  66151. * @param result the resulting transformnode
  66152. * @returns this TransformNode.
  66153. */
  66154. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  66155. /**
  66156. * Sets this transform node rotation to the given local axis.
  66157. * @param localAxis the axis in local space
  66158. * @param yawCor optional yaw (y-axis) correction in radians
  66159. * @param pitchCor optional pitch (x-axis) correction in radians
  66160. * @param rollCor optional roll (z-axis) correction in radians
  66161. * @returns this TransformNode
  66162. */
  66163. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  66164. /**
  66165. * Sets a new pivot point to the current node
  66166. * @param point defines the new pivot point to use
  66167. * @param space defines if the point is in world or local space (local by default)
  66168. * @returns the current TransformNode
  66169. */
  66170. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  66171. /**
  66172. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  66173. * @returns the pivot point
  66174. */
  66175. getPivotPoint(): Vector3;
  66176. /**
  66177. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  66178. * @param result the vector3 to store the result
  66179. * @returns this TransformNode.
  66180. */
  66181. getPivotPointToRef(result: Vector3): TransformNode;
  66182. /**
  66183. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  66184. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  66185. */
  66186. getAbsolutePivotPoint(): Vector3;
  66187. /**
  66188. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  66189. * @param result vector3 to store the result
  66190. * @returns this TransformNode.
  66191. */
  66192. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  66193. /**
  66194. * Defines the passed node as the parent of the current node.
  66195. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  66196. * @see https://doc.babylonjs.com/how_to/parenting
  66197. * @param node the node ot set as the parent
  66198. * @returns this TransformNode.
  66199. */
  66200. setParent(node: Nullable<Node>): TransformNode;
  66201. private _nonUniformScaling;
  66202. /**
  66203. * True if the scaling property of this object is non uniform eg. (1,2,1)
  66204. */
  66205. readonly nonUniformScaling: boolean;
  66206. /** @hidden */
  66207. _updateNonUniformScalingState(value: boolean): boolean;
  66208. /**
  66209. * Attach the current TransformNode to another TransformNode associated with a bone
  66210. * @param bone Bone affecting the TransformNode
  66211. * @param affectedTransformNode TransformNode associated with the bone
  66212. * @returns this object
  66213. */
  66214. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  66215. /**
  66216. * Detach the transform node if its associated with a bone
  66217. * @returns this object
  66218. */
  66219. detachFromBone(): TransformNode;
  66220. private static _rotationAxisCache;
  66221. /**
  66222. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  66223. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  66224. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  66225. * The passed axis is also normalized.
  66226. * @param axis the axis to rotate around
  66227. * @param amount the amount to rotate in radians
  66228. * @param space Space to rotate in (Default: local)
  66229. * @returns the TransformNode.
  66230. */
  66231. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  66232. /**
  66233. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  66234. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  66235. * The passed axis is also normalized. .
  66236. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  66237. * @param point the point to rotate around
  66238. * @param axis the axis to rotate around
  66239. * @param amount the amount to rotate in radians
  66240. * @returns the TransformNode
  66241. */
  66242. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  66243. /**
  66244. * Translates the mesh along the axis vector for the passed distance in the given space.
  66245. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  66246. * @param axis the axis to translate in
  66247. * @param distance the distance to translate
  66248. * @param space Space to rotate in (Default: local)
  66249. * @returns the TransformNode.
  66250. */
  66251. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  66252. /**
  66253. * Adds a rotation step to the mesh current rotation.
  66254. * x, y, z are Euler angles expressed in radians.
  66255. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  66256. * This means this rotation is made in the mesh local space only.
  66257. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  66258. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  66259. * ```javascript
  66260. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  66261. * ```
  66262. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  66263. * 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.
  66264. * @param x Rotation to add
  66265. * @param y Rotation to add
  66266. * @param z Rotation to add
  66267. * @returns the TransformNode.
  66268. */
  66269. addRotation(x: number, y: number, z: number): TransformNode;
  66270. /**
  66271. * Computes the world matrix of the node
  66272. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  66273. * @returns the world matrix
  66274. */
  66275. computeWorldMatrix(force?: boolean): Matrix;
  66276. protected _afterComputeWorldMatrix(): void;
  66277. /**
  66278. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  66279. * @param func callback function to add
  66280. *
  66281. * @returns the TransformNode.
  66282. */
  66283. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  66284. /**
  66285. * Removes a registered callback function.
  66286. * @param func callback function to remove
  66287. * @returns the TransformNode.
  66288. */
  66289. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  66290. /**
  66291. * Gets the position of the current mesh in camera space
  66292. * @param camera defines the camera to use
  66293. * @returns a position
  66294. */
  66295. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  66296. /**
  66297. * Returns the distance from the mesh to the active camera
  66298. * @param camera defines the camera to use
  66299. * @returns the distance
  66300. */
  66301. getDistanceToCamera(camera?: Nullable<Camera>): number;
  66302. /**
  66303. * Clone the current transform node
  66304. * @param name Name of the new clone
  66305. * @param newParent New parent for the clone
  66306. * @param doNotCloneChildren Do not clone children hierarchy
  66307. * @returns the new transform node
  66308. */
  66309. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  66310. /**
  66311. * Serializes the objects information.
  66312. * @param currentSerializationObject defines the object to serialize in
  66313. * @returns the serialized object
  66314. */
  66315. serialize(currentSerializationObject?: any): any;
  66316. /**
  66317. * Returns a new TransformNode object parsed from the source provided.
  66318. * @param parsedTransformNode is the source.
  66319. * @param scene the scne the object belongs to
  66320. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  66321. * @returns a new TransformNode object parsed from the source provided.
  66322. */
  66323. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  66324. /**
  66325. * Get all child-transformNodes of this node
  66326. * @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
  66327. * @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
  66328. * @returns an array of TransformNode
  66329. */
  66330. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  66331. /**
  66332. * Releases resources associated with this transform node.
  66333. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  66334. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  66335. */
  66336. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  66337. }
  66338. }
  66339. declare module BABYLON {
  66340. /**
  66341. * Class used to override all child animations of a given target
  66342. */
  66343. export class AnimationPropertiesOverride {
  66344. /**
  66345. * Gets or sets a value indicating if animation blending must be used
  66346. */
  66347. enableBlending: boolean;
  66348. /**
  66349. * Gets or sets the blending speed to use when enableBlending is true
  66350. */
  66351. blendingSpeed: number;
  66352. /**
  66353. * Gets or sets the default loop mode to use
  66354. */
  66355. loopMode: number;
  66356. }
  66357. }
  66358. declare module BABYLON {
  66359. /**
  66360. * Class used to store bone information
  66361. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  66362. */
  66363. export class Bone extends Node {
  66364. /**
  66365. * defines the bone name
  66366. */
  66367. name: string;
  66368. private static _tmpVecs;
  66369. private static _tmpQuat;
  66370. private static _tmpMats;
  66371. /**
  66372. * Gets the list of child bones
  66373. */
  66374. children: Bone[];
  66375. /** Gets the animations associated with this bone */
  66376. animations: Animation[];
  66377. /**
  66378. * Gets or sets bone length
  66379. */
  66380. length: number;
  66381. /**
  66382. * @hidden Internal only
  66383. * Set this value to map this bone to a different index in the transform matrices
  66384. * Set this value to -1 to exclude the bone from the transform matrices
  66385. */
  66386. _index: Nullable<number>;
  66387. private _skeleton;
  66388. private _localMatrix;
  66389. private _restPose;
  66390. private _baseMatrix;
  66391. private _absoluteTransform;
  66392. private _invertedAbsoluteTransform;
  66393. private _parent;
  66394. private _scalingDeterminant;
  66395. private _worldTransform;
  66396. private _localScaling;
  66397. private _localRotation;
  66398. private _localPosition;
  66399. private _needToDecompose;
  66400. private _needToCompose;
  66401. /** @hidden */
  66402. _linkedTransformNode: Nullable<TransformNode>;
  66403. /** @hidden */
  66404. /** @hidden */
  66405. _matrix: Matrix;
  66406. /**
  66407. * Create a new bone
  66408. * @param name defines the bone name
  66409. * @param skeleton defines the parent skeleton
  66410. * @param parentBone defines the parent (can be null if the bone is the root)
  66411. * @param localMatrix defines the local matrix
  66412. * @param restPose defines the rest pose matrix
  66413. * @param baseMatrix defines the base matrix
  66414. * @param index defines index of the bone in the hiearchy
  66415. */
  66416. constructor(
  66417. /**
  66418. * defines the bone name
  66419. */
  66420. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  66421. /**
  66422. * Gets the current object class name.
  66423. * @return the class name
  66424. */
  66425. getClassName(): string;
  66426. /**
  66427. * Gets the parent skeleton
  66428. * @returns a skeleton
  66429. */
  66430. getSkeleton(): Skeleton;
  66431. /**
  66432. * Gets parent bone
  66433. * @returns a bone or null if the bone is the root of the bone hierarchy
  66434. */
  66435. getParent(): Nullable<Bone>;
  66436. /**
  66437. * Returns an array containing the root bones
  66438. * @returns an array containing the root bones
  66439. */
  66440. getChildren(): Array<Bone>;
  66441. /**
  66442. * Sets the parent bone
  66443. * @param parent defines the parent (can be null if the bone is the root)
  66444. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  66445. */
  66446. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  66447. /**
  66448. * Gets the local matrix
  66449. * @returns a matrix
  66450. */
  66451. getLocalMatrix(): Matrix;
  66452. /**
  66453. * Gets the base matrix (initial matrix which remains unchanged)
  66454. * @returns a matrix
  66455. */
  66456. getBaseMatrix(): Matrix;
  66457. /**
  66458. * Gets the rest pose matrix
  66459. * @returns a matrix
  66460. */
  66461. getRestPose(): Matrix;
  66462. /**
  66463. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  66464. */
  66465. getWorldMatrix(): Matrix;
  66466. /**
  66467. * Sets the local matrix to rest pose matrix
  66468. */
  66469. returnToRest(): void;
  66470. /**
  66471. * Gets the inverse of the absolute transform matrix.
  66472. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  66473. * @returns a matrix
  66474. */
  66475. getInvertedAbsoluteTransform(): Matrix;
  66476. /**
  66477. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  66478. * @returns a matrix
  66479. */
  66480. getAbsoluteTransform(): Matrix;
  66481. /**
  66482. * Links with the given transform node.
  66483. * The local matrix of this bone is copied from the transform node every frame.
  66484. * @param transformNode defines the transform node to link to
  66485. */
  66486. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  66487. /** Gets or sets current position (in local space) */
  66488. position: Vector3;
  66489. /** Gets or sets current rotation (in local space) */
  66490. rotation: Vector3;
  66491. /** Gets or sets current rotation quaternion (in local space) */
  66492. rotationQuaternion: Quaternion;
  66493. /** Gets or sets current scaling (in local space) */
  66494. scaling: Vector3;
  66495. /**
  66496. * Gets the animation properties override
  66497. */
  66498. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  66499. private _decompose;
  66500. private _compose;
  66501. /**
  66502. * Update the base and local matrices
  66503. * @param matrix defines the new base or local matrix
  66504. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  66505. * @param updateLocalMatrix defines if the local matrix should be updated
  66506. */
  66507. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  66508. /** @hidden */
  66509. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  66510. /**
  66511. * Flag the bone as dirty (Forcing it to update everything)
  66512. */
  66513. markAsDirty(): void;
  66514. private _markAsDirtyAndCompose;
  66515. private _markAsDirtyAndDecompose;
  66516. /**
  66517. * Translate the bone in local or world space
  66518. * @param vec The amount to translate the bone
  66519. * @param space The space that the translation is in
  66520. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66521. */
  66522. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  66523. /**
  66524. * Set the postion of the bone in local or world space
  66525. * @param position The position to set the bone
  66526. * @param space The space that the position is in
  66527. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66528. */
  66529. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  66530. /**
  66531. * Set the absolute position of the bone (world space)
  66532. * @param position The position to set the bone
  66533. * @param mesh The mesh that this bone is attached to
  66534. */
  66535. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  66536. /**
  66537. * Scale the bone on the x, y and z axes (in local space)
  66538. * @param x The amount to scale the bone on the x axis
  66539. * @param y The amount to scale the bone on the y axis
  66540. * @param z The amount to scale the bone on the z axis
  66541. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  66542. */
  66543. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  66544. /**
  66545. * Set the bone scaling in local space
  66546. * @param scale defines the scaling vector
  66547. */
  66548. setScale(scale: Vector3): void;
  66549. /**
  66550. * Gets the current scaling in local space
  66551. * @returns the current scaling vector
  66552. */
  66553. getScale(): Vector3;
  66554. /**
  66555. * Gets the current scaling in local space and stores it in a target vector
  66556. * @param result defines the target vector
  66557. */
  66558. getScaleToRef(result: Vector3): void;
  66559. /**
  66560. * Set the yaw, pitch, and roll of the bone in local or world space
  66561. * @param yaw The rotation of the bone on the y axis
  66562. * @param pitch The rotation of the bone on the x axis
  66563. * @param roll The rotation of the bone on the z axis
  66564. * @param space The space that the axes of rotation are in
  66565. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66566. */
  66567. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  66568. /**
  66569. * Add a rotation to the bone on an axis in local or world space
  66570. * @param axis The axis to rotate the bone on
  66571. * @param amount The amount to rotate the bone
  66572. * @param space The space that the axis is in
  66573. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66574. */
  66575. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  66576. /**
  66577. * Set the rotation of the bone to a particular axis angle in local or world space
  66578. * @param axis The axis to rotate the bone on
  66579. * @param angle The angle that the bone should be rotated to
  66580. * @param space The space that the axis is in
  66581. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66582. */
  66583. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  66584. /**
  66585. * Set the euler rotation of the bone in local of world space
  66586. * @param rotation The euler rotation that the bone should be set to
  66587. * @param space The space that the rotation is in
  66588. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66589. */
  66590. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  66591. /**
  66592. * Set the quaternion rotation of the bone in local of world space
  66593. * @param quat The quaternion rotation that the bone should be set to
  66594. * @param space The space that the rotation is in
  66595. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66596. */
  66597. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  66598. /**
  66599. * Set the rotation matrix of the bone in local of world space
  66600. * @param rotMat The rotation matrix that the bone should be set to
  66601. * @param space The space that the rotation is in
  66602. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66603. */
  66604. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  66605. private _rotateWithMatrix;
  66606. private _getNegativeRotationToRef;
  66607. /**
  66608. * Get the position of the bone in local or world space
  66609. * @param space The space that the returned position is in
  66610. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66611. * @returns The position of the bone
  66612. */
  66613. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  66614. /**
  66615. * Copy the position of the bone to a vector3 in local or world space
  66616. * @param space The space that the returned position is in
  66617. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66618. * @param result The vector3 to copy the position to
  66619. */
  66620. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  66621. /**
  66622. * Get the absolute position of the bone (world space)
  66623. * @param mesh The mesh that this bone is attached to
  66624. * @returns The absolute position of the bone
  66625. */
  66626. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  66627. /**
  66628. * Copy the absolute position of the bone (world space) to the result param
  66629. * @param mesh The mesh that this bone is attached to
  66630. * @param result The vector3 to copy the absolute position to
  66631. */
  66632. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  66633. /**
  66634. * Compute the absolute transforms of this bone and its children
  66635. */
  66636. computeAbsoluteTransforms(): void;
  66637. /**
  66638. * Get the world direction from an axis that is in the local space of the bone
  66639. * @param localAxis The local direction that is used to compute the world direction
  66640. * @param mesh The mesh that this bone is attached to
  66641. * @returns The world direction
  66642. */
  66643. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  66644. /**
  66645. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  66646. * @param localAxis The local direction that is used to compute the world direction
  66647. * @param mesh The mesh that this bone is attached to
  66648. * @param result The vector3 that the world direction will be copied to
  66649. */
  66650. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  66651. /**
  66652. * Get the euler rotation of the bone in local or world space
  66653. * @param space The space that the rotation should be in
  66654. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66655. * @returns The euler rotation
  66656. */
  66657. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  66658. /**
  66659. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  66660. * @param space The space that the rotation should be in
  66661. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66662. * @param result The vector3 that the rotation should be copied to
  66663. */
  66664. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  66665. /**
  66666. * Get the quaternion rotation of the bone in either local or world space
  66667. * @param space The space that the rotation should be in
  66668. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66669. * @returns The quaternion rotation
  66670. */
  66671. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  66672. /**
  66673. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  66674. * @param space The space that the rotation should be in
  66675. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66676. * @param result The quaternion that the rotation should be copied to
  66677. */
  66678. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  66679. /**
  66680. * Get the rotation matrix of the bone in local or world space
  66681. * @param space The space that the rotation should be in
  66682. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66683. * @returns The rotation matrix
  66684. */
  66685. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  66686. /**
  66687. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  66688. * @param space The space that the rotation should be in
  66689. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66690. * @param result The quaternion that the rotation should be copied to
  66691. */
  66692. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  66693. /**
  66694. * Get the world position of a point that is in the local space of the bone
  66695. * @param position The local position
  66696. * @param mesh The mesh that this bone is attached to
  66697. * @returns The world position
  66698. */
  66699. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  66700. /**
  66701. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  66702. * @param position The local position
  66703. * @param mesh The mesh that this bone is attached to
  66704. * @param result The vector3 that the world position should be copied to
  66705. */
  66706. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  66707. /**
  66708. * Get the local position of a point that is in world space
  66709. * @param position The world position
  66710. * @param mesh The mesh that this bone is attached to
  66711. * @returns The local position
  66712. */
  66713. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  66714. /**
  66715. * Get the local position of a point that is in world space and copy it to the result param
  66716. * @param position The world position
  66717. * @param mesh The mesh that this bone is attached to
  66718. * @param result The vector3 that the local position should be copied to
  66719. */
  66720. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  66721. }
  66722. }
  66723. declare module BABYLON {
  66724. /**
  66725. * Enum that determines the text-wrapping mode to use.
  66726. */
  66727. export enum InspectableType {
  66728. /**
  66729. * Checkbox for booleans
  66730. */
  66731. Checkbox = 0,
  66732. /**
  66733. * Sliders for numbers
  66734. */
  66735. Slider = 1,
  66736. /**
  66737. * Vector3
  66738. */
  66739. Vector3 = 2,
  66740. /**
  66741. * Quaternions
  66742. */
  66743. Quaternion = 3,
  66744. /**
  66745. * Color3
  66746. */
  66747. Color3 = 4
  66748. }
  66749. /**
  66750. * Interface used to define custom inspectable properties.
  66751. * This interface is used by the inspector to display custom property grids
  66752. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  66753. */
  66754. export interface IInspectable {
  66755. /**
  66756. * Gets the label to display
  66757. */
  66758. label: string;
  66759. /**
  66760. * Gets the name of the property to edit
  66761. */
  66762. propertyName: string;
  66763. /**
  66764. * Gets the type of the editor to use
  66765. */
  66766. type: InspectableType;
  66767. /**
  66768. * Gets the minimum value of the property when using in "slider" mode
  66769. */
  66770. min?: number;
  66771. /**
  66772. * Gets the maximum value of the property when using in "slider" mode
  66773. */
  66774. max?: number;
  66775. /**
  66776. * Gets the setp to use when using in "slider" mode
  66777. */
  66778. step?: number;
  66779. }
  66780. }
  66781. declare module BABYLON {
  66782. /**
  66783. * Class for creating a cube texture
  66784. */
  66785. export class CubeTexture extends BaseTexture {
  66786. private _delayedOnLoad;
  66787. /**
  66788. * The url of the texture
  66789. */
  66790. url: string;
  66791. /**
  66792. * Gets or sets the center of the bounding box associated with the cube texture.
  66793. * It must define where the camera used to render the texture was set
  66794. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  66795. */
  66796. boundingBoxPosition: Vector3;
  66797. private _boundingBoxSize;
  66798. /**
  66799. * Gets or sets the size of the bounding box associated with the cube texture
  66800. * When defined, the cubemap will switch to local mode
  66801. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  66802. * @example https://www.babylonjs-playground.com/#RNASML
  66803. */
  66804. /**
  66805. * Returns the bounding box size
  66806. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  66807. */
  66808. boundingBoxSize: Vector3;
  66809. protected _rotationY: number;
  66810. /**
  66811. * Sets texture matrix rotation angle around Y axis in radians.
  66812. */
  66813. /**
  66814. * Gets texture matrix rotation angle around Y axis radians.
  66815. */
  66816. rotationY: number;
  66817. /**
  66818. * Are mip maps generated for this texture or not.
  66819. */
  66820. readonly noMipmap: boolean;
  66821. private _noMipmap;
  66822. private _files;
  66823. private _extensions;
  66824. private _textureMatrix;
  66825. private _format;
  66826. private _createPolynomials;
  66827. /** @hidden */
  66828. _prefiltered: boolean;
  66829. /**
  66830. * Creates a cube texture from an array of image urls
  66831. * @param files defines an array of image urls
  66832. * @param scene defines the hosting scene
  66833. * @param noMipmap specifies if mip maps are not used
  66834. * @returns a cube texture
  66835. */
  66836. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  66837. /**
  66838. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  66839. * @param url defines the url of the prefiltered texture
  66840. * @param scene defines the scene the texture is attached to
  66841. * @param forcedExtension defines the extension of the file if different from the url
  66842. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  66843. * @return the prefiltered texture
  66844. */
  66845. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  66846. /**
  66847. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  66848. * as prefiltered data.
  66849. * @param rootUrl defines the url of the texture or the root name of the six images
  66850. * @param scene defines the scene the texture is attached to
  66851. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  66852. * @param noMipmap defines if mipmaps should be created or not
  66853. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  66854. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  66855. * @param onError defines a callback triggered in case of error during load
  66856. * @param format defines the internal format to use for the texture once loaded
  66857. * @param prefiltered defines whether or not the texture is created from prefiltered data
  66858. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  66859. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  66860. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  66861. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  66862. * @return the cube texture
  66863. */
  66864. 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);
  66865. /**
  66866. * Get the current class name of the texture useful for serialization or dynamic coding.
  66867. * @returns "CubeTexture"
  66868. */
  66869. getClassName(): string;
  66870. /**
  66871. * Update the url (and optional buffer) of this texture if url was null during construction.
  66872. * @param url the url of the texture
  66873. * @param forcedExtension defines the extension to use
  66874. * @param onLoad callback called when the texture is loaded (defaults to null)
  66875. */
  66876. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  66877. /**
  66878. * Delays loading of the cube texture
  66879. * @param forcedExtension defines the extension to use
  66880. */
  66881. delayLoad(forcedExtension?: string): void;
  66882. /**
  66883. * Returns the reflection texture matrix
  66884. * @returns the reflection texture matrix
  66885. */
  66886. getReflectionTextureMatrix(): Matrix;
  66887. /**
  66888. * Sets the reflection texture matrix
  66889. * @param value Reflection texture matrix
  66890. */
  66891. setReflectionTextureMatrix(value: Matrix): void;
  66892. /**
  66893. * Parses text to create a cube texture
  66894. * @param parsedTexture define the serialized text to read from
  66895. * @param scene defines the hosting scene
  66896. * @param rootUrl defines the root url of the cube texture
  66897. * @returns a cube texture
  66898. */
  66899. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  66900. /**
  66901. * Makes a clone, or deep copy, of the cube texture
  66902. * @returns a new cube texture
  66903. */
  66904. clone(): CubeTexture;
  66905. }
  66906. }
  66907. declare module BABYLON {
  66908. /** @hidden */
  66909. export var postprocessVertexShader: {
  66910. name: string;
  66911. shader: string;
  66912. };
  66913. }
  66914. declare module BABYLON {
  66915. /**
  66916. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  66917. * This is the base of the follow, arc rotate cameras and Free camera
  66918. * @see http://doc.babylonjs.com/features/cameras
  66919. */
  66920. export class TargetCamera extends Camera {
  66921. private static _RigCamTransformMatrix;
  66922. private static _TargetTransformMatrix;
  66923. private static _TargetFocalPoint;
  66924. /**
  66925. * Define the current direction the camera is moving to
  66926. */
  66927. cameraDirection: Vector3;
  66928. /**
  66929. * Define the current rotation the camera is rotating to
  66930. */
  66931. cameraRotation: Vector2;
  66932. /**
  66933. * When set, the up vector of the camera will be updated by the rotation of the camera
  66934. */
  66935. updateUpVectorFromRotation: boolean;
  66936. private _tmpQuaternion;
  66937. /**
  66938. * Define the current rotation of the camera
  66939. */
  66940. rotation: Vector3;
  66941. /**
  66942. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  66943. */
  66944. rotationQuaternion: Quaternion;
  66945. /**
  66946. * Define the current speed of the camera
  66947. */
  66948. speed: number;
  66949. /**
  66950. * Add cconstraint to the camera to prevent it to move freely in all directions and
  66951. * around all axis.
  66952. */
  66953. noRotationConstraint: boolean;
  66954. /**
  66955. * Define the current target of the camera as an object or a position.
  66956. */
  66957. lockedTarget: any;
  66958. /** @hidden */
  66959. _currentTarget: Vector3;
  66960. /** @hidden */
  66961. _initialFocalDistance: number;
  66962. /** @hidden */
  66963. _viewMatrix: Matrix;
  66964. /** @hidden */
  66965. _camMatrix: Matrix;
  66966. /** @hidden */
  66967. _cameraTransformMatrix: Matrix;
  66968. /** @hidden */
  66969. _cameraRotationMatrix: Matrix;
  66970. /** @hidden */
  66971. _referencePoint: Vector3;
  66972. /** @hidden */
  66973. _transformedReferencePoint: Vector3;
  66974. protected _globalCurrentTarget: Vector3;
  66975. protected _globalCurrentUpVector: Vector3;
  66976. /** @hidden */
  66977. _reset: () => void;
  66978. private _defaultUp;
  66979. /**
  66980. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  66981. * This is the base of the follow, arc rotate cameras and Free camera
  66982. * @see http://doc.babylonjs.com/features/cameras
  66983. * @param name Defines the name of the camera in the scene
  66984. * @param position Defines the start position of the camera in the scene
  66985. * @param scene Defines the scene the camera belongs to
  66986. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  66987. */
  66988. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  66989. /**
  66990. * Gets the position in front of the camera at a given distance.
  66991. * @param distance The distance from the camera we want the position to be
  66992. * @returns the position
  66993. */
  66994. getFrontPosition(distance: number): Vector3;
  66995. /** @hidden */
  66996. _getLockedTargetPosition(): Nullable<Vector3>;
  66997. private _storedPosition;
  66998. private _storedRotation;
  66999. private _storedRotationQuaternion;
  67000. /**
  67001. * Store current camera state of the camera (fov, position, rotation, etc..)
  67002. * @returns the camera
  67003. */
  67004. storeState(): Camera;
  67005. /**
  67006. * Restored camera state. You must call storeState() first
  67007. * @returns whether it was successful or not
  67008. * @hidden
  67009. */
  67010. _restoreStateValues(): boolean;
  67011. /** @hidden */
  67012. _initCache(): void;
  67013. /** @hidden */
  67014. _updateCache(ignoreParentClass?: boolean): void;
  67015. /** @hidden */
  67016. _isSynchronizedViewMatrix(): boolean;
  67017. /** @hidden */
  67018. _computeLocalCameraSpeed(): number;
  67019. /**
  67020. * Defines the target the camera should look at.
  67021. * This will automatically adapt alpha beta and radius to fit within the new target.
  67022. * @param target Defines the new target as a Vector or a mesh
  67023. */
  67024. setTarget(target: Vector3): void;
  67025. /**
  67026. * Return the current target position of the camera. This value is expressed in local space.
  67027. * @returns the target position
  67028. */
  67029. getTarget(): Vector3;
  67030. /** @hidden */
  67031. _decideIfNeedsToMove(): boolean;
  67032. /** @hidden */
  67033. _updatePosition(): void;
  67034. /** @hidden */
  67035. _checkInputs(): void;
  67036. protected _updateCameraRotationMatrix(): void;
  67037. /**
  67038. * 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)
  67039. * @returns the current camera
  67040. */
  67041. private _rotateUpVectorWithCameraRotationMatrix;
  67042. private _cachedRotationZ;
  67043. private _cachedQuaternionRotationZ;
  67044. /** @hidden */
  67045. _getViewMatrix(): Matrix;
  67046. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  67047. /**
  67048. * @hidden
  67049. */
  67050. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  67051. /**
  67052. * @hidden
  67053. */
  67054. _updateRigCameras(): void;
  67055. private _getRigCamPositionAndTarget;
  67056. /**
  67057. * Gets the current object class name.
  67058. * @return the class name
  67059. */
  67060. getClassName(): string;
  67061. }
  67062. }
  67063. declare module BABYLON {
  67064. /**
  67065. * @ignore
  67066. * This is a list of all the different input types that are available in the application.
  67067. * Fo instance: ArcRotateCameraGamepadInput...
  67068. */
  67069. export var CameraInputTypes: {};
  67070. /**
  67071. * This is the contract to implement in order to create a new input class.
  67072. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  67073. */
  67074. export interface ICameraInput<TCamera extends Camera> {
  67075. /**
  67076. * Defines the camera the input is attached to.
  67077. */
  67078. camera: Nullable<TCamera>;
  67079. /**
  67080. * Gets the class name of the current intput.
  67081. * @returns the class name
  67082. */
  67083. getClassName(): string;
  67084. /**
  67085. * Get the friendly name associated with the input class.
  67086. * @returns the input friendly name
  67087. */
  67088. getSimpleName(): string;
  67089. /**
  67090. * Attach the input controls to a specific dom element to get the input from.
  67091. * @param element Defines the element the controls should be listened from
  67092. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  67093. */
  67094. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  67095. /**
  67096. * Detach the current controls from the specified dom element.
  67097. * @param element Defines the element to stop listening the inputs from
  67098. */
  67099. detachControl(element: Nullable<HTMLElement>): void;
  67100. /**
  67101. * Update the current camera state depending on the inputs that have been used this frame.
  67102. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  67103. */
  67104. checkInputs?: () => void;
  67105. }
  67106. /**
  67107. * Represents a map of input types to input instance or input index to input instance.
  67108. */
  67109. export interface CameraInputsMap<TCamera extends Camera> {
  67110. /**
  67111. * Accessor to the input by input type.
  67112. */
  67113. [name: string]: ICameraInput<TCamera>;
  67114. /**
  67115. * Accessor to the input by input index.
  67116. */
  67117. [idx: number]: ICameraInput<TCamera>;
  67118. }
  67119. /**
  67120. * This represents the input manager used within a camera.
  67121. * It helps dealing with all the different kind of input attached to a camera.
  67122. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  67123. */
  67124. export class CameraInputsManager<TCamera extends Camera> {
  67125. /**
  67126. * Defines the list of inputs attahed to the camera.
  67127. */
  67128. attached: CameraInputsMap<TCamera>;
  67129. /**
  67130. * Defines the dom element the camera is collecting inputs from.
  67131. * This is null if the controls have not been attached.
  67132. */
  67133. attachedElement: Nullable<HTMLElement>;
  67134. /**
  67135. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  67136. */
  67137. noPreventDefault: boolean;
  67138. /**
  67139. * Defined the camera the input manager belongs to.
  67140. */
  67141. camera: TCamera;
  67142. /**
  67143. * Update the current camera state depending on the inputs that have been used this frame.
  67144. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  67145. */
  67146. checkInputs: () => void;
  67147. /**
  67148. * Instantiate a new Camera Input Manager.
  67149. * @param camera Defines the camera the input manager blongs to
  67150. */
  67151. constructor(camera: TCamera);
  67152. /**
  67153. * Add an input method to a camera
  67154. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  67155. * @param input camera input method
  67156. */
  67157. add(input: ICameraInput<TCamera>): void;
  67158. /**
  67159. * Remove a specific input method from a camera
  67160. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  67161. * @param inputToRemove camera input method
  67162. */
  67163. remove(inputToRemove: ICameraInput<TCamera>): void;
  67164. /**
  67165. * Remove a specific input type from a camera
  67166. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  67167. * @param inputType the type of the input to remove
  67168. */
  67169. removeByType(inputType: string): void;
  67170. private _addCheckInputs;
  67171. /**
  67172. * Attach the input controls to the currently attached dom element to listen the events from.
  67173. * @param input Defines the input to attach
  67174. */
  67175. attachInput(input: ICameraInput<TCamera>): void;
  67176. /**
  67177. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  67178. * @param element Defines the dom element to collect the events from
  67179. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  67180. */
  67181. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  67182. /**
  67183. * Detach the current manager inputs controls from a specific dom element.
  67184. * @param element Defines the dom element to collect the events from
  67185. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  67186. */
  67187. detachElement(element: HTMLElement, disconnect?: boolean): void;
  67188. /**
  67189. * Rebuild the dynamic inputCheck function from the current list of
  67190. * defined inputs in the manager.
  67191. */
  67192. rebuildInputCheck(): void;
  67193. /**
  67194. * Remove all attached input methods from a camera
  67195. */
  67196. clear(): void;
  67197. /**
  67198. * Serialize the current input manager attached to a camera.
  67199. * This ensures than once parsed,
  67200. * the input associated to the camera will be identical to the current ones
  67201. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  67202. */
  67203. serialize(serializedCamera: any): void;
  67204. /**
  67205. * Parses an input manager serialized JSON to restore the previous list of inputs
  67206. * and states associated to a camera.
  67207. * @param parsedCamera Defines the JSON to parse
  67208. */
  67209. parse(parsedCamera: any): void;
  67210. }
  67211. }
  67212. declare module BABYLON {
  67213. /**
  67214. * Gather the list of keyboard event types as constants.
  67215. */
  67216. export class KeyboardEventTypes {
  67217. /**
  67218. * The keydown event is fired when a key becomes active (pressed).
  67219. */
  67220. static readonly KEYDOWN: number;
  67221. /**
  67222. * The keyup event is fired when a key has been released.
  67223. */
  67224. static readonly KEYUP: number;
  67225. }
  67226. /**
  67227. * This class is used to store keyboard related info for the onKeyboardObservable event.
  67228. */
  67229. export class KeyboardInfo {
  67230. /**
  67231. * Defines the type of event (KeyboardEventTypes)
  67232. */
  67233. type: number;
  67234. /**
  67235. * Defines the related dom event
  67236. */
  67237. event: KeyboardEvent;
  67238. /**
  67239. * Instantiates a new keyboard info.
  67240. * This class is used to store keyboard related info for the onKeyboardObservable event.
  67241. * @param type Defines the type of event (KeyboardEventTypes)
  67242. * @param event Defines the related dom event
  67243. */
  67244. constructor(
  67245. /**
  67246. * Defines the type of event (KeyboardEventTypes)
  67247. */
  67248. type: number,
  67249. /**
  67250. * Defines the related dom event
  67251. */
  67252. event: KeyboardEvent);
  67253. }
  67254. /**
  67255. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  67256. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  67257. */
  67258. export class KeyboardInfoPre extends KeyboardInfo {
  67259. /**
  67260. * Defines the type of event (KeyboardEventTypes)
  67261. */
  67262. type: number;
  67263. /**
  67264. * Defines the related dom event
  67265. */
  67266. event: KeyboardEvent;
  67267. /**
  67268. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  67269. */
  67270. skipOnPointerObservable: boolean;
  67271. /**
  67272. * Instantiates a new keyboard pre info.
  67273. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  67274. * @param type Defines the type of event (KeyboardEventTypes)
  67275. * @param event Defines the related dom event
  67276. */
  67277. constructor(
  67278. /**
  67279. * Defines the type of event (KeyboardEventTypes)
  67280. */
  67281. type: number,
  67282. /**
  67283. * Defines the related dom event
  67284. */
  67285. event: KeyboardEvent);
  67286. }
  67287. }
  67288. declare module BABYLON {
  67289. /**
  67290. * Manage the keyboard inputs to control the movement of a free camera.
  67291. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  67292. */
  67293. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  67294. /**
  67295. * Defines the camera the input is attached to.
  67296. */
  67297. camera: FreeCamera;
  67298. /**
  67299. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  67300. */
  67301. keysUp: number[];
  67302. /**
  67303. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  67304. */
  67305. keysDown: number[];
  67306. /**
  67307. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  67308. */
  67309. keysLeft: number[];
  67310. /**
  67311. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  67312. */
  67313. keysRight: number[];
  67314. private _keys;
  67315. private _onCanvasBlurObserver;
  67316. private _onKeyboardObserver;
  67317. private _engine;
  67318. private _scene;
  67319. /**
  67320. * Attach the input controls to a specific dom element to get the input from.
  67321. * @param element Defines the element the controls should be listened from
  67322. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  67323. */
  67324. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  67325. /**
  67326. * Detach the current controls from the specified dom element.
  67327. * @param element Defines the element to stop listening the inputs from
  67328. */
  67329. detachControl(element: Nullable<HTMLElement>): void;
  67330. /**
  67331. * Update the current camera state depending on the inputs that have been used this frame.
  67332. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  67333. */
  67334. checkInputs(): void;
  67335. /**
  67336. * Gets the class name of the current intput.
  67337. * @returns the class name
  67338. */
  67339. getClassName(): string;
  67340. /** @hidden */
  67341. _onLostFocus(): void;
  67342. /**
  67343. * Get the friendly name associated with the input class.
  67344. * @returns the input friendly name
  67345. */
  67346. getSimpleName(): string;
  67347. }
  67348. }
  67349. declare module BABYLON {
  67350. /**
  67351. * Interface describing all the common properties and methods a shadow light needs to implement.
  67352. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  67353. * as well as binding the different shadow properties to the effects.
  67354. */
  67355. export interface IShadowLight extends Light {
  67356. /**
  67357. * The light id in the scene (used in scene.findLighById for instance)
  67358. */
  67359. id: string;
  67360. /**
  67361. * The position the shdow will be casted from.
  67362. */
  67363. position: Vector3;
  67364. /**
  67365. * In 2d mode (needCube being false), the direction used to cast the shadow.
  67366. */
  67367. direction: Vector3;
  67368. /**
  67369. * The transformed position. Position of the light in world space taking parenting in account.
  67370. */
  67371. transformedPosition: Vector3;
  67372. /**
  67373. * The transformed direction. Direction of the light in world space taking parenting in account.
  67374. */
  67375. transformedDirection: Vector3;
  67376. /**
  67377. * The friendly name of the light in the scene.
  67378. */
  67379. name: string;
  67380. /**
  67381. * Defines the shadow projection clipping minimum z value.
  67382. */
  67383. shadowMinZ: number;
  67384. /**
  67385. * Defines the shadow projection clipping maximum z value.
  67386. */
  67387. shadowMaxZ: number;
  67388. /**
  67389. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  67390. * @returns true if the information has been computed, false if it does not need to (no parenting)
  67391. */
  67392. computeTransformedInformation(): boolean;
  67393. /**
  67394. * Gets the scene the light belongs to.
  67395. * @returns The scene
  67396. */
  67397. getScene(): Scene;
  67398. /**
  67399. * Callback defining a custom Projection Matrix Builder.
  67400. * This can be used to override the default projection matrix computation.
  67401. */
  67402. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  67403. /**
  67404. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  67405. * @param matrix The materix to updated with the projection information
  67406. * @param viewMatrix The transform matrix of the light
  67407. * @param renderList The list of mesh to render in the map
  67408. * @returns The current light
  67409. */
  67410. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  67411. /**
  67412. * Gets the current depth scale used in ESM.
  67413. * @returns The scale
  67414. */
  67415. getDepthScale(): number;
  67416. /**
  67417. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  67418. * @returns true if a cube texture needs to be use
  67419. */
  67420. needCube(): boolean;
  67421. /**
  67422. * Detects if the projection matrix requires to be recomputed this frame.
  67423. * @returns true if it requires to be recomputed otherwise, false.
  67424. */
  67425. needProjectionMatrixCompute(): boolean;
  67426. /**
  67427. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  67428. */
  67429. forceProjectionMatrixCompute(): void;
  67430. /**
  67431. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  67432. * @param faceIndex The index of the face we are computed the direction to generate shadow
  67433. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  67434. */
  67435. getShadowDirection(faceIndex?: number): Vector3;
  67436. /**
  67437. * Gets the minZ used for shadow according to both the scene and the light.
  67438. * @param activeCamera The camera we are returning the min for
  67439. * @returns the depth min z
  67440. */
  67441. getDepthMinZ(activeCamera: Camera): number;
  67442. /**
  67443. * Gets the maxZ used for shadow according to both the scene and the light.
  67444. * @param activeCamera The camera we are returning the max for
  67445. * @returns the depth max z
  67446. */
  67447. getDepthMaxZ(activeCamera: Camera): number;
  67448. }
  67449. /**
  67450. * Base implementation IShadowLight
  67451. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  67452. */
  67453. export abstract class ShadowLight extends Light implements IShadowLight {
  67454. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  67455. protected _position: Vector3;
  67456. protected _setPosition(value: Vector3): void;
  67457. /**
  67458. * Sets the position the shadow will be casted from. Also use as the light position for both
  67459. * point and spot lights.
  67460. */
  67461. /**
  67462. * Sets the position the shadow will be casted from. Also use as the light position for both
  67463. * point and spot lights.
  67464. */
  67465. position: Vector3;
  67466. protected _direction: Vector3;
  67467. protected _setDirection(value: Vector3): void;
  67468. /**
  67469. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  67470. * Also use as the light direction on spot and directional lights.
  67471. */
  67472. /**
  67473. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  67474. * Also use as the light direction on spot and directional lights.
  67475. */
  67476. direction: Vector3;
  67477. private _shadowMinZ;
  67478. /**
  67479. * Gets the shadow projection clipping minimum z value.
  67480. */
  67481. /**
  67482. * Sets the shadow projection clipping minimum z value.
  67483. */
  67484. shadowMinZ: number;
  67485. private _shadowMaxZ;
  67486. /**
  67487. * Sets the shadow projection clipping maximum z value.
  67488. */
  67489. /**
  67490. * Gets the shadow projection clipping maximum z value.
  67491. */
  67492. shadowMaxZ: number;
  67493. /**
  67494. * Callback defining a custom Projection Matrix Builder.
  67495. * This can be used to override the default projection matrix computation.
  67496. */
  67497. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  67498. /**
  67499. * The transformed position. Position of the light in world space taking parenting in account.
  67500. */
  67501. transformedPosition: Vector3;
  67502. /**
  67503. * The transformed direction. Direction of the light in world space taking parenting in account.
  67504. */
  67505. transformedDirection: Vector3;
  67506. private _needProjectionMatrixCompute;
  67507. /**
  67508. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  67509. * @returns true if the information has been computed, false if it does not need to (no parenting)
  67510. */
  67511. computeTransformedInformation(): boolean;
  67512. /**
  67513. * Return the depth scale used for the shadow map.
  67514. * @returns the depth scale.
  67515. */
  67516. getDepthScale(): number;
  67517. /**
  67518. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  67519. * @param faceIndex The index of the face we are computed the direction to generate shadow
  67520. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  67521. */
  67522. getShadowDirection(faceIndex?: number): Vector3;
  67523. /**
  67524. * Returns the ShadowLight absolute position in the World.
  67525. * @returns the position vector in world space
  67526. */
  67527. getAbsolutePosition(): Vector3;
  67528. /**
  67529. * Sets the ShadowLight direction toward the passed target.
  67530. * @param target The point to target in local space
  67531. * @returns the updated ShadowLight direction
  67532. */
  67533. setDirectionToTarget(target: Vector3): Vector3;
  67534. /**
  67535. * Returns the light rotation in euler definition.
  67536. * @returns the x y z rotation in local space.
  67537. */
  67538. getRotation(): Vector3;
  67539. /**
  67540. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  67541. * @returns true if a cube texture needs to be use
  67542. */
  67543. needCube(): boolean;
  67544. /**
  67545. * Detects if the projection matrix requires to be recomputed this frame.
  67546. * @returns true if it requires to be recomputed otherwise, false.
  67547. */
  67548. needProjectionMatrixCompute(): boolean;
  67549. /**
  67550. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  67551. */
  67552. forceProjectionMatrixCompute(): void;
  67553. /** @hidden */
  67554. _initCache(): void;
  67555. /** @hidden */
  67556. _isSynchronized(): boolean;
  67557. /**
  67558. * Computes the world matrix of the node
  67559. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  67560. * @returns the world matrix
  67561. */
  67562. computeWorldMatrix(force?: boolean): Matrix;
  67563. /**
  67564. * Gets the minZ used for shadow according to both the scene and the light.
  67565. * @param activeCamera The camera we are returning the min for
  67566. * @returns the depth min z
  67567. */
  67568. getDepthMinZ(activeCamera: Camera): number;
  67569. /**
  67570. * Gets the maxZ used for shadow according to both the scene and the light.
  67571. * @param activeCamera The camera we are returning the max for
  67572. * @returns the depth max z
  67573. */
  67574. getDepthMaxZ(activeCamera: Camera): number;
  67575. /**
  67576. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  67577. * @param matrix The materix to updated with the projection information
  67578. * @param viewMatrix The transform matrix of the light
  67579. * @param renderList The list of mesh to render in the map
  67580. * @returns The current light
  67581. */
  67582. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  67583. }
  67584. }
  67585. declare module BABYLON {
  67586. /**
  67587. * "Static Class" containing the most commonly used helper while dealing with material for
  67588. * rendering purpose.
  67589. *
  67590. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  67591. *
  67592. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  67593. */
  67594. export class MaterialHelper {
  67595. /**
  67596. * Bind the current view position to an effect.
  67597. * @param effect The effect to be bound
  67598. * @param scene The scene the eyes position is used from
  67599. */
  67600. static BindEyePosition(effect: Effect, scene: Scene): void;
  67601. /**
  67602. * Helps preparing the defines values about the UVs in used in the effect.
  67603. * UVs are shared as much as we can accross channels in the shaders.
  67604. * @param texture The texture we are preparing the UVs for
  67605. * @param defines The defines to update
  67606. * @param key The channel key "diffuse", "specular"... used in the shader
  67607. */
  67608. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  67609. /**
  67610. * Binds a texture matrix value to its corrsponding uniform
  67611. * @param texture The texture to bind the matrix for
  67612. * @param uniformBuffer The uniform buffer receivin the data
  67613. * @param key The channel key "diffuse", "specular"... used in the shader
  67614. */
  67615. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  67616. /**
  67617. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  67618. * @param mesh defines the current mesh
  67619. * @param scene defines the current scene
  67620. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  67621. * @param pointsCloud defines if point cloud rendering has to be turned on
  67622. * @param fogEnabled defines if fog has to be turned on
  67623. * @param alphaTest defines if alpha testing has to be turned on
  67624. * @param defines defines the current list of defines
  67625. */
  67626. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  67627. /**
  67628. * Helper used to prepare the list of defines associated with frame values for shader compilation
  67629. * @param scene defines the current scene
  67630. * @param engine defines the current engine
  67631. * @param defines specifies the list of active defines
  67632. * @param useInstances defines if instances have to be turned on
  67633. * @param useClipPlane defines if clip plane have to be turned on
  67634. */
  67635. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  67636. /**
  67637. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  67638. * @param mesh The mesh containing the geometry data we will draw
  67639. * @param defines The defines to update
  67640. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  67641. * @param useBones Precise whether bones should be used or not (override mesh info)
  67642. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  67643. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  67644. * @returns false if defines are considered not dirty and have not been checked
  67645. */
  67646. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  67647. /**
  67648. * Prepares the defines related to the light information passed in parameter
  67649. * @param scene The scene we are intending to draw
  67650. * @param mesh The mesh the effect is compiling for
  67651. * @param defines The defines to update
  67652. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  67653. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  67654. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  67655. * @returns true if normals will be required for the rest of the effect
  67656. */
  67657. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  67658. /**
  67659. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  67660. * that won t be acctive due to defines being turned off.
  67661. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  67662. * @param samplersList The samplers list
  67663. * @param defines The defines helping in the list generation
  67664. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  67665. */
  67666. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  67667. /**
  67668. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  67669. * @param defines The defines to update while falling back
  67670. * @param fallbacks The authorized effect fallbacks
  67671. * @param maxSimultaneousLights The maximum number of lights allowed
  67672. * @param rank the current rank of the Effect
  67673. * @returns The newly affected rank
  67674. */
  67675. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  67676. /**
  67677. * Prepares the list of attributes required for morph targets according to the effect defines.
  67678. * @param attribs The current list of supported attribs
  67679. * @param mesh The mesh to prepare the morph targets attributes for
  67680. * @param defines The current Defines of the effect
  67681. */
  67682. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  67683. /**
  67684. * Prepares the list of attributes required for bones according to the effect defines.
  67685. * @param attribs The current list of supported attribs
  67686. * @param mesh The mesh to prepare the bones attributes for
  67687. * @param defines The current Defines of the effect
  67688. * @param fallbacks The current efffect fallback strategy
  67689. */
  67690. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  67691. /**
  67692. * Prepares the list of attributes required for instances according to the effect defines.
  67693. * @param attribs The current list of supported attribs
  67694. * @param defines The current Defines of the effect
  67695. */
  67696. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  67697. /**
  67698. * Binds the light shadow information to the effect for the given mesh.
  67699. * @param light The light containing the generator
  67700. * @param scene The scene the lights belongs to
  67701. * @param mesh The mesh we are binding the information to render
  67702. * @param lightIndex The light index in the effect used to render the mesh
  67703. * @param effect The effect we are binding the data to
  67704. */
  67705. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  67706. /**
  67707. * Binds the light information to the effect.
  67708. * @param light The light containing the generator
  67709. * @param effect The effect we are binding the data to
  67710. * @param lightIndex The light index in the effect used to render
  67711. */
  67712. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  67713. /**
  67714. * Binds the lights information from the scene to the effect for the given mesh.
  67715. * @param scene The scene the lights belongs to
  67716. * @param mesh The mesh we are binding the information to render
  67717. * @param effect The effect we are binding the data to
  67718. * @param defines The generated defines for the effect
  67719. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  67720. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  67721. */
  67722. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  67723. private static _tempFogColor;
  67724. /**
  67725. * Binds the fog information from the scene to the effect for the given mesh.
  67726. * @param scene The scene the lights belongs to
  67727. * @param mesh The mesh we are binding the information to render
  67728. * @param effect The effect we are binding the data to
  67729. * @param linearSpace Defines if the fog effect is applied in linear space
  67730. */
  67731. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  67732. /**
  67733. * Binds the bones information from the mesh to the effect.
  67734. * @param mesh The mesh we are binding the information to render
  67735. * @param effect The effect we are binding the data to
  67736. */
  67737. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  67738. /**
  67739. * Binds the morph targets information from the mesh to the effect.
  67740. * @param abstractMesh The mesh we are binding the information to render
  67741. * @param effect The effect we are binding the data to
  67742. */
  67743. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  67744. /**
  67745. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  67746. * @param defines The generated defines used in the effect
  67747. * @param effect The effect we are binding the data to
  67748. * @param scene The scene we are willing to render with logarithmic scale for
  67749. */
  67750. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  67751. /**
  67752. * Binds the clip plane information from the scene to the effect.
  67753. * @param scene The scene the clip plane information are extracted from
  67754. * @param effect The effect we are binding the data to
  67755. */
  67756. static BindClipPlane(effect: Effect, scene: Scene): void;
  67757. }
  67758. }
  67759. declare module BABYLON {
  67760. /** @hidden */
  67761. export var kernelBlurVaryingDeclaration: {
  67762. name: string;
  67763. shader: string;
  67764. };
  67765. }
  67766. declare module BABYLON {
  67767. /** @hidden */
  67768. export var kernelBlurFragment: {
  67769. name: string;
  67770. shader: string;
  67771. };
  67772. }
  67773. declare module BABYLON {
  67774. /** @hidden */
  67775. export var kernelBlurFragment2: {
  67776. name: string;
  67777. shader: string;
  67778. };
  67779. }
  67780. declare module BABYLON {
  67781. /** @hidden */
  67782. export var kernelBlurPixelShader: {
  67783. name: string;
  67784. shader: string;
  67785. };
  67786. }
  67787. declare module BABYLON {
  67788. /** @hidden */
  67789. export var kernelBlurVertex: {
  67790. name: string;
  67791. shader: string;
  67792. };
  67793. }
  67794. declare module BABYLON {
  67795. /** @hidden */
  67796. export var kernelBlurVertexShader: {
  67797. name: string;
  67798. shader: string;
  67799. };
  67800. }
  67801. declare module BABYLON {
  67802. /**
  67803. * The Blur Post Process which blurs an image based on a kernel and direction.
  67804. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  67805. */
  67806. export class BlurPostProcess extends PostProcess {
  67807. /** The direction in which to blur the image. */
  67808. direction: Vector2;
  67809. private blockCompilation;
  67810. protected _kernel: number;
  67811. protected _idealKernel: number;
  67812. protected _packedFloat: boolean;
  67813. private _staticDefines;
  67814. /**
  67815. * Sets the length in pixels of the blur sample region
  67816. */
  67817. /**
  67818. * Gets the length in pixels of the blur sample region
  67819. */
  67820. kernel: number;
  67821. /**
  67822. * Sets wether or not the blur needs to unpack/repack floats
  67823. */
  67824. /**
  67825. * Gets wether or not the blur is unpacking/repacking floats
  67826. */
  67827. packedFloat: boolean;
  67828. /**
  67829. * Creates a new instance BlurPostProcess
  67830. * @param name The name of the effect.
  67831. * @param direction The direction in which to blur the image.
  67832. * @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.
  67833. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  67834. * @param camera The camera to apply the render pass to.
  67835. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67836. * @param engine The engine which the post process will be applied. (default: current engine)
  67837. * @param reusable If the post process can be reused on the same frame. (default: false)
  67838. * @param textureType Type of textures used when performing the post process. (default: 0)
  67839. * @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)
  67840. */
  67841. constructor(name: string,
  67842. /** The direction in which to blur the image. */
  67843. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  67844. /**
  67845. * Updates the effect with the current post process compile time values and recompiles the shader.
  67846. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67847. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67848. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67849. * @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
  67850. * @param onCompiled Called when the shader has been compiled.
  67851. * @param onError Called if there is an error when compiling a shader.
  67852. */
  67853. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67854. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67855. /**
  67856. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  67857. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  67858. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  67859. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  67860. * The gaps between physical kernels are compensated for in the weighting of the samples
  67861. * @param idealKernel Ideal blur kernel.
  67862. * @return Nearest best kernel.
  67863. */
  67864. protected _nearestBestKernel(idealKernel: number): number;
  67865. /**
  67866. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  67867. * @param x The point on the Gaussian distribution to sample.
  67868. * @return the value of the Gaussian function at x.
  67869. */
  67870. protected _gaussianWeight(x: number): number;
  67871. /**
  67872. * Generates a string that can be used as a floating point number in GLSL.
  67873. * @param x Value to print.
  67874. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  67875. * @return GLSL float string.
  67876. */
  67877. protected _glslFloat(x: number, decimalFigures?: number): string;
  67878. }
  67879. }
  67880. declare module BABYLON {
  67881. /** @hidden */
  67882. export var shadowMapPixelShader: {
  67883. name: string;
  67884. shader: string;
  67885. };
  67886. }
  67887. declare module BABYLON {
  67888. /** @hidden */
  67889. export var bonesDeclaration: {
  67890. name: string;
  67891. shader: string;
  67892. };
  67893. }
  67894. declare module BABYLON {
  67895. /** @hidden */
  67896. export var morphTargetsVertexGlobalDeclaration: {
  67897. name: string;
  67898. shader: string;
  67899. };
  67900. }
  67901. declare module BABYLON {
  67902. /** @hidden */
  67903. export var morphTargetsVertexDeclaration: {
  67904. name: string;
  67905. shader: string;
  67906. };
  67907. }
  67908. declare module BABYLON {
  67909. /** @hidden */
  67910. export var instancesDeclaration: {
  67911. name: string;
  67912. shader: string;
  67913. };
  67914. }
  67915. declare module BABYLON {
  67916. /** @hidden */
  67917. export var helperFunctions: {
  67918. name: string;
  67919. shader: string;
  67920. };
  67921. }
  67922. declare module BABYLON {
  67923. /** @hidden */
  67924. export var morphTargetsVertex: {
  67925. name: string;
  67926. shader: string;
  67927. };
  67928. }
  67929. declare module BABYLON {
  67930. /** @hidden */
  67931. export var instancesVertex: {
  67932. name: string;
  67933. shader: string;
  67934. };
  67935. }
  67936. declare module BABYLON {
  67937. /** @hidden */
  67938. export var bonesVertex: {
  67939. name: string;
  67940. shader: string;
  67941. };
  67942. }
  67943. declare module BABYLON {
  67944. /** @hidden */
  67945. export var shadowMapVertexShader: {
  67946. name: string;
  67947. shader: string;
  67948. };
  67949. }
  67950. declare module BABYLON {
  67951. /** @hidden */
  67952. export var depthBoxBlurPixelShader: {
  67953. name: string;
  67954. shader: string;
  67955. };
  67956. }
  67957. declare module BABYLON {
  67958. /**
  67959. * Defines the options associated with the creation of a custom shader for a shadow generator.
  67960. */
  67961. export interface ICustomShaderOptions {
  67962. /**
  67963. * Gets or sets the custom shader name to use
  67964. */
  67965. shaderName: string;
  67966. /**
  67967. * The list of attribute names used in the shader
  67968. */
  67969. attributes?: string[];
  67970. /**
  67971. * The list of unifrom names used in the shader
  67972. */
  67973. uniforms?: string[];
  67974. /**
  67975. * The list of sampler names used in the shader
  67976. */
  67977. samplers?: string[];
  67978. /**
  67979. * The list of defines used in the shader
  67980. */
  67981. defines?: string[];
  67982. }
  67983. /**
  67984. * Interface to implement to create a shadow generator compatible with BJS.
  67985. */
  67986. export interface IShadowGenerator {
  67987. /**
  67988. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  67989. * @returns The render target texture if present otherwise, null
  67990. */
  67991. getShadowMap(): Nullable<RenderTargetTexture>;
  67992. /**
  67993. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  67994. * @returns The render target texture if the shadow map is present otherwise, null
  67995. */
  67996. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  67997. /**
  67998. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  67999. * @param subMesh The submesh we want to render in the shadow map
  68000. * @param useInstances Defines wether will draw in the map using instances
  68001. * @returns true if ready otherwise, false
  68002. */
  68003. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68004. /**
  68005. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  68006. * @param defines Defines of the material we want to update
  68007. * @param lightIndex Index of the light in the enabled light list of the material
  68008. */
  68009. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  68010. /**
  68011. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  68012. * defined in the generator but impacting the effect).
  68013. * It implies the unifroms available on the materials are the standard BJS ones.
  68014. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  68015. * @param effect The effect we are binfing the information for
  68016. */
  68017. bindShadowLight(lightIndex: string, effect: Effect): void;
  68018. /**
  68019. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  68020. * (eq to shadow prjection matrix * light transform matrix)
  68021. * @returns The transform matrix used to create the shadow map
  68022. */
  68023. getTransformMatrix(): Matrix;
  68024. /**
  68025. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  68026. * Cube and 2D textures for instance.
  68027. */
  68028. recreateShadowMap(): void;
  68029. /**
  68030. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  68031. * @param onCompiled Callback triggered at the and of the effects compilation
  68032. * @param options Sets of optional options forcing the compilation with different modes
  68033. */
  68034. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  68035. useInstances: boolean;
  68036. }>): void;
  68037. /**
  68038. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  68039. * @param options Sets of optional options forcing the compilation with different modes
  68040. * @returns A promise that resolves when the compilation completes
  68041. */
  68042. forceCompilationAsync(options?: Partial<{
  68043. useInstances: boolean;
  68044. }>): Promise<void>;
  68045. /**
  68046. * Serializes the shadow generator setup to a json object.
  68047. * @returns The serialized JSON object
  68048. */
  68049. serialize(): any;
  68050. /**
  68051. * Disposes the Shadow map and related Textures and effects.
  68052. */
  68053. dispose(): void;
  68054. }
  68055. /**
  68056. * Default implementation IShadowGenerator.
  68057. * This is the main object responsible of generating shadows in the framework.
  68058. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  68059. */
  68060. export class ShadowGenerator implements IShadowGenerator {
  68061. /**
  68062. * Shadow generator mode None: no filtering applied.
  68063. */
  68064. static readonly FILTER_NONE: number;
  68065. /**
  68066. * Shadow generator mode ESM: Exponential Shadow Mapping.
  68067. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  68068. */
  68069. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  68070. /**
  68071. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  68072. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  68073. */
  68074. static readonly FILTER_POISSONSAMPLING: number;
  68075. /**
  68076. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  68077. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  68078. */
  68079. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  68080. /**
  68081. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  68082. * edge artifacts on steep falloff.
  68083. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  68084. */
  68085. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  68086. /**
  68087. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  68088. * edge artifacts on steep falloff.
  68089. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  68090. */
  68091. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  68092. /**
  68093. * Shadow generator mode PCF: Percentage Closer Filtering
  68094. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  68095. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  68096. */
  68097. static readonly FILTER_PCF: number;
  68098. /**
  68099. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  68100. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  68101. * Contact Hardening
  68102. */
  68103. static readonly FILTER_PCSS: number;
  68104. /**
  68105. * Reserved for PCF and PCSS
  68106. * Highest Quality.
  68107. *
  68108. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  68109. *
  68110. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  68111. */
  68112. static readonly QUALITY_HIGH: number;
  68113. /**
  68114. * Reserved for PCF and PCSS
  68115. * Good tradeoff for quality/perf cross devices
  68116. *
  68117. * Execute PCF on a 3*3 kernel.
  68118. *
  68119. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  68120. */
  68121. static readonly QUALITY_MEDIUM: number;
  68122. /**
  68123. * Reserved for PCF and PCSS
  68124. * The lowest quality but the fastest.
  68125. *
  68126. * Execute PCF on a 1*1 kernel.
  68127. *
  68128. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  68129. */
  68130. static readonly QUALITY_LOW: number;
  68131. /** Gets or sets the custom shader name to use */
  68132. customShaderOptions: ICustomShaderOptions;
  68133. /**
  68134. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  68135. */
  68136. onBeforeShadowMapRenderObservable: Observable<Effect>;
  68137. /**
  68138. * Observable triggered before a mesh is rendered in the shadow map.
  68139. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  68140. */
  68141. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  68142. private _bias;
  68143. /**
  68144. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  68145. */
  68146. /**
  68147. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  68148. */
  68149. bias: number;
  68150. private _normalBias;
  68151. /**
  68152. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  68153. */
  68154. /**
  68155. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  68156. */
  68157. normalBias: number;
  68158. private _blurBoxOffset;
  68159. /**
  68160. * Gets the blur box offset: offset applied during the blur pass.
  68161. * Only useful if useKernelBlur = false
  68162. */
  68163. /**
  68164. * Sets the blur box offset: offset applied during the blur pass.
  68165. * Only useful if useKernelBlur = false
  68166. */
  68167. blurBoxOffset: number;
  68168. private _blurScale;
  68169. /**
  68170. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  68171. * 2 means half of the size.
  68172. */
  68173. /**
  68174. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  68175. * 2 means half of the size.
  68176. */
  68177. blurScale: number;
  68178. private _blurKernel;
  68179. /**
  68180. * Gets the blur kernel: kernel size of the blur pass.
  68181. * Only useful if useKernelBlur = true
  68182. */
  68183. /**
  68184. * Sets the blur kernel: kernel size of the blur pass.
  68185. * Only useful if useKernelBlur = true
  68186. */
  68187. blurKernel: number;
  68188. private _useKernelBlur;
  68189. /**
  68190. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  68191. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  68192. */
  68193. /**
  68194. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  68195. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  68196. */
  68197. useKernelBlur: boolean;
  68198. private _depthScale;
  68199. /**
  68200. * Gets the depth scale used in ESM mode.
  68201. */
  68202. /**
  68203. * Sets the depth scale used in ESM mode.
  68204. * This can override the scale stored on the light.
  68205. */
  68206. depthScale: number;
  68207. private _filter;
  68208. /**
  68209. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  68210. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  68211. */
  68212. /**
  68213. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  68214. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  68215. */
  68216. filter: number;
  68217. /**
  68218. * Gets if the current filter is set to Poisson Sampling.
  68219. */
  68220. /**
  68221. * Sets the current filter to Poisson Sampling.
  68222. */
  68223. usePoissonSampling: boolean;
  68224. /**
  68225. * Gets if the current filter is set to ESM.
  68226. */
  68227. /**
  68228. * Sets the current filter is to ESM.
  68229. */
  68230. useExponentialShadowMap: boolean;
  68231. /**
  68232. * Gets if the current filter is set to filtered ESM.
  68233. */
  68234. /**
  68235. * Gets if the current filter is set to filtered ESM.
  68236. */
  68237. useBlurExponentialShadowMap: boolean;
  68238. /**
  68239. * Gets if the current filter is set to "close ESM" (using the inverse of the
  68240. * exponential to prevent steep falloff artifacts).
  68241. */
  68242. /**
  68243. * Sets the current filter to "close ESM" (using the inverse of the
  68244. * exponential to prevent steep falloff artifacts).
  68245. */
  68246. useCloseExponentialShadowMap: boolean;
  68247. /**
  68248. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  68249. * exponential to prevent steep falloff artifacts).
  68250. */
  68251. /**
  68252. * Sets the current filter to filtered "close ESM" (using the inverse of the
  68253. * exponential to prevent steep falloff artifacts).
  68254. */
  68255. useBlurCloseExponentialShadowMap: boolean;
  68256. /**
  68257. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  68258. */
  68259. /**
  68260. * Sets the current filter to "PCF" (percentage closer filtering).
  68261. */
  68262. usePercentageCloserFiltering: boolean;
  68263. private _filteringQuality;
  68264. /**
  68265. * Gets the PCF or PCSS Quality.
  68266. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  68267. */
  68268. /**
  68269. * Sets the PCF or PCSS Quality.
  68270. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  68271. */
  68272. filteringQuality: number;
  68273. /**
  68274. * Gets if the current filter is set to "PCSS" (contact hardening).
  68275. */
  68276. /**
  68277. * Sets the current filter to "PCSS" (contact hardening).
  68278. */
  68279. useContactHardeningShadow: boolean;
  68280. private _contactHardeningLightSizeUVRatio;
  68281. /**
  68282. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  68283. * Using a ratio helps keeping shape stability independently of the map size.
  68284. *
  68285. * It does not account for the light projection as it was having too much
  68286. * instability during the light setup or during light position changes.
  68287. *
  68288. * Only valid if useContactHardeningShadow is true.
  68289. */
  68290. /**
  68291. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  68292. * Using a ratio helps keeping shape stability independently of the map size.
  68293. *
  68294. * It does not account for the light projection as it was having too much
  68295. * instability during the light setup or during light position changes.
  68296. *
  68297. * Only valid if useContactHardeningShadow is true.
  68298. */
  68299. contactHardeningLightSizeUVRatio: number;
  68300. private _darkness;
  68301. /**
  68302. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  68303. * 0 means strongest and 1 would means no shadow.
  68304. * @returns the darkness.
  68305. */
  68306. getDarkness(): number;
  68307. /**
  68308. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  68309. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  68310. * @returns the shadow generator allowing fluent coding.
  68311. */
  68312. setDarkness(darkness: number): ShadowGenerator;
  68313. private _transparencyShadow;
  68314. /**
  68315. * Sets the ability to have transparent shadow (boolean).
  68316. * @param transparent True if transparent else False
  68317. * @returns the shadow generator allowing fluent coding
  68318. */
  68319. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  68320. private _shadowMap;
  68321. private _shadowMap2;
  68322. /**
  68323. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  68324. * @returns The render target texture if present otherwise, null
  68325. */
  68326. getShadowMap(): Nullable<RenderTargetTexture>;
  68327. /**
  68328. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  68329. * @returns The render target texture if the shadow map is present otherwise, null
  68330. */
  68331. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  68332. /**
  68333. * Helper function to add a mesh and its descendants to the list of shadow casters.
  68334. * @param mesh Mesh to add
  68335. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  68336. * @returns the Shadow Generator itself
  68337. */
  68338. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  68339. /**
  68340. * Helper function to remove a mesh and its descendants from the list of shadow casters
  68341. * @param mesh Mesh to remove
  68342. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  68343. * @returns the Shadow Generator itself
  68344. */
  68345. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  68346. /**
  68347. * Controls the extent to which the shadows fade out at the edge of the frustum
  68348. * Used only by directionals and spots
  68349. */
  68350. frustumEdgeFalloff: number;
  68351. private _light;
  68352. /**
  68353. * Returns the associated light object.
  68354. * @returns the light generating the shadow
  68355. */
  68356. getLight(): IShadowLight;
  68357. /**
  68358. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  68359. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  68360. * It might on the other hand introduce peter panning.
  68361. */
  68362. forceBackFacesOnly: boolean;
  68363. private _scene;
  68364. private _lightDirection;
  68365. private _effect;
  68366. private _viewMatrix;
  68367. private _projectionMatrix;
  68368. private _transformMatrix;
  68369. private _cachedPosition;
  68370. private _cachedDirection;
  68371. private _cachedDefines;
  68372. private _currentRenderID;
  68373. private _boxBlurPostprocess;
  68374. private _kernelBlurXPostprocess;
  68375. private _kernelBlurYPostprocess;
  68376. private _blurPostProcesses;
  68377. private _mapSize;
  68378. private _currentFaceIndex;
  68379. private _currentFaceIndexCache;
  68380. private _textureType;
  68381. private _defaultTextureMatrix;
  68382. /** @hidden */
  68383. static _SceneComponentInitialization: (scene: Scene) => void;
  68384. /**
  68385. * Creates a ShadowGenerator object.
  68386. * A ShadowGenerator is the required tool to use the shadows.
  68387. * Each light casting shadows needs to use its own ShadowGenerator.
  68388. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  68389. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  68390. * @param light The light object generating the shadows.
  68391. * @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.
  68392. */
  68393. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  68394. private _initializeGenerator;
  68395. private _initializeShadowMap;
  68396. private _initializeBlurRTTAndPostProcesses;
  68397. private _renderForShadowMap;
  68398. private _renderSubMeshForShadowMap;
  68399. private _applyFilterValues;
  68400. /**
  68401. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  68402. * @param onCompiled Callback triggered at the and of the effects compilation
  68403. * @param options Sets of optional options forcing the compilation with different modes
  68404. */
  68405. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  68406. useInstances: boolean;
  68407. }>): void;
  68408. /**
  68409. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  68410. * @param options Sets of optional options forcing the compilation with different modes
  68411. * @returns A promise that resolves when the compilation completes
  68412. */
  68413. forceCompilationAsync(options?: Partial<{
  68414. useInstances: boolean;
  68415. }>): Promise<void>;
  68416. /**
  68417. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  68418. * @param subMesh The submesh we want to render in the shadow map
  68419. * @param useInstances Defines wether will draw in the map using instances
  68420. * @returns true if ready otherwise, false
  68421. */
  68422. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68423. /**
  68424. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  68425. * @param defines Defines of the material we want to update
  68426. * @param lightIndex Index of the light in the enabled light list of the material
  68427. */
  68428. prepareDefines(defines: any, lightIndex: number): void;
  68429. /**
  68430. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  68431. * defined in the generator but impacting the effect).
  68432. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  68433. * @param effect The effect we are binfing the information for
  68434. */
  68435. bindShadowLight(lightIndex: string, effect: Effect): void;
  68436. /**
  68437. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  68438. * (eq to shadow prjection matrix * light transform matrix)
  68439. * @returns The transform matrix used to create the shadow map
  68440. */
  68441. getTransformMatrix(): Matrix;
  68442. /**
  68443. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  68444. * Cube and 2D textures for instance.
  68445. */
  68446. recreateShadowMap(): void;
  68447. private _disposeBlurPostProcesses;
  68448. private _disposeRTTandPostProcesses;
  68449. /**
  68450. * Disposes the ShadowGenerator.
  68451. * Returns nothing.
  68452. */
  68453. dispose(): void;
  68454. /**
  68455. * Serializes the shadow generator setup to a json object.
  68456. * @returns The serialized JSON object
  68457. */
  68458. serialize(): any;
  68459. /**
  68460. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  68461. * @param parsedShadowGenerator The JSON object to parse
  68462. * @param scene The scene to create the shadow map for
  68463. * @returns The parsed shadow generator
  68464. */
  68465. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  68466. }
  68467. }
  68468. declare module BABYLON {
  68469. /**
  68470. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  68471. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  68472. * 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.
  68473. */
  68474. export abstract class Light extends Node {
  68475. /**
  68476. * Falloff Default: light is falling off following the material specification:
  68477. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  68478. */
  68479. static readonly FALLOFF_DEFAULT: number;
  68480. /**
  68481. * Falloff Physical: light is falling off following the inverse squared distance law.
  68482. */
  68483. static readonly FALLOFF_PHYSICAL: number;
  68484. /**
  68485. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  68486. * to enhance interoperability with other engines.
  68487. */
  68488. static readonly FALLOFF_GLTF: number;
  68489. /**
  68490. * Falloff Standard: light is falling off like in the standard material
  68491. * to enhance interoperability with other materials.
  68492. */
  68493. static readonly FALLOFF_STANDARD: number;
  68494. /**
  68495. * If every light affecting the material is in this lightmapMode,
  68496. * material.lightmapTexture adds or multiplies
  68497. * (depends on material.useLightmapAsShadowmap)
  68498. * after every other light calculations.
  68499. */
  68500. static readonly LIGHTMAP_DEFAULT: number;
  68501. /**
  68502. * material.lightmapTexture as only diffuse lighting from this light
  68503. * adds only specular lighting from this light
  68504. * adds dynamic shadows
  68505. */
  68506. static readonly LIGHTMAP_SPECULAR: number;
  68507. /**
  68508. * material.lightmapTexture as only lighting
  68509. * no light calculation from this light
  68510. * only adds dynamic shadows from this light
  68511. */
  68512. static readonly LIGHTMAP_SHADOWSONLY: number;
  68513. /**
  68514. * Each light type uses the default quantity according to its type:
  68515. * point/spot lights use luminous intensity
  68516. * directional lights use illuminance
  68517. */
  68518. static readonly INTENSITYMODE_AUTOMATIC: number;
  68519. /**
  68520. * lumen (lm)
  68521. */
  68522. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  68523. /**
  68524. * candela (lm/sr)
  68525. */
  68526. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  68527. /**
  68528. * lux (lm/m^2)
  68529. */
  68530. static readonly INTENSITYMODE_ILLUMINANCE: number;
  68531. /**
  68532. * nit (cd/m^2)
  68533. */
  68534. static readonly INTENSITYMODE_LUMINANCE: number;
  68535. /**
  68536. * Light type const id of the point light.
  68537. */
  68538. static readonly LIGHTTYPEID_POINTLIGHT: number;
  68539. /**
  68540. * Light type const id of the directional light.
  68541. */
  68542. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  68543. /**
  68544. * Light type const id of the spot light.
  68545. */
  68546. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  68547. /**
  68548. * Light type const id of the hemispheric light.
  68549. */
  68550. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  68551. /**
  68552. * Diffuse gives the basic color to an object.
  68553. */
  68554. diffuse: Color3;
  68555. /**
  68556. * Specular produces a highlight color on an object.
  68557. * Note: This is note affecting PBR materials.
  68558. */
  68559. specular: Color3;
  68560. /**
  68561. * Defines the falloff type for this light. This lets overrriding how punctual light are
  68562. * falling off base on range or angle.
  68563. * This can be set to any values in Light.FALLOFF_x.
  68564. *
  68565. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  68566. * other types of materials.
  68567. */
  68568. falloffType: number;
  68569. /**
  68570. * Strength of the light.
  68571. * Note: By default it is define in the framework own unit.
  68572. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  68573. */
  68574. intensity: number;
  68575. private _range;
  68576. protected _inverseSquaredRange: number;
  68577. /**
  68578. * Defines how far from the source the light is impacting in scene units.
  68579. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  68580. */
  68581. /**
  68582. * Defines how far from the source the light is impacting in scene units.
  68583. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  68584. */
  68585. range: number;
  68586. /**
  68587. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  68588. * of light.
  68589. */
  68590. private _photometricScale;
  68591. private _intensityMode;
  68592. /**
  68593. * Gets the photometric scale used to interpret the intensity.
  68594. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  68595. */
  68596. /**
  68597. * Sets the photometric scale used to interpret the intensity.
  68598. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  68599. */
  68600. intensityMode: number;
  68601. private _radius;
  68602. /**
  68603. * Gets the light radius used by PBR Materials to simulate soft area lights.
  68604. */
  68605. /**
  68606. * sets the light radius used by PBR Materials to simulate soft area lights.
  68607. */
  68608. radius: number;
  68609. private _renderPriority;
  68610. /**
  68611. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  68612. * exceeding the number allowed of the materials.
  68613. */
  68614. renderPriority: number;
  68615. private _shadowEnabled;
  68616. /**
  68617. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  68618. * the current shadow generator.
  68619. */
  68620. /**
  68621. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  68622. * the current shadow generator.
  68623. */
  68624. shadowEnabled: boolean;
  68625. private _includedOnlyMeshes;
  68626. /**
  68627. * Gets the only meshes impacted by this light.
  68628. */
  68629. /**
  68630. * Sets the only meshes impacted by this light.
  68631. */
  68632. includedOnlyMeshes: AbstractMesh[];
  68633. private _excludedMeshes;
  68634. /**
  68635. * Gets the meshes not impacted by this light.
  68636. */
  68637. /**
  68638. * Sets the meshes not impacted by this light.
  68639. */
  68640. excludedMeshes: AbstractMesh[];
  68641. private _excludeWithLayerMask;
  68642. /**
  68643. * Gets the layer id use to find what meshes are not impacted by the light.
  68644. * Inactive if 0
  68645. */
  68646. /**
  68647. * Sets the layer id use to find what meshes are not impacted by the light.
  68648. * Inactive if 0
  68649. */
  68650. excludeWithLayerMask: number;
  68651. private _includeOnlyWithLayerMask;
  68652. /**
  68653. * Gets the layer id use to find what meshes are impacted by the light.
  68654. * Inactive if 0
  68655. */
  68656. /**
  68657. * Sets the layer id use to find what meshes are impacted by the light.
  68658. * Inactive if 0
  68659. */
  68660. includeOnlyWithLayerMask: number;
  68661. private _lightmapMode;
  68662. /**
  68663. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  68664. */
  68665. /**
  68666. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  68667. */
  68668. lightmapMode: number;
  68669. /**
  68670. * Shadow generator associted to the light.
  68671. * @hidden Internal use only.
  68672. */
  68673. _shadowGenerator: Nullable<IShadowGenerator>;
  68674. /**
  68675. * @hidden Internal use only.
  68676. */
  68677. _excludedMeshesIds: string[];
  68678. /**
  68679. * @hidden Internal use only.
  68680. */
  68681. _includedOnlyMeshesIds: string[];
  68682. /**
  68683. * The current light unifom buffer.
  68684. * @hidden Internal use only.
  68685. */
  68686. _uniformBuffer: UniformBuffer;
  68687. /**
  68688. * Creates a Light object in the scene.
  68689. * Documentation : https://doc.babylonjs.com/babylon101/lights
  68690. * @param name The firendly name of the light
  68691. * @param scene The scene the light belongs too
  68692. */
  68693. constructor(name: string, scene: Scene);
  68694. protected abstract _buildUniformLayout(): void;
  68695. /**
  68696. * Sets the passed Effect "effect" with the Light information.
  68697. * @param effect The effect to update
  68698. * @param lightIndex The index of the light in the effect to update
  68699. * @returns The light
  68700. */
  68701. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  68702. /**
  68703. * Returns the string "Light".
  68704. * @returns the class name
  68705. */
  68706. getClassName(): string;
  68707. /** @hidden */
  68708. readonly _isLight: boolean;
  68709. /**
  68710. * Converts the light information to a readable string for debug purpose.
  68711. * @param fullDetails Supports for multiple levels of logging within scene loading
  68712. * @returns the human readable light info
  68713. */
  68714. toString(fullDetails?: boolean): string;
  68715. /** @hidden */
  68716. protected _syncParentEnabledState(): void;
  68717. /**
  68718. * Set the enabled state of this node.
  68719. * @param value - the new enabled state
  68720. */
  68721. setEnabled(value: boolean): void;
  68722. /**
  68723. * Returns the Light associated shadow generator if any.
  68724. * @return the associated shadow generator.
  68725. */
  68726. getShadowGenerator(): Nullable<IShadowGenerator>;
  68727. /**
  68728. * Returns a Vector3, the absolute light position in the World.
  68729. * @returns the world space position of the light
  68730. */
  68731. getAbsolutePosition(): Vector3;
  68732. /**
  68733. * Specifies if the light will affect the passed mesh.
  68734. * @param mesh The mesh to test against the light
  68735. * @return true the mesh is affected otherwise, false.
  68736. */
  68737. canAffectMesh(mesh: AbstractMesh): boolean;
  68738. /**
  68739. * Sort function to order lights for rendering.
  68740. * @param a First Light object to compare to second.
  68741. * @param b Second Light object to compare first.
  68742. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  68743. */
  68744. static CompareLightsPriority(a: Light, b: Light): number;
  68745. /**
  68746. * Releases resources associated with this node.
  68747. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  68748. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  68749. */
  68750. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  68751. /**
  68752. * Returns the light type ID (integer).
  68753. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  68754. */
  68755. getTypeID(): number;
  68756. /**
  68757. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  68758. * @returns the scaled intensity in intensity mode unit
  68759. */
  68760. getScaledIntensity(): number;
  68761. /**
  68762. * Returns a new Light object, named "name", from the current one.
  68763. * @param name The name of the cloned light
  68764. * @returns the new created light
  68765. */
  68766. clone(name: string): Nullable<Light>;
  68767. /**
  68768. * Serializes the current light into a Serialization object.
  68769. * @returns the serialized object.
  68770. */
  68771. serialize(): any;
  68772. /**
  68773. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  68774. * This new light is named "name" and added to the passed scene.
  68775. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  68776. * @param name The friendly name of the light
  68777. * @param scene The scene the new light will belong to
  68778. * @returns the constructor function
  68779. */
  68780. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  68781. /**
  68782. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  68783. * @param parsedLight The JSON representation of the light
  68784. * @param scene The scene to create the parsed light in
  68785. * @returns the created light after parsing
  68786. */
  68787. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  68788. private _hookArrayForExcluded;
  68789. private _hookArrayForIncludedOnly;
  68790. private _resyncMeshes;
  68791. /**
  68792. * Forces the meshes to update their light related information in their rendering used effects
  68793. * @hidden Internal Use Only
  68794. */
  68795. _markMeshesAsLightDirty(): void;
  68796. /**
  68797. * Recomputes the cached photometric scale if needed.
  68798. */
  68799. private _computePhotometricScale;
  68800. /**
  68801. * Returns the Photometric Scale according to the light type and intensity mode.
  68802. */
  68803. private _getPhotometricScale;
  68804. /**
  68805. * Reorder the light in the scene according to their defined priority.
  68806. * @hidden Internal Use Only
  68807. */
  68808. _reorderLightsInScene(): void;
  68809. /**
  68810. * Prepares the list of defines specific to the light type.
  68811. * @param defines the list of defines
  68812. * @param lightIndex defines the index of the light for the effect
  68813. */
  68814. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  68815. }
  68816. }
  68817. declare module BABYLON {
  68818. /**
  68819. * Interface used to define Action
  68820. */
  68821. export interface IAction {
  68822. /**
  68823. * Trigger for the action
  68824. */
  68825. trigger: number;
  68826. /** Options of the trigger */
  68827. triggerOptions: any;
  68828. /**
  68829. * Gets the trigger parameters
  68830. * @returns the trigger parameters
  68831. */
  68832. getTriggerParameter(): any;
  68833. /**
  68834. * Internal only - executes current action event
  68835. * @hidden
  68836. */
  68837. _executeCurrent(evt?: ActionEvent): void;
  68838. /**
  68839. * Serialize placeholder for child classes
  68840. * @param parent of child
  68841. * @returns the serialized object
  68842. */
  68843. serialize(parent: any): any;
  68844. /**
  68845. * Internal only
  68846. * @hidden
  68847. */
  68848. _prepare(): void;
  68849. /**
  68850. * Internal only - manager for action
  68851. * @hidden
  68852. */
  68853. _actionManager: AbstractActionManager;
  68854. }
  68855. /**
  68856. * The action to be carried out following a trigger
  68857. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  68858. */
  68859. export class Action implements IAction {
  68860. /** the trigger, with or without parameters, for the action */
  68861. triggerOptions: any;
  68862. /**
  68863. * Trigger for the action
  68864. */
  68865. trigger: number;
  68866. /**
  68867. * Internal only - manager for action
  68868. * @hidden
  68869. */
  68870. _actionManager: ActionManager;
  68871. private _nextActiveAction;
  68872. private _child;
  68873. private _condition?;
  68874. private _triggerParameter;
  68875. /**
  68876. * An event triggered prior to action being executed.
  68877. */
  68878. onBeforeExecuteObservable: Observable<Action>;
  68879. /**
  68880. * Creates a new Action
  68881. * @param triggerOptions the trigger, with or without parameters, for the action
  68882. * @param condition an optional determinant of action
  68883. */
  68884. constructor(
  68885. /** the trigger, with or without parameters, for the action */
  68886. triggerOptions: any, condition?: Condition);
  68887. /**
  68888. * Internal only
  68889. * @hidden
  68890. */
  68891. _prepare(): void;
  68892. /**
  68893. * Gets the trigger parameters
  68894. * @returns the trigger parameters
  68895. */
  68896. getTriggerParameter(): any;
  68897. /**
  68898. * Internal only - executes current action event
  68899. * @hidden
  68900. */
  68901. _executeCurrent(evt?: ActionEvent): void;
  68902. /**
  68903. * Execute placeholder for child classes
  68904. * @param evt optional action event
  68905. */
  68906. execute(evt?: ActionEvent): void;
  68907. /**
  68908. * Skips to next active action
  68909. */
  68910. skipToNextActiveAction(): void;
  68911. /**
  68912. * Adds action to chain of actions, may be a DoNothingAction
  68913. * @param action defines the next action to execute
  68914. * @returns The action passed in
  68915. * @see https://www.babylonjs-playground.com/#1T30HR#0
  68916. */
  68917. then(action: Action): Action;
  68918. /**
  68919. * Internal only
  68920. * @hidden
  68921. */
  68922. _getProperty(propertyPath: string): string;
  68923. /**
  68924. * Internal only
  68925. * @hidden
  68926. */
  68927. _getEffectiveTarget(target: any, propertyPath: string): any;
  68928. /**
  68929. * Serialize placeholder for child classes
  68930. * @param parent of child
  68931. * @returns the serialized object
  68932. */
  68933. serialize(parent: any): any;
  68934. /**
  68935. * Internal only called by serialize
  68936. * @hidden
  68937. */
  68938. protected _serialize(serializedAction: any, parent?: any): any;
  68939. /**
  68940. * Internal only
  68941. * @hidden
  68942. */
  68943. static _SerializeValueAsString: (value: any) => string;
  68944. /**
  68945. * Internal only
  68946. * @hidden
  68947. */
  68948. static _GetTargetProperty: (target: Scene | Node) => {
  68949. name: string;
  68950. targetType: string;
  68951. value: string;
  68952. };
  68953. }
  68954. }
  68955. declare module BABYLON {
  68956. /**
  68957. * A Condition applied to an Action
  68958. */
  68959. export class Condition {
  68960. /**
  68961. * Internal only - manager for action
  68962. * @hidden
  68963. */
  68964. _actionManager: ActionManager;
  68965. /**
  68966. * Internal only
  68967. * @hidden
  68968. */
  68969. _evaluationId: number;
  68970. /**
  68971. * Internal only
  68972. * @hidden
  68973. */
  68974. _currentResult: boolean;
  68975. /**
  68976. * Creates a new Condition
  68977. * @param actionManager the manager of the action the condition is applied to
  68978. */
  68979. constructor(actionManager: ActionManager);
  68980. /**
  68981. * Check if the current condition is valid
  68982. * @returns a boolean
  68983. */
  68984. isValid(): boolean;
  68985. /**
  68986. * Internal only
  68987. * @hidden
  68988. */
  68989. _getProperty(propertyPath: string): string;
  68990. /**
  68991. * Internal only
  68992. * @hidden
  68993. */
  68994. _getEffectiveTarget(target: any, propertyPath: string): any;
  68995. /**
  68996. * Serialize placeholder for child classes
  68997. * @returns the serialized object
  68998. */
  68999. serialize(): any;
  69000. /**
  69001. * Internal only
  69002. * @hidden
  69003. */
  69004. protected _serialize(serializedCondition: any): any;
  69005. }
  69006. /**
  69007. * Defines specific conditional operators as extensions of Condition
  69008. */
  69009. export class ValueCondition extends Condition {
  69010. /** path to specify the property of the target the conditional operator uses */
  69011. propertyPath: string;
  69012. /** the value compared by the conditional operator against the current value of the property */
  69013. value: any;
  69014. /** the conditional operator, default ValueCondition.IsEqual */
  69015. operator: number;
  69016. /**
  69017. * Internal only
  69018. * @hidden
  69019. */
  69020. private static _IsEqual;
  69021. /**
  69022. * Internal only
  69023. * @hidden
  69024. */
  69025. private static _IsDifferent;
  69026. /**
  69027. * Internal only
  69028. * @hidden
  69029. */
  69030. private static _IsGreater;
  69031. /**
  69032. * Internal only
  69033. * @hidden
  69034. */
  69035. private static _IsLesser;
  69036. /**
  69037. * returns the number for IsEqual
  69038. */
  69039. static readonly IsEqual: number;
  69040. /**
  69041. * Returns the number for IsDifferent
  69042. */
  69043. static readonly IsDifferent: number;
  69044. /**
  69045. * Returns the number for IsGreater
  69046. */
  69047. static readonly IsGreater: number;
  69048. /**
  69049. * Returns the number for IsLesser
  69050. */
  69051. static readonly IsLesser: number;
  69052. /**
  69053. * Internal only The action manager for the condition
  69054. * @hidden
  69055. */
  69056. _actionManager: ActionManager;
  69057. /**
  69058. * Internal only
  69059. * @hidden
  69060. */
  69061. private _target;
  69062. /**
  69063. * Internal only
  69064. * @hidden
  69065. */
  69066. private _effectiveTarget;
  69067. /**
  69068. * Internal only
  69069. * @hidden
  69070. */
  69071. private _property;
  69072. /**
  69073. * Creates a new ValueCondition
  69074. * @param actionManager manager for the action the condition applies to
  69075. * @param target for the action
  69076. * @param propertyPath path to specify the property of the target the conditional operator uses
  69077. * @param value the value compared by the conditional operator against the current value of the property
  69078. * @param operator the conditional operator, default ValueCondition.IsEqual
  69079. */
  69080. constructor(actionManager: ActionManager, target: any,
  69081. /** path to specify the property of the target the conditional operator uses */
  69082. propertyPath: string,
  69083. /** the value compared by the conditional operator against the current value of the property */
  69084. value: any,
  69085. /** the conditional operator, default ValueCondition.IsEqual */
  69086. operator?: number);
  69087. /**
  69088. * Compares the given value with the property value for the specified conditional operator
  69089. * @returns the result of the comparison
  69090. */
  69091. isValid(): boolean;
  69092. /**
  69093. * Serialize the ValueCondition into a JSON compatible object
  69094. * @returns serialization object
  69095. */
  69096. serialize(): any;
  69097. /**
  69098. * Gets the name of the conditional operator for the ValueCondition
  69099. * @param operator the conditional operator
  69100. * @returns the name
  69101. */
  69102. static GetOperatorName(operator: number): string;
  69103. }
  69104. /**
  69105. * Defines a predicate condition as an extension of Condition
  69106. */
  69107. export class PredicateCondition extends Condition {
  69108. /** defines the predicate function used to validate the condition */
  69109. predicate: () => boolean;
  69110. /**
  69111. * Internal only - manager for action
  69112. * @hidden
  69113. */
  69114. _actionManager: ActionManager;
  69115. /**
  69116. * Creates a new PredicateCondition
  69117. * @param actionManager manager for the action the condition applies to
  69118. * @param predicate defines the predicate function used to validate the condition
  69119. */
  69120. constructor(actionManager: ActionManager,
  69121. /** defines the predicate function used to validate the condition */
  69122. predicate: () => boolean);
  69123. /**
  69124. * @returns the validity of the predicate condition
  69125. */
  69126. isValid(): boolean;
  69127. }
  69128. /**
  69129. * Defines a state condition as an extension of Condition
  69130. */
  69131. export class StateCondition extends Condition {
  69132. /** Value to compare with target state */
  69133. value: string;
  69134. /**
  69135. * Internal only - manager for action
  69136. * @hidden
  69137. */
  69138. _actionManager: ActionManager;
  69139. /**
  69140. * Internal only
  69141. * @hidden
  69142. */
  69143. private _target;
  69144. /**
  69145. * Creates a new StateCondition
  69146. * @param actionManager manager for the action the condition applies to
  69147. * @param target of the condition
  69148. * @param value to compare with target state
  69149. */
  69150. constructor(actionManager: ActionManager, target: any,
  69151. /** Value to compare with target state */
  69152. value: string);
  69153. /**
  69154. * Gets a boolean indicating if the current condition is met
  69155. * @returns the validity of the state
  69156. */
  69157. isValid(): boolean;
  69158. /**
  69159. * Serialize the StateCondition into a JSON compatible object
  69160. * @returns serialization object
  69161. */
  69162. serialize(): any;
  69163. }
  69164. }
  69165. declare module BABYLON {
  69166. /**
  69167. * This defines an action responsible to toggle a boolean once triggered.
  69168. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69169. */
  69170. export class SwitchBooleanAction extends Action {
  69171. /**
  69172. * The path to the boolean property in the target object
  69173. */
  69174. propertyPath: string;
  69175. private _target;
  69176. private _effectiveTarget;
  69177. private _property;
  69178. /**
  69179. * Instantiate the action
  69180. * @param triggerOptions defines the trigger options
  69181. * @param target defines the object containing the boolean
  69182. * @param propertyPath defines the path to the boolean property in the target object
  69183. * @param condition defines the trigger related conditions
  69184. */
  69185. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  69186. /** @hidden */
  69187. _prepare(): void;
  69188. /**
  69189. * Execute the action toggle the boolean value.
  69190. */
  69191. execute(): void;
  69192. /**
  69193. * Serializes the actions and its related information.
  69194. * @param parent defines the object to serialize in
  69195. * @returns the serialized object
  69196. */
  69197. serialize(parent: any): any;
  69198. }
  69199. /**
  69200. * This defines an action responsible to set a the state field of the target
  69201. * to a desired value once triggered.
  69202. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69203. */
  69204. export class SetStateAction extends Action {
  69205. /**
  69206. * The value to store in the state field.
  69207. */
  69208. value: string;
  69209. private _target;
  69210. /**
  69211. * Instantiate the action
  69212. * @param triggerOptions defines the trigger options
  69213. * @param target defines the object containing the state property
  69214. * @param value defines the value to store in the state field
  69215. * @param condition defines the trigger related conditions
  69216. */
  69217. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  69218. /**
  69219. * Execute the action and store the value on the target state property.
  69220. */
  69221. execute(): void;
  69222. /**
  69223. * Serializes the actions and its related information.
  69224. * @param parent defines the object to serialize in
  69225. * @returns the serialized object
  69226. */
  69227. serialize(parent: any): any;
  69228. }
  69229. /**
  69230. * This defines an action responsible to set a property of the target
  69231. * to a desired value once triggered.
  69232. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69233. */
  69234. export class SetValueAction extends Action {
  69235. /**
  69236. * The path of the property to set in the target.
  69237. */
  69238. propertyPath: string;
  69239. /**
  69240. * The value to set in the property
  69241. */
  69242. value: any;
  69243. private _target;
  69244. private _effectiveTarget;
  69245. private _property;
  69246. /**
  69247. * Instantiate the action
  69248. * @param triggerOptions defines the trigger options
  69249. * @param target defines the object containing the property
  69250. * @param propertyPath defines the path of the property to set in the target
  69251. * @param value defines the value to set in the property
  69252. * @param condition defines the trigger related conditions
  69253. */
  69254. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  69255. /** @hidden */
  69256. _prepare(): void;
  69257. /**
  69258. * Execute the action and set the targetted property to the desired value.
  69259. */
  69260. execute(): void;
  69261. /**
  69262. * Serializes the actions and its related information.
  69263. * @param parent defines the object to serialize in
  69264. * @returns the serialized object
  69265. */
  69266. serialize(parent: any): any;
  69267. }
  69268. /**
  69269. * This defines an action responsible to increment the target value
  69270. * to a desired value once triggered.
  69271. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69272. */
  69273. export class IncrementValueAction extends Action {
  69274. /**
  69275. * The path of the property to increment in the target.
  69276. */
  69277. propertyPath: string;
  69278. /**
  69279. * The value we should increment the property by.
  69280. */
  69281. value: any;
  69282. private _target;
  69283. private _effectiveTarget;
  69284. private _property;
  69285. /**
  69286. * Instantiate the action
  69287. * @param triggerOptions defines the trigger options
  69288. * @param target defines the object containing the property
  69289. * @param propertyPath defines the path of the property to increment in the target
  69290. * @param value defines the value value we should increment the property by
  69291. * @param condition defines the trigger related conditions
  69292. */
  69293. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  69294. /** @hidden */
  69295. _prepare(): void;
  69296. /**
  69297. * Execute the action and increment the target of the value amount.
  69298. */
  69299. execute(): void;
  69300. /**
  69301. * Serializes the actions and its related information.
  69302. * @param parent defines the object to serialize in
  69303. * @returns the serialized object
  69304. */
  69305. serialize(parent: any): any;
  69306. }
  69307. /**
  69308. * This defines an action responsible to start an animation once triggered.
  69309. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69310. */
  69311. export class PlayAnimationAction extends Action {
  69312. /**
  69313. * Where the animation should start (animation frame)
  69314. */
  69315. from: number;
  69316. /**
  69317. * Where the animation should stop (animation frame)
  69318. */
  69319. to: number;
  69320. /**
  69321. * Define if the animation should loop or stop after the first play.
  69322. */
  69323. loop?: boolean;
  69324. private _target;
  69325. /**
  69326. * Instantiate the action
  69327. * @param triggerOptions defines the trigger options
  69328. * @param target defines the target animation or animation name
  69329. * @param from defines from where the animation should start (animation frame)
  69330. * @param end defines where the animation should stop (animation frame)
  69331. * @param loop defines if the animation should loop or stop after the first play
  69332. * @param condition defines the trigger related conditions
  69333. */
  69334. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  69335. /** @hidden */
  69336. _prepare(): void;
  69337. /**
  69338. * Execute the action and play the animation.
  69339. */
  69340. execute(): void;
  69341. /**
  69342. * Serializes the actions and its related information.
  69343. * @param parent defines the object to serialize in
  69344. * @returns the serialized object
  69345. */
  69346. serialize(parent: any): any;
  69347. }
  69348. /**
  69349. * This defines an action responsible to stop an animation once triggered.
  69350. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69351. */
  69352. export class StopAnimationAction extends Action {
  69353. private _target;
  69354. /**
  69355. * Instantiate the action
  69356. * @param triggerOptions defines the trigger options
  69357. * @param target defines the target animation or animation name
  69358. * @param condition defines the trigger related conditions
  69359. */
  69360. constructor(triggerOptions: any, target: any, condition?: Condition);
  69361. /** @hidden */
  69362. _prepare(): void;
  69363. /**
  69364. * Execute the action and stop the animation.
  69365. */
  69366. execute(): void;
  69367. /**
  69368. * Serializes the actions and its related information.
  69369. * @param parent defines the object to serialize in
  69370. * @returns the serialized object
  69371. */
  69372. serialize(parent: any): any;
  69373. }
  69374. /**
  69375. * This defines an action responsible that does nothing once triggered.
  69376. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69377. */
  69378. export class DoNothingAction extends Action {
  69379. /**
  69380. * Instantiate the action
  69381. * @param triggerOptions defines the trigger options
  69382. * @param condition defines the trigger related conditions
  69383. */
  69384. constructor(triggerOptions?: any, condition?: Condition);
  69385. /**
  69386. * Execute the action and do nothing.
  69387. */
  69388. execute(): void;
  69389. /**
  69390. * Serializes the actions and its related information.
  69391. * @param parent defines the object to serialize in
  69392. * @returns the serialized object
  69393. */
  69394. serialize(parent: any): any;
  69395. }
  69396. /**
  69397. * This defines an action responsible to trigger several actions once triggered.
  69398. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69399. */
  69400. export class CombineAction extends Action {
  69401. /**
  69402. * The list of aggregated animations to run.
  69403. */
  69404. children: Action[];
  69405. /**
  69406. * Instantiate the action
  69407. * @param triggerOptions defines the trigger options
  69408. * @param children defines the list of aggregated animations to run
  69409. * @param condition defines the trigger related conditions
  69410. */
  69411. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  69412. /** @hidden */
  69413. _prepare(): void;
  69414. /**
  69415. * Execute the action and executes all the aggregated actions.
  69416. */
  69417. execute(evt: ActionEvent): void;
  69418. /**
  69419. * Serializes the actions and its related information.
  69420. * @param parent defines the object to serialize in
  69421. * @returns the serialized object
  69422. */
  69423. serialize(parent: any): any;
  69424. }
  69425. /**
  69426. * This defines an action responsible to run code (external event) once triggered.
  69427. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69428. */
  69429. export class ExecuteCodeAction extends Action {
  69430. /**
  69431. * The callback function to run.
  69432. */
  69433. func: (evt: ActionEvent) => void;
  69434. /**
  69435. * Instantiate the action
  69436. * @param triggerOptions defines the trigger options
  69437. * @param func defines the callback function to run
  69438. * @param condition defines the trigger related conditions
  69439. */
  69440. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  69441. /**
  69442. * Execute the action and run the attached code.
  69443. */
  69444. execute(evt: ActionEvent): void;
  69445. }
  69446. /**
  69447. * This defines an action responsible to set the parent property of the target once triggered.
  69448. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69449. */
  69450. export class SetParentAction extends Action {
  69451. private _parent;
  69452. private _target;
  69453. /**
  69454. * Instantiate the action
  69455. * @param triggerOptions defines the trigger options
  69456. * @param target defines the target containing the parent property
  69457. * @param parent defines from where the animation should start (animation frame)
  69458. * @param condition defines the trigger related conditions
  69459. */
  69460. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  69461. /** @hidden */
  69462. _prepare(): void;
  69463. /**
  69464. * Execute the action and set the parent property.
  69465. */
  69466. execute(): void;
  69467. /**
  69468. * Serializes the actions and its related information.
  69469. * @param parent defines the object to serialize in
  69470. * @returns the serialized object
  69471. */
  69472. serialize(parent: any): any;
  69473. }
  69474. }
  69475. declare module BABYLON {
  69476. /**
  69477. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  69478. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  69479. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69480. */
  69481. export class ActionManager extends AbstractActionManager {
  69482. /**
  69483. * Nothing
  69484. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69485. */
  69486. static readonly NothingTrigger: number;
  69487. /**
  69488. * On pick
  69489. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69490. */
  69491. static readonly OnPickTrigger: number;
  69492. /**
  69493. * On left pick
  69494. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69495. */
  69496. static readonly OnLeftPickTrigger: number;
  69497. /**
  69498. * On right pick
  69499. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69500. */
  69501. static readonly OnRightPickTrigger: number;
  69502. /**
  69503. * On center pick
  69504. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69505. */
  69506. static readonly OnCenterPickTrigger: number;
  69507. /**
  69508. * On pick down
  69509. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69510. */
  69511. static readonly OnPickDownTrigger: number;
  69512. /**
  69513. * On double pick
  69514. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69515. */
  69516. static readonly OnDoublePickTrigger: number;
  69517. /**
  69518. * On pick up
  69519. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69520. */
  69521. static readonly OnPickUpTrigger: number;
  69522. /**
  69523. * On pick out.
  69524. * This trigger will only be raised if you also declared a OnPickDown
  69525. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69526. */
  69527. static readonly OnPickOutTrigger: number;
  69528. /**
  69529. * On long press
  69530. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69531. */
  69532. static readonly OnLongPressTrigger: number;
  69533. /**
  69534. * On pointer over
  69535. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69536. */
  69537. static readonly OnPointerOverTrigger: number;
  69538. /**
  69539. * On pointer out
  69540. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69541. */
  69542. static readonly OnPointerOutTrigger: number;
  69543. /**
  69544. * On every frame
  69545. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69546. */
  69547. static readonly OnEveryFrameTrigger: number;
  69548. /**
  69549. * On intersection enter
  69550. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69551. */
  69552. static readonly OnIntersectionEnterTrigger: number;
  69553. /**
  69554. * On intersection exit
  69555. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69556. */
  69557. static readonly OnIntersectionExitTrigger: number;
  69558. /**
  69559. * On key down
  69560. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69561. */
  69562. static readonly OnKeyDownTrigger: number;
  69563. /**
  69564. * On key up
  69565. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69566. */
  69567. static readonly OnKeyUpTrigger: number;
  69568. private _scene;
  69569. /**
  69570. * Creates a new action manager
  69571. * @param scene defines the hosting scene
  69572. */
  69573. constructor(scene: Scene);
  69574. /**
  69575. * Releases all associated resources
  69576. */
  69577. dispose(): void;
  69578. /**
  69579. * Gets hosting scene
  69580. * @returns the hosting scene
  69581. */
  69582. getScene(): Scene;
  69583. /**
  69584. * Does this action manager handles actions of any of the given triggers
  69585. * @param triggers defines the triggers to be tested
  69586. * @return a boolean indicating whether one (or more) of the triggers is handled
  69587. */
  69588. hasSpecificTriggers(triggers: number[]): boolean;
  69589. /**
  69590. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  69591. * speed.
  69592. * @param triggerA defines the trigger to be tested
  69593. * @param triggerB defines the trigger to be tested
  69594. * @return a boolean indicating whether one (or more) of the triggers is handled
  69595. */
  69596. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  69597. /**
  69598. * Does this action manager handles actions of a given trigger
  69599. * @param trigger defines the trigger to be tested
  69600. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  69601. * @return whether the trigger is handled
  69602. */
  69603. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  69604. /**
  69605. * Does this action manager has pointer triggers
  69606. */
  69607. readonly hasPointerTriggers: boolean;
  69608. /**
  69609. * Does this action manager has pick triggers
  69610. */
  69611. readonly hasPickTriggers: boolean;
  69612. /**
  69613. * Registers an action to this action manager
  69614. * @param action defines the action to be registered
  69615. * @return the action amended (prepared) after registration
  69616. */
  69617. registerAction(action: IAction): Nullable<IAction>;
  69618. /**
  69619. * Unregisters an action to this action manager
  69620. * @param action defines the action to be unregistered
  69621. * @return a boolean indicating whether the action has been unregistered
  69622. */
  69623. unregisterAction(action: IAction): Boolean;
  69624. /**
  69625. * Process a specific trigger
  69626. * @param trigger defines the trigger to process
  69627. * @param evt defines the event details to be processed
  69628. */
  69629. processTrigger(trigger: number, evt?: IActionEvent): void;
  69630. /** @hidden */
  69631. _getEffectiveTarget(target: any, propertyPath: string): any;
  69632. /** @hidden */
  69633. _getProperty(propertyPath: string): string;
  69634. /**
  69635. * Serialize this manager to a JSON object
  69636. * @param name defines the property name to store this manager
  69637. * @returns a JSON representation of this manager
  69638. */
  69639. serialize(name: string): any;
  69640. /**
  69641. * Creates a new ActionManager from a JSON data
  69642. * @param parsedActions defines the JSON data to read from
  69643. * @param object defines the hosting mesh
  69644. * @param scene defines the hosting scene
  69645. */
  69646. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  69647. /**
  69648. * Get a trigger name by index
  69649. * @param trigger defines the trigger index
  69650. * @returns a trigger name
  69651. */
  69652. static GetTriggerName(trigger: number): string;
  69653. }
  69654. }
  69655. declare module BABYLON {
  69656. /**
  69657. * Class representing a ray with position and direction
  69658. */
  69659. export class Ray {
  69660. /** origin point */
  69661. origin: Vector3;
  69662. /** direction */
  69663. direction: Vector3;
  69664. /** length of the ray */
  69665. length: number;
  69666. private static readonly TmpVector3;
  69667. private _tmpRay;
  69668. /**
  69669. * Creates a new ray
  69670. * @param origin origin point
  69671. * @param direction direction
  69672. * @param length length of the ray
  69673. */
  69674. constructor(
  69675. /** origin point */
  69676. origin: Vector3,
  69677. /** direction */
  69678. direction: Vector3,
  69679. /** length of the ray */
  69680. length?: number);
  69681. /**
  69682. * Checks if the ray intersects a box
  69683. * @param minimum bound of the box
  69684. * @param maximum bound of the box
  69685. * @param intersectionTreshold extra extend to be added to the box in all direction
  69686. * @returns if the box was hit
  69687. */
  69688. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  69689. /**
  69690. * Checks if the ray intersects a box
  69691. * @param box the bounding box to check
  69692. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  69693. * @returns if the box was hit
  69694. */
  69695. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  69696. /**
  69697. * If the ray hits a sphere
  69698. * @param sphere the bounding sphere to check
  69699. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  69700. * @returns true if it hits the sphere
  69701. */
  69702. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  69703. /**
  69704. * If the ray hits a triange
  69705. * @param vertex0 triangle vertex
  69706. * @param vertex1 triangle vertex
  69707. * @param vertex2 triangle vertex
  69708. * @returns intersection information if hit
  69709. */
  69710. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  69711. /**
  69712. * Checks if ray intersects a plane
  69713. * @param plane the plane to check
  69714. * @returns the distance away it was hit
  69715. */
  69716. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  69717. /**
  69718. * Checks if ray intersects a mesh
  69719. * @param mesh the mesh to check
  69720. * @param fastCheck if only the bounding box should checked
  69721. * @returns picking info of the intersecton
  69722. */
  69723. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  69724. /**
  69725. * Checks if ray intersects a mesh
  69726. * @param meshes the meshes to check
  69727. * @param fastCheck if only the bounding box should checked
  69728. * @param results array to store result in
  69729. * @returns Array of picking infos
  69730. */
  69731. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  69732. private _comparePickingInfo;
  69733. private static smallnum;
  69734. private static rayl;
  69735. /**
  69736. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  69737. * @param sega the first point of the segment to test the intersection against
  69738. * @param segb the second point of the segment to test the intersection against
  69739. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  69740. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  69741. */
  69742. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  69743. /**
  69744. * Update the ray from viewport position
  69745. * @param x position
  69746. * @param y y position
  69747. * @param viewportWidth viewport width
  69748. * @param viewportHeight viewport height
  69749. * @param world world matrix
  69750. * @param view view matrix
  69751. * @param projection projection matrix
  69752. * @returns this ray updated
  69753. */
  69754. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  69755. /**
  69756. * Creates a ray with origin and direction of 0,0,0
  69757. * @returns the new ray
  69758. */
  69759. static Zero(): Ray;
  69760. /**
  69761. * Creates a new ray from screen space and viewport
  69762. * @param x position
  69763. * @param y y position
  69764. * @param viewportWidth viewport width
  69765. * @param viewportHeight viewport height
  69766. * @param world world matrix
  69767. * @param view view matrix
  69768. * @param projection projection matrix
  69769. * @returns new ray
  69770. */
  69771. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  69772. /**
  69773. * 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
  69774. * transformed to the given world matrix.
  69775. * @param origin The origin point
  69776. * @param end The end point
  69777. * @param world a matrix to transform the ray to. Default is the identity matrix.
  69778. * @returns the new ray
  69779. */
  69780. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  69781. /**
  69782. * Transforms a ray by a matrix
  69783. * @param ray ray to transform
  69784. * @param matrix matrix to apply
  69785. * @returns the resulting new ray
  69786. */
  69787. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  69788. /**
  69789. * Transforms a ray by a matrix
  69790. * @param ray ray to transform
  69791. * @param matrix matrix to apply
  69792. * @param result ray to store result in
  69793. */
  69794. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  69795. /**
  69796. * Unproject a ray from screen space to object space
  69797. * @param sourceX defines the screen space x coordinate to use
  69798. * @param sourceY defines the screen space y coordinate to use
  69799. * @param viewportWidth defines the current width of the viewport
  69800. * @param viewportHeight defines the current height of the viewport
  69801. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69802. * @param view defines the view matrix to use
  69803. * @param projection defines the projection matrix to use
  69804. */
  69805. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  69806. }
  69807. /**
  69808. * Type used to define predicate used to select faces when a mesh intersection is detected
  69809. */
  69810. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  69811. interface Scene {
  69812. /** @hidden */
  69813. _tempPickingRay: Nullable<Ray>;
  69814. /** @hidden */
  69815. _cachedRayForTransform: Ray;
  69816. /** @hidden */
  69817. _pickWithRayInverseMatrix: Matrix;
  69818. /** @hidden */
  69819. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  69820. /** @hidden */
  69821. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  69822. }
  69823. }
  69824. declare module BABYLON {
  69825. /**
  69826. * Groups all the scene component constants in one place to ease maintenance.
  69827. * @hidden
  69828. */
  69829. export class SceneComponentConstants {
  69830. static readonly NAME_EFFECTLAYER: string;
  69831. static readonly NAME_LAYER: string;
  69832. static readonly NAME_LENSFLARESYSTEM: string;
  69833. static readonly NAME_BOUNDINGBOXRENDERER: string;
  69834. static readonly NAME_PARTICLESYSTEM: string;
  69835. static readonly NAME_GAMEPAD: string;
  69836. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  69837. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  69838. static readonly NAME_DEPTHRENDERER: string;
  69839. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  69840. static readonly NAME_SPRITE: string;
  69841. static readonly NAME_OUTLINERENDERER: string;
  69842. static readonly NAME_PROCEDURALTEXTURE: string;
  69843. static readonly NAME_SHADOWGENERATOR: string;
  69844. static readonly NAME_OCTREE: string;
  69845. static readonly NAME_PHYSICSENGINE: string;
  69846. static readonly NAME_AUDIO: string;
  69847. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  69848. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  69849. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  69850. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  69851. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  69852. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  69853. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  69854. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  69855. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  69856. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  69857. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  69858. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  69859. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  69860. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  69861. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  69862. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  69863. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  69864. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  69865. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  69866. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  69867. static readonly STEP_AFTERRENDER_AUDIO: number;
  69868. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  69869. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  69870. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  69871. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  69872. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  69873. static readonly STEP_POINTERMOVE_SPRITE: number;
  69874. static readonly STEP_POINTERDOWN_SPRITE: number;
  69875. static readonly STEP_POINTERUP_SPRITE: number;
  69876. }
  69877. /**
  69878. * This represents a scene component.
  69879. *
  69880. * This is used to decouple the dependency the scene is having on the different workloads like
  69881. * layers, post processes...
  69882. */
  69883. export interface ISceneComponent {
  69884. /**
  69885. * The name of the component. Each component must have a unique name.
  69886. */
  69887. name: string;
  69888. /**
  69889. * The scene the component belongs to.
  69890. */
  69891. scene: Scene;
  69892. /**
  69893. * Register the component to one instance of a scene.
  69894. */
  69895. register(): void;
  69896. /**
  69897. * Rebuilds the elements related to this component in case of
  69898. * context lost for instance.
  69899. */
  69900. rebuild(): void;
  69901. /**
  69902. * Disposes the component and the associated ressources.
  69903. */
  69904. dispose(): void;
  69905. }
  69906. /**
  69907. * This represents a SERIALIZABLE scene component.
  69908. *
  69909. * This extends Scene Component to add Serialization methods on top.
  69910. */
  69911. export interface ISceneSerializableComponent extends ISceneComponent {
  69912. /**
  69913. * Adds all the element from the container to the scene
  69914. * @param container the container holding the elements
  69915. */
  69916. addFromContainer(container: AbstractScene): void;
  69917. /**
  69918. * Removes all the elements in the container from the scene
  69919. * @param container contains the elements to remove
  69920. */
  69921. removeFromContainer(container: AbstractScene): void;
  69922. /**
  69923. * Serializes the component data to the specified json object
  69924. * @param serializationObject The object to serialize to
  69925. */
  69926. serialize(serializationObject: any): void;
  69927. }
  69928. /**
  69929. * Strong typing of a Mesh related stage step action
  69930. */
  69931. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  69932. /**
  69933. * Strong typing of a Evaluate Sub Mesh related stage step action
  69934. */
  69935. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  69936. /**
  69937. * Strong typing of a Active Mesh related stage step action
  69938. */
  69939. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  69940. /**
  69941. * Strong typing of a Camera related stage step action
  69942. */
  69943. export type CameraStageAction = (camera: Camera) => void;
  69944. /**
  69945. * Strong typing of a Render Target related stage step action
  69946. */
  69947. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  69948. /**
  69949. * Strong typing of a RenderingGroup related stage step action
  69950. */
  69951. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  69952. /**
  69953. * Strong typing of a Mesh Render related stage step action
  69954. */
  69955. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  69956. /**
  69957. * Strong typing of a simple stage step action
  69958. */
  69959. export type SimpleStageAction = () => void;
  69960. /**
  69961. * Strong typing of a render target action.
  69962. */
  69963. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  69964. /**
  69965. * Strong typing of a pointer move action.
  69966. */
  69967. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  69968. /**
  69969. * Strong typing of a pointer up/down action.
  69970. */
  69971. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  69972. /**
  69973. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  69974. * @hidden
  69975. */
  69976. export class Stage<T extends Function> extends Array<{
  69977. index: number;
  69978. component: ISceneComponent;
  69979. action: T;
  69980. }> {
  69981. /**
  69982. * Hide ctor from the rest of the world.
  69983. * @param items The items to add.
  69984. */
  69985. private constructor();
  69986. /**
  69987. * Creates a new Stage.
  69988. * @returns A new instance of a Stage
  69989. */
  69990. static Create<T extends Function>(): Stage<T>;
  69991. /**
  69992. * Registers a step in an ordered way in the targeted stage.
  69993. * @param index Defines the position to register the step in
  69994. * @param component Defines the component attached to the step
  69995. * @param action Defines the action to launch during the step
  69996. */
  69997. registerStep(index: number, component: ISceneComponent, action: T): void;
  69998. /**
  69999. * Clears all the steps from the stage.
  70000. */
  70001. clear(): void;
  70002. }
  70003. }
  70004. declare module BABYLON {
  70005. interface Scene {
  70006. /** @hidden */
  70007. _pointerOverSprite: Nullable<Sprite>;
  70008. /** @hidden */
  70009. _pickedDownSprite: Nullable<Sprite>;
  70010. /** @hidden */
  70011. _tempSpritePickingRay: Nullable<Ray>;
  70012. /**
  70013. * All of the sprite managers added to this scene
  70014. * @see http://doc.babylonjs.com/babylon101/sprites
  70015. */
  70016. spriteManagers: Array<ISpriteManager>;
  70017. /**
  70018. * An event triggered when sprites rendering is about to start
  70019. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  70020. */
  70021. onBeforeSpritesRenderingObservable: Observable<Scene>;
  70022. /**
  70023. * An event triggered when sprites rendering is done
  70024. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  70025. */
  70026. onAfterSpritesRenderingObservable: Observable<Scene>;
  70027. /** @hidden */
  70028. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  70029. /** Launch a ray to try to pick a sprite in the scene
  70030. * @param x position on screen
  70031. * @param y position on screen
  70032. * @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
  70033. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  70034. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  70035. * @returns a PickingInfo
  70036. */
  70037. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  70038. /** Use the given ray to pick a sprite in the scene
  70039. * @param ray The ray (in world space) to use to pick meshes
  70040. * @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
  70041. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  70042. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  70043. * @returns a PickingInfo
  70044. */
  70045. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  70046. /**
  70047. * Force the sprite under the pointer
  70048. * @param sprite defines the sprite to use
  70049. */
  70050. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  70051. /**
  70052. * Gets the sprite under the pointer
  70053. * @returns a Sprite or null if no sprite is under the pointer
  70054. */
  70055. getPointerOverSprite(): Nullable<Sprite>;
  70056. }
  70057. /**
  70058. * Defines the sprite scene component responsible to manage sprites
  70059. * in a given scene.
  70060. */
  70061. export class SpriteSceneComponent implements ISceneComponent {
  70062. /**
  70063. * The component name helpfull to identify the component in the list of scene components.
  70064. */
  70065. readonly name: string;
  70066. /**
  70067. * The scene the component belongs to.
  70068. */
  70069. scene: Scene;
  70070. /** @hidden */
  70071. private _spritePredicate;
  70072. /**
  70073. * Creates a new instance of the component for the given scene
  70074. * @param scene Defines the scene to register the component in
  70075. */
  70076. constructor(scene: Scene);
  70077. /**
  70078. * Registers the component in a given scene
  70079. */
  70080. register(): void;
  70081. /**
  70082. * Rebuilds the elements related to this component in case of
  70083. * context lost for instance.
  70084. */
  70085. rebuild(): void;
  70086. /**
  70087. * Disposes the component and the associated ressources.
  70088. */
  70089. dispose(): void;
  70090. private _pickSpriteButKeepRay;
  70091. private _pointerMove;
  70092. private _pointerDown;
  70093. private _pointerUp;
  70094. }
  70095. }
  70096. declare module BABYLON {
  70097. /** @hidden */
  70098. export var fogFragmentDeclaration: {
  70099. name: string;
  70100. shader: string;
  70101. };
  70102. }
  70103. declare module BABYLON {
  70104. /** @hidden */
  70105. export var fogFragment: {
  70106. name: string;
  70107. shader: string;
  70108. };
  70109. }
  70110. declare module BABYLON {
  70111. /** @hidden */
  70112. export var spritesPixelShader: {
  70113. name: string;
  70114. shader: string;
  70115. };
  70116. }
  70117. declare module BABYLON {
  70118. /** @hidden */
  70119. export var fogVertexDeclaration: {
  70120. name: string;
  70121. shader: string;
  70122. };
  70123. }
  70124. declare module BABYLON {
  70125. /** @hidden */
  70126. export var spritesVertexShader: {
  70127. name: string;
  70128. shader: string;
  70129. };
  70130. }
  70131. declare module BABYLON {
  70132. /**
  70133. * Defines the minimum interface to fullfil in order to be a sprite manager.
  70134. */
  70135. export interface ISpriteManager extends IDisposable {
  70136. /**
  70137. * Restricts the camera to viewing objects with the same layerMask.
  70138. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  70139. */
  70140. layerMask: number;
  70141. /**
  70142. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  70143. */
  70144. isPickable: boolean;
  70145. /**
  70146. * Specifies the rendering group id for this mesh (0 by default)
  70147. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  70148. */
  70149. renderingGroupId: number;
  70150. /**
  70151. * Defines the list of sprites managed by the manager.
  70152. */
  70153. sprites: Array<Sprite>;
  70154. /**
  70155. * Tests the intersection of a sprite with a specific ray.
  70156. * @param ray The ray we are sending to test the collision
  70157. * @param camera The camera space we are sending rays in
  70158. * @param predicate A predicate allowing excluding sprites from the list of object to test
  70159. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  70160. * @returns picking info or null.
  70161. */
  70162. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  70163. /**
  70164. * Renders the list of sprites on screen.
  70165. */
  70166. render(): void;
  70167. }
  70168. /**
  70169. * Class used to manage multiple sprites on the same spritesheet
  70170. * @see http://doc.babylonjs.com/babylon101/sprites
  70171. */
  70172. export class SpriteManager implements ISpriteManager {
  70173. /** defines the manager's name */
  70174. name: string;
  70175. /** Gets the list of sprites */
  70176. sprites: Sprite[];
  70177. /** Gets or sets the rendering group id (0 by default) */
  70178. renderingGroupId: number;
  70179. /** Gets or sets camera layer mask */
  70180. layerMask: number;
  70181. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  70182. fogEnabled: boolean;
  70183. /** Gets or sets a boolean indicating if the sprites are pickable */
  70184. isPickable: boolean;
  70185. /** Defines the default width of a cell in the spritesheet */
  70186. cellWidth: number;
  70187. /** Defines the default height of a cell in the spritesheet */
  70188. cellHeight: number;
  70189. /**
  70190. * An event triggered when the manager is disposed.
  70191. */
  70192. onDisposeObservable: Observable<SpriteManager>;
  70193. private _onDisposeObserver;
  70194. /**
  70195. * Callback called when the manager is disposed
  70196. */
  70197. onDispose: () => void;
  70198. private _capacity;
  70199. private _spriteTexture;
  70200. private _epsilon;
  70201. private _scene;
  70202. private _vertexData;
  70203. private _buffer;
  70204. private _vertexBuffers;
  70205. private _indexBuffer;
  70206. private _effectBase;
  70207. private _effectFog;
  70208. /**
  70209. * Gets or sets the spritesheet texture
  70210. */
  70211. texture: Texture;
  70212. /**
  70213. * Creates a new sprite manager
  70214. * @param name defines the manager's name
  70215. * @param imgUrl defines the sprite sheet url
  70216. * @param capacity defines the maximum allowed number of sprites
  70217. * @param cellSize defines the size of a sprite cell
  70218. * @param scene defines the hosting scene
  70219. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70220. * @param samplingMode defines the smapling mode to use with spritesheet
  70221. */
  70222. constructor(
  70223. /** defines the manager's name */
  70224. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  70225. private _appendSpriteVertex;
  70226. /**
  70227. * Intersects the sprites with a ray
  70228. * @param ray defines the ray to intersect with
  70229. * @param camera defines the current active camera
  70230. * @param predicate defines a predicate used to select candidate sprites
  70231. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  70232. * @returns null if no hit or a PickingInfo
  70233. */
  70234. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  70235. /**
  70236. * Render all child sprites
  70237. */
  70238. render(): void;
  70239. /**
  70240. * Release associated resources
  70241. */
  70242. dispose(): void;
  70243. }
  70244. }
  70245. declare module BABYLON {
  70246. /**
  70247. * Class used to represent a sprite
  70248. * @see http://doc.babylonjs.com/babylon101/sprites
  70249. */
  70250. export class Sprite {
  70251. /** defines the name */
  70252. name: string;
  70253. /** Gets or sets the current world position */
  70254. position: Vector3;
  70255. /** Gets or sets the main color */
  70256. color: Color4;
  70257. /** Gets or sets the width */
  70258. width: number;
  70259. /** Gets or sets the height */
  70260. height: number;
  70261. /** Gets or sets rotation angle */
  70262. angle: number;
  70263. /** Gets or sets the cell index in the sprite sheet */
  70264. cellIndex: number;
  70265. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  70266. invertU: number;
  70267. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  70268. invertV: number;
  70269. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  70270. disposeWhenFinishedAnimating: boolean;
  70271. /** Gets the list of attached animations */
  70272. animations: Animation[];
  70273. /** Gets or sets a boolean indicating if the sprite can be picked */
  70274. isPickable: boolean;
  70275. /**
  70276. * Gets or sets the associated action manager
  70277. */
  70278. actionManager: Nullable<ActionManager>;
  70279. private _animationStarted;
  70280. private _loopAnimation;
  70281. private _fromIndex;
  70282. private _toIndex;
  70283. private _delay;
  70284. private _direction;
  70285. private _manager;
  70286. private _time;
  70287. private _onAnimationEnd;
  70288. /**
  70289. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  70290. */
  70291. isVisible: boolean;
  70292. /**
  70293. * Gets or sets the sprite size
  70294. */
  70295. size: number;
  70296. /**
  70297. * Creates a new Sprite
  70298. * @param name defines the name
  70299. * @param manager defines the manager
  70300. */
  70301. constructor(
  70302. /** defines the name */
  70303. name: string, manager: ISpriteManager);
  70304. /**
  70305. * Starts an animation
  70306. * @param from defines the initial key
  70307. * @param to defines the end key
  70308. * @param loop defines if the animation must loop
  70309. * @param delay defines the start delay (in ms)
  70310. * @param onAnimationEnd defines a callback to call when animation ends
  70311. */
  70312. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  70313. /** Stops current animation (if any) */
  70314. stopAnimation(): void;
  70315. /** @hidden */
  70316. _animate(deltaTime: number): void;
  70317. /** Release associated resources */
  70318. dispose(): void;
  70319. }
  70320. }
  70321. declare module BABYLON {
  70322. /**
  70323. * Information about the result of picking within a scene
  70324. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  70325. */
  70326. export class PickingInfo {
  70327. /** @hidden */
  70328. _pickingUnavailable: boolean;
  70329. /**
  70330. * If the pick collided with an object
  70331. */
  70332. hit: boolean;
  70333. /**
  70334. * Distance away where the pick collided
  70335. */
  70336. distance: number;
  70337. /**
  70338. * The location of pick collision
  70339. */
  70340. pickedPoint: Nullable<Vector3>;
  70341. /**
  70342. * The mesh corresponding the the pick collision
  70343. */
  70344. pickedMesh: Nullable<AbstractMesh>;
  70345. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  70346. bu: number;
  70347. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  70348. bv: number;
  70349. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  70350. faceId: number;
  70351. /** Id of the the submesh that was picked */
  70352. subMeshId: number;
  70353. /** If a sprite was picked, this will be the sprite the pick collided with */
  70354. pickedSprite: Nullable<Sprite>;
  70355. /**
  70356. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  70357. */
  70358. originMesh: Nullable<AbstractMesh>;
  70359. /**
  70360. * The ray that was used to perform the picking.
  70361. */
  70362. ray: Nullable<Ray>;
  70363. /**
  70364. * Gets the normal correspodning to the face the pick collided with
  70365. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  70366. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  70367. * @returns The normal correspodning to the face the pick collided with
  70368. */
  70369. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  70370. /**
  70371. * Gets the texture coordinates of where the pick occured
  70372. * @returns the vector containing the coordnates of the texture
  70373. */
  70374. getTextureCoordinates(): Nullable<Vector2>;
  70375. }
  70376. }
  70377. declare module BABYLON {
  70378. /**
  70379. * Gather the list of pointer event types as constants.
  70380. */
  70381. export class PointerEventTypes {
  70382. /**
  70383. * 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.
  70384. */
  70385. static readonly POINTERDOWN: number;
  70386. /**
  70387. * The pointerup event is fired when a pointer is no longer active.
  70388. */
  70389. static readonly POINTERUP: number;
  70390. /**
  70391. * The pointermove event is fired when a pointer changes coordinates.
  70392. */
  70393. static readonly POINTERMOVE: number;
  70394. /**
  70395. * The pointerwheel event is fired when a mouse wheel has been rotated.
  70396. */
  70397. static readonly POINTERWHEEL: number;
  70398. /**
  70399. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  70400. */
  70401. static readonly POINTERPICK: number;
  70402. /**
  70403. * The pointertap event is fired when a the object has been touched and released without drag.
  70404. */
  70405. static readonly POINTERTAP: number;
  70406. /**
  70407. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  70408. */
  70409. static readonly POINTERDOUBLETAP: number;
  70410. }
  70411. /**
  70412. * Base class of pointer info types.
  70413. */
  70414. export class PointerInfoBase {
  70415. /**
  70416. * Defines the type of event (PointerEventTypes)
  70417. */
  70418. type: number;
  70419. /**
  70420. * Defines the related dom event
  70421. */
  70422. event: PointerEvent | MouseWheelEvent;
  70423. /**
  70424. * Instantiates the base class of pointers info.
  70425. * @param type Defines the type of event (PointerEventTypes)
  70426. * @param event Defines the related dom event
  70427. */
  70428. constructor(
  70429. /**
  70430. * Defines the type of event (PointerEventTypes)
  70431. */
  70432. type: number,
  70433. /**
  70434. * Defines the related dom event
  70435. */
  70436. event: PointerEvent | MouseWheelEvent);
  70437. }
  70438. /**
  70439. * This class is used to store pointer related info for the onPrePointerObservable event.
  70440. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  70441. */
  70442. export class PointerInfoPre extends PointerInfoBase {
  70443. /**
  70444. * Ray from a pointer if availible (eg. 6dof controller)
  70445. */
  70446. ray: Nullable<Ray>;
  70447. /**
  70448. * Defines the local position of the pointer on the canvas.
  70449. */
  70450. localPosition: Vector2;
  70451. /**
  70452. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  70453. */
  70454. skipOnPointerObservable: boolean;
  70455. /**
  70456. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  70457. * @param type Defines the type of event (PointerEventTypes)
  70458. * @param event Defines the related dom event
  70459. * @param localX Defines the local x coordinates of the pointer when the event occured
  70460. * @param localY Defines the local y coordinates of the pointer when the event occured
  70461. */
  70462. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  70463. }
  70464. /**
  70465. * This type contains all the data related to a pointer event in Babylon.js.
  70466. * 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.
  70467. */
  70468. export class PointerInfo extends PointerInfoBase {
  70469. /**
  70470. * Defines the picking info associated to the info (if any)\
  70471. */
  70472. pickInfo: Nullable<PickingInfo>;
  70473. /**
  70474. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  70475. * @param type Defines the type of event (PointerEventTypes)
  70476. * @param event Defines the related dom event
  70477. * @param pickInfo Defines the picking info associated to the info (if any)\
  70478. */
  70479. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  70480. /**
  70481. * Defines the picking info associated to the info (if any)\
  70482. */
  70483. pickInfo: Nullable<PickingInfo>);
  70484. }
  70485. /**
  70486. * Data relating to a touch event on the screen.
  70487. */
  70488. export interface PointerTouch {
  70489. /**
  70490. * X coordinate of touch.
  70491. */
  70492. x: number;
  70493. /**
  70494. * Y coordinate of touch.
  70495. */
  70496. y: number;
  70497. /**
  70498. * Id of touch. Unique for each finger.
  70499. */
  70500. pointerId: number;
  70501. /**
  70502. * Event type passed from DOM.
  70503. */
  70504. type: any;
  70505. }
  70506. }
  70507. declare module BABYLON {
  70508. /**
  70509. * Manage the mouse inputs to control the movement of a free camera.
  70510. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70511. */
  70512. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  70513. /**
  70514. * Define if touch is enabled in the mouse input
  70515. */
  70516. touchEnabled: boolean;
  70517. /**
  70518. * Defines the camera the input is attached to.
  70519. */
  70520. camera: FreeCamera;
  70521. /**
  70522. * Defines the buttons associated with the input to handle camera move.
  70523. */
  70524. buttons: number[];
  70525. /**
  70526. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  70527. */
  70528. angularSensibility: number;
  70529. private _pointerInput;
  70530. private _onMouseMove;
  70531. private _observer;
  70532. private previousPosition;
  70533. /**
  70534. * Manage the mouse inputs to control the movement of a free camera.
  70535. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70536. * @param touchEnabled Defines if touch is enabled or not
  70537. */
  70538. constructor(
  70539. /**
  70540. * Define if touch is enabled in the mouse input
  70541. */
  70542. touchEnabled?: boolean);
  70543. /**
  70544. * Attach the input controls to a specific dom element to get the input from.
  70545. * @param element Defines the element the controls should be listened from
  70546. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70547. */
  70548. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70549. /**
  70550. * Called on JS contextmenu event.
  70551. * Override this method to provide functionality.
  70552. */
  70553. protected onContextMenu(evt: PointerEvent): void;
  70554. /**
  70555. * Detach the current controls from the specified dom element.
  70556. * @param element Defines the element to stop listening the inputs from
  70557. */
  70558. detachControl(element: Nullable<HTMLElement>): void;
  70559. /**
  70560. * Gets the class name of the current intput.
  70561. * @returns the class name
  70562. */
  70563. getClassName(): string;
  70564. /**
  70565. * Get the friendly name associated with the input class.
  70566. * @returns the input friendly name
  70567. */
  70568. getSimpleName(): string;
  70569. }
  70570. }
  70571. declare module BABYLON {
  70572. /**
  70573. * Manage the touch inputs to control the movement of a free camera.
  70574. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70575. */
  70576. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  70577. /**
  70578. * Defines the camera the input is attached to.
  70579. */
  70580. camera: FreeCamera;
  70581. /**
  70582. * Defines the touch sensibility for rotation.
  70583. * The higher the faster.
  70584. */
  70585. touchAngularSensibility: number;
  70586. /**
  70587. * Defines the touch sensibility for move.
  70588. * The higher the faster.
  70589. */
  70590. touchMoveSensibility: number;
  70591. private _offsetX;
  70592. private _offsetY;
  70593. private _pointerPressed;
  70594. private _pointerInput;
  70595. private _observer;
  70596. private _onLostFocus;
  70597. /**
  70598. * Attach the input controls to a specific dom element to get the input from.
  70599. * @param element Defines the element the controls should be listened from
  70600. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70601. */
  70602. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70603. /**
  70604. * Detach the current controls from the specified dom element.
  70605. * @param element Defines the element to stop listening the inputs from
  70606. */
  70607. detachControl(element: Nullable<HTMLElement>): void;
  70608. /**
  70609. * Update the current camera state depending on the inputs that have been used this frame.
  70610. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70611. */
  70612. checkInputs(): void;
  70613. /**
  70614. * Gets the class name of the current intput.
  70615. * @returns the class name
  70616. */
  70617. getClassName(): string;
  70618. /**
  70619. * Get the friendly name associated with the input class.
  70620. * @returns the input friendly name
  70621. */
  70622. getSimpleName(): string;
  70623. }
  70624. }
  70625. declare module BABYLON {
  70626. /**
  70627. * Default Inputs manager for the FreeCamera.
  70628. * It groups all the default supported inputs for ease of use.
  70629. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70630. */
  70631. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  70632. /**
  70633. * Instantiates a new FreeCameraInputsManager.
  70634. * @param camera Defines the camera the inputs belong to
  70635. */
  70636. constructor(camera: FreeCamera);
  70637. /**
  70638. * Add keyboard input support to the input manager.
  70639. * @returns the current input manager
  70640. */
  70641. addKeyboard(): FreeCameraInputsManager;
  70642. /**
  70643. * Add mouse input support to the input manager.
  70644. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  70645. * @returns the current input manager
  70646. */
  70647. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  70648. /**
  70649. * Add touch input support to the input manager.
  70650. * @returns the current input manager
  70651. */
  70652. addTouch(): FreeCameraInputsManager;
  70653. }
  70654. }
  70655. declare module BABYLON {
  70656. /**
  70657. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  70658. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  70659. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  70660. */
  70661. export class FreeCamera extends TargetCamera {
  70662. /**
  70663. * Define the collision ellipsoid of the camera.
  70664. * This is helpful to simulate a camera body like the player body around the camera
  70665. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  70666. */
  70667. ellipsoid: Vector3;
  70668. /**
  70669. * Define an offset for the position of the ellipsoid around the camera.
  70670. * This can be helpful to determine the center of the body near the gravity center of the body
  70671. * instead of its head.
  70672. */
  70673. ellipsoidOffset: Vector3;
  70674. /**
  70675. * Enable or disable collisions of the camera with the rest of the scene objects.
  70676. */
  70677. checkCollisions: boolean;
  70678. /**
  70679. * Enable or disable gravity on the camera.
  70680. */
  70681. applyGravity: boolean;
  70682. /**
  70683. * Define the input manager associated to the camera.
  70684. */
  70685. inputs: FreeCameraInputsManager;
  70686. /**
  70687. * Gets the input sensibility for a mouse input. (default is 2000.0)
  70688. * Higher values reduce sensitivity.
  70689. */
  70690. /**
  70691. * Sets the input sensibility for a mouse input. (default is 2000.0)
  70692. * Higher values reduce sensitivity.
  70693. */
  70694. angularSensibility: number;
  70695. /**
  70696. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  70697. */
  70698. keysUp: number[];
  70699. /**
  70700. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  70701. */
  70702. keysDown: number[];
  70703. /**
  70704. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  70705. */
  70706. keysLeft: number[];
  70707. /**
  70708. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  70709. */
  70710. keysRight: number[];
  70711. /**
  70712. * Event raised when the camera collide with a mesh in the scene.
  70713. */
  70714. onCollide: (collidedMesh: AbstractMesh) => void;
  70715. private _collider;
  70716. private _needMoveForGravity;
  70717. private _oldPosition;
  70718. private _diffPosition;
  70719. private _newPosition;
  70720. /** @hidden */
  70721. _localDirection: Vector3;
  70722. /** @hidden */
  70723. _transformedDirection: Vector3;
  70724. /**
  70725. * Instantiates a Free Camera.
  70726. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  70727. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  70728. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  70729. * @param name Define the name of the camera in the scene
  70730. * @param position Define the start position of the camera in the scene
  70731. * @param scene Define the scene the camera belongs to
  70732. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  70733. */
  70734. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  70735. /**
  70736. * Attached controls to the current camera.
  70737. * @param element Defines the element the controls should be listened from
  70738. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70739. */
  70740. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70741. /**
  70742. * Detach the current controls from the camera.
  70743. * The camera will stop reacting to inputs.
  70744. * @param element Defines the element to stop listening the inputs from
  70745. */
  70746. detachControl(element: HTMLElement): void;
  70747. private _collisionMask;
  70748. /**
  70749. * Define a collision mask to limit the list of object the camera can collide with
  70750. */
  70751. collisionMask: number;
  70752. /** @hidden */
  70753. _collideWithWorld(displacement: Vector3): void;
  70754. private _onCollisionPositionChange;
  70755. /** @hidden */
  70756. _checkInputs(): void;
  70757. /** @hidden */
  70758. _decideIfNeedsToMove(): boolean;
  70759. /** @hidden */
  70760. _updatePosition(): void;
  70761. /**
  70762. * Destroy the camera and release the current resources hold by it.
  70763. */
  70764. dispose(): void;
  70765. /**
  70766. * Gets the current object class name.
  70767. * @return the class name
  70768. */
  70769. getClassName(): string;
  70770. }
  70771. }
  70772. declare module BABYLON {
  70773. /**
  70774. * Represents a gamepad control stick position
  70775. */
  70776. export class StickValues {
  70777. /**
  70778. * The x component of the control stick
  70779. */
  70780. x: number;
  70781. /**
  70782. * The y component of the control stick
  70783. */
  70784. y: number;
  70785. /**
  70786. * Initializes the gamepad x and y control stick values
  70787. * @param x The x component of the gamepad control stick value
  70788. * @param y The y component of the gamepad control stick value
  70789. */
  70790. constructor(
  70791. /**
  70792. * The x component of the control stick
  70793. */
  70794. x: number,
  70795. /**
  70796. * The y component of the control stick
  70797. */
  70798. y: number);
  70799. }
  70800. /**
  70801. * An interface which manages callbacks for gamepad button changes
  70802. */
  70803. export interface GamepadButtonChanges {
  70804. /**
  70805. * Called when a gamepad has been changed
  70806. */
  70807. changed: boolean;
  70808. /**
  70809. * Called when a gamepad press event has been triggered
  70810. */
  70811. pressChanged: boolean;
  70812. /**
  70813. * Called when a touch event has been triggered
  70814. */
  70815. touchChanged: boolean;
  70816. /**
  70817. * Called when a value has changed
  70818. */
  70819. valueChanged: boolean;
  70820. }
  70821. /**
  70822. * Represents a gamepad
  70823. */
  70824. export class Gamepad {
  70825. /**
  70826. * The id of the gamepad
  70827. */
  70828. id: string;
  70829. /**
  70830. * The index of the gamepad
  70831. */
  70832. index: number;
  70833. /**
  70834. * The browser gamepad
  70835. */
  70836. browserGamepad: any;
  70837. /**
  70838. * Specifies what type of gamepad this represents
  70839. */
  70840. type: number;
  70841. private _leftStick;
  70842. private _rightStick;
  70843. /** @hidden */
  70844. _isConnected: boolean;
  70845. private _leftStickAxisX;
  70846. private _leftStickAxisY;
  70847. private _rightStickAxisX;
  70848. private _rightStickAxisY;
  70849. /**
  70850. * Triggered when the left control stick has been changed
  70851. */
  70852. private _onleftstickchanged;
  70853. /**
  70854. * Triggered when the right control stick has been changed
  70855. */
  70856. private _onrightstickchanged;
  70857. /**
  70858. * Represents a gamepad controller
  70859. */
  70860. static GAMEPAD: number;
  70861. /**
  70862. * Represents a generic controller
  70863. */
  70864. static GENERIC: number;
  70865. /**
  70866. * Represents an XBox controller
  70867. */
  70868. static XBOX: number;
  70869. /**
  70870. * Represents a pose-enabled controller
  70871. */
  70872. static POSE_ENABLED: number;
  70873. /**
  70874. * Specifies whether the left control stick should be Y-inverted
  70875. */
  70876. protected _invertLeftStickY: boolean;
  70877. /**
  70878. * Specifies if the gamepad has been connected
  70879. */
  70880. readonly isConnected: boolean;
  70881. /**
  70882. * Initializes the gamepad
  70883. * @param id The id of the gamepad
  70884. * @param index The index of the gamepad
  70885. * @param browserGamepad The browser gamepad
  70886. * @param leftStickX The x component of the left joystick
  70887. * @param leftStickY The y component of the left joystick
  70888. * @param rightStickX The x component of the right joystick
  70889. * @param rightStickY The y component of the right joystick
  70890. */
  70891. constructor(
  70892. /**
  70893. * The id of the gamepad
  70894. */
  70895. id: string,
  70896. /**
  70897. * The index of the gamepad
  70898. */
  70899. index: number,
  70900. /**
  70901. * The browser gamepad
  70902. */
  70903. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  70904. /**
  70905. * Callback triggered when the left joystick has changed
  70906. * @param callback
  70907. */
  70908. onleftstickchanged(callback: (values: StickValues) => void): void;
  70909. /**
  70910. * Callback triggered when the right joystick has changed
  70911. * @param callback
  70912. */
  70913. onrightstickchanged(callback: (values: StickValues) => void): void;
  70914. /**
  70915. * Gets the left joystick
  70916. */
  70917. /**
  70918. * Sets the left joystick values
  70919. */
  70920. leftStick: StickValues;
  70921. /**
  70922. * Gets the right joystick
  70923. */
  70924. /**
  70925. * Sets the right joystick value
  70926. */
  70927. rightStick: StickValues;
  70928. /**
  70929. * Updates the gamepad joystick positions
  70930. */
  70931. update(): void;
  70932. /**
  70933. * Disposes the gamepad
  70934. */
  70935. dispose(): void;
  70936. }
  70937. /**
  70938. * Represents a generic gamepad
  70939. */
  70940. export class GenericPad extends Gamepad {
  70941. private _buttons;
  70942. private _onbuttondown;
  70943. private _onbuttonup;
  70944. /**
  70945. * Observable triggered when a button has been pressed
  70946. */
  70947. onButtonDownObservable: Observable<number>;
  70948. /**
  70949. * Observable triggered when a button has been released
  70950. */
  70951. onButtonUpObservable: Observable<number>;
  70952. /**
  70953. * Callback triggered when a button has been pressed
  70954. * @param callback Called when a button has been pressed
  70955. */
  70956. onbuttondown(callback: (buttonPressed: number) => void): void;
  70957. /**
  70958. * Callback triggered when a button has been released
  70959. * @param callback Called when a button has been released
  70960. */
  70961. onbuttonup(callback: (buttonReleased: number) => void): void;
  70962. /**
  70963. * Initializes the generic gamepad
  70964. * @param id The id of the generic gamepad
  70965. * @param index The index of the generic gamepad
  70966. * @param browserGamepad The browser gamepad
  70967. */
  70968. constructor(id: string, index: number, browserGamepad: any);
  70969. private _setButtonValue;
  70970. /**
  70971. * Updates the generic gamepad
  70972. */
  70973. update(): void;
  70974. /**
  70975. * Disposes the generic gamepad
  70976. */
  70977. dispose(): void;
  70978. }
  70979. }
  70980. declare module BABYLON {
  70981. /**
  70982. * Defines the types of pose enabled controllers that are supported
  70983. */
  70984. export enum PoseEnabledControllerType {
  70985. /**
  70986. * HTC Vive
  70987. */
  70988. VIVE = 0,
  70989. /**
  70990. * Oculus Rift
  70991. */
  70992. OCULUS = 1,
  70993. /**
  70994. * Windows mixed reality
  70995. */
  70996. WINDOWS = 2,
  70997. /**
  70998. * Samsung gear VR
  70999. */
  71000. GEAR_VR = 3,
  71001. /**
  71002. * Google Daydream
  71003. */
  71004. DAYDREAM = 4,
  71005. /**
  71006. * Generic
  71007. */
  71008. GENERIC = 5
  71009. }
  71010. /**
  71011. * Defines the MutableGamepadButton interface for the state of a gamepad button
  71012. */
  71013. export interface MutableGamepadButton {
  71014. /**
  71015. * Value of the button/trigger
  71016. */
  71017. value: number;
  71018. /**
  71019. * If the button/trigger is currently touched
  71020. */
  71021. touched: boolean;
  71022. /**
  71023. * If the button/trigger is currently pressed
  71024. */
  71025. pressed: boolean;
  71026. }
  71027. /**
  71028. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  71029. * @hidden
  71030. */
  71031. export interface ExtendedGamepadButton extends GamepadButton {
  71032. /**
  71033. * If the button/trigger is currently pressed
  71034. */
  71035. readonly pressed: boolean;
  71036. /**
  71037. * If the button/trigger is currently touched
  71038. */
  71039. readonly touched: boolean;
  71040. /**
  71041. * Value of the button/trigger
  71042. */
  71043. readonly value: number;
  71044. }
  71045. /** @hidden */
  71046. export interface _GamePadFactory {
  71047. /**
  71048. * Returns wether or not the current gamepad can be created for this type of controller.
  71049. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  71050. * @returns true if it can be created, otherwise false
  71051. */
  71052. canCreate(gamepadInfo: any): boolean;
  71053. /**
  71054. * Creates a new instance of the Gamepad.
  71055. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  71056. * @returns the new gamepad instance
  71057. */
  71058. create(gamepadInfo: any): Gamepad;
  71059. }
  71060. /**
  71061. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  71062. */
  71063. export class PoseEnabledControllerHelper {
  71064. /** @hidden */
  71065. static _ControllerFactories: _GamePadFactory[];
  71066. /** @hidden */
  71067. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  71068. /**
  71069. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  71070. * @param vrGamepad the gamepad to initialized
  71071. * @returns a vr controller of the type the gamepad identified as
  71072. */
  71073. static InitiateController(vrGamepad: any): Gamepad;
  71074. }
  71075. /**
  71076. * Defines the PoseEnabledController object that contains state of a vr capable controller
  71077. */
  71078. export class PoseEnabledController extends Gamepad implements PoseControlled {
  71079. private _deviceRoomPosition;
  71080. private _deviceRoomRotationQuaternion;
  71081. /**
  71082. * The device position in babylon space
  71083. */
  71084. devicePosition: Vector3;
  71085. /**
  71086. * The device rotation in babylon space
  71087. */
  71088. deviceRotationQuaternion: Quaternion;
  71089. /**
  71090. * The scale factor of the device in babylon space
  71091. */
  71092. deviceScaleFactor: number;
  71093. /**
  71094. * (Likely devicePosition should be used instead) The device position in its room space
  71095. */
  71096. position: Vector3;
  71097. /**
  71098. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  71099. */
  71100. rotationQuaternion: Quaternion;
  71101. /**
  71102. * The type of controller (Eg. Windows mixed reality)
  71103. */
  71104. controllerType: PoseEnabledControllerType;
  71105. protected _calculatedPosition: Vector3;
  71106. private _calculatedRotation;
  71107. /**
  71108. * The raw pose from the device
  71109. */
  71110. rawPose: DevicePose;
  71111. private _trackPosition;
  71112. private _maxRotationDistFromHeadset;
  71113. private _draggedRoomRotation;
  71114. /**
  71115. * @hidden
  71116. */
  71117. _disableTrackPosition(fixedPosition: Vector3): void;
  71118. /**
  71119. * Internal, the mesh attached to the controller
  71120. * @hidden
  71121. */
  71122. _mesh: Nullable<AbstractMesh>;
  71123. private _poseControlledCamera;
  71124. private _leftHandSystemQuaternion;
  71125. /**
  71126. * Internal, matrix used to convert room space to babylon space
  71127. * @hidden
  71128. */
  71129. _deviceToWorld: Matrix;
  71130. /**
  71131. * Node to be used when casting a ray from the controller
  71132. * @hidden
  71133. */
  71134. _pointingPoseNode: Nullable<TransformNode>;
  71135. /**
  71136. * Name of the child mesh that can be used to cast a ray from the controller
  71137. */
  71138. static readonly POINTING_POSE: string;
  71139. /**
  71140. * Creates a new PoseEnabledController from a gamepad
  71141. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  71142. */
  71143. constructor(browserGamepad: any);
  71144. private _workingMatrix;
  71145. /**
  71146. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  71147. */
  71148. update(): void;
  71149. /**
  71150. * Updates only the pose device and mesh without doing any button event checking
  71151. */
  71152. protected _updatePoseAndMesh(): void;
  71153. /**
  71154. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  71155. * @param poseData raw pose fromthe device
  71156. */
  71157. updateFromDevice(poseData: DevicePose): void;
  71158. /**
  71159. * @hidden
  71160. */
  71161. _meshAttachedObservable: Observable<AbstractMesh>;
  71162. /**
  71163. * Attaches a mesh to the controller
  71164. * @param mesh the mesh to be attached
  71165. */
  71166. attachToMesh(mesh: AbstractMesh): void;
  71167. /**
  71168. * Attaches the controllers mesh to a camera
  71169. * @param camera the camera the mesh should be attached to
  71170. */
  71171. attachToPoseControlledCamera(camera: TargetCamera): void;
  71172. /**
  71173. * Disposes of the controller
  71174. */
  71175. dispose(): void;
  71176. /**
  71177. * The mesh that is attached to the controller
  71178. */
  71179. readonly mesh: Nullable<AbstractMesh>;
  71180. /**
  71181. * Gets the ray of the controller in the direction the controller is pointing
  71182. * @param length the length the resulting ray should be
  71183. * @returns a ray in the direction the controller is pointing
  71184. */
  71185. getForwardRay(length?: number): Ray;
  71186. }
  71187. }
  71188. declare module BABYLON {
  71189. /**
  71190. * Defines the WebVRController object that represents controllers tracked in 3D space
  71191. */
  71192. export abstract class WebVRController extends PoseEnabledController {
  71193. /**
  71194. * Internal, the default controller model for the controller
  71195. */
  71196. protected _defaultModel: AbstractMesh;
  71197. /**
  71198. * Fired when the trigger state has changed
  71199. */
  71200. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  71201. /**
  71202. * Fired when the main button state has changed
  71203. */
  71204. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  71205. /**
  71206. * Fired when the secondary button state has changed
  71207. */
  71208. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  71209. /**
  71210. * Fired when the pad state has changed
  71211. */
  71212. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  71213. /**
  71214. * Fired when controllers stick values have changed
  71215. */
  71216. onPadValuesChangedObservable: Observable<StickValues>;
  71217. /**
  71218. * Array of button availible on the controller
  71219. */
  71220. protected _buttons: Array<MutableGamepadButton>;
  71221. private _onButtonStateChange;
  71222. /**
  71223. * Fired when a controller button's state has changed
  71224. * @param callback the callback containing the button that was modified
  71225. */
  71226. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  71227. /**
  71228. * X and Y axis corrisponding to the controllers joystick
  71229. */
  71230. pad: StickValues;
  71231. /**
  71232. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  71233. */
  71234. hand: string;
  71235. /**
  71236. * The default controller model for the controller
  71237. */
  71238. readonly defaultModel: AbstractMesh;
  71239. /**
  71240. * Creates a new WebVRController from a gamepad
  71241. * @param vrGamepad the gamepad that the WebVRController should be created from
  71242. */
  71243. constructor(vrGamepad: any);
  71244. /**
  71245. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  71246. */
  71247. update(): void;
  71248. /**
  71249. * Function to be called when a button is modified
  71250. */
  71251. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  71252. /**
  71253. * Loads a mesh and attaches it to the controller
  71254. * @param scene the scene the mesh should be added to
  71255. * @param meshLoaded callback for when the mesh has been loaded
  71256. */
  71257. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  71258. private _setButtonValue;
  71259. private _changes;
  71260. private _checkChanges;
  71261. /**
  71262. * Disposes of th webVRCOntroller
  71263. */
  71264. dispose(): void;
  71265. }
  71266. }
  71267. declare module BABYLON {
  71268. /**
  71269. * The HemisphericLight simulates the ambient environment light,
  71270. * so the passed direction is the light reflection direction, not the incoming direction.
  71271. */
  71272. export class HemisphericLight extends Light {
  71273. /**
  71274. * The groundColor is the light in the opposite direction to the one specified during creation.
  71275. * 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.
  71276. */
  71277. groundColor: Color3;
  71278. /**
  71279. * The light reflection direction, not the incoming direction.
  71280. */
  71281. direction: Vector3;
  71282. /**
  71283. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  71284. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  71285. * The HemisphericLight can't cast shadows.
  71286. * Documentation : https://doc.babylonjs.com/babylon101/lights
  71287. * @param name The friendly name of the light
  71288. * @param direction The direction of the light reflection
  71289. * @param scene The scene the light belongs to
  71290. */
  71291. constructor(name: string, direction: Vector3, scene: Scene);
  71292. protected _buildUniformLayout(): void;
  71293. /**
  71294. * Returns the string "HemisphericLight".
  71295. * @return The class name
  71296. */
  71297. getClassName(): string;
  71298. /**
  71299. * Sets the HemisphericLight direction towards the passed target (Vector3).
  71300. * Returns the updated direction.
  71301. * @param target The target the direction should point to
  71302. * @return The computed direction
  71303. */
  71304. setDirectionToTarget(target: Vector3): Vector3;
  71305. /**
  71306. * Returns the shadow generator associated to the light.
  71307. * @returns Always null for hemispheric lights because it does not support shadows.
  71308. */
  71309. getShadowGenerator(): Nullable<IShadowGenerator>;
  71310. /**
  71311. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  71312. * @param effect The effect to update
  71313. * @param lightIndex The index of the light in the effect to update
  71314. * @returns The hemispheric light
  71315. */
  71316. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  71317. /**
  71318. * Computes the world matrix of the node
  71319. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  71320. * @param useWasUpdatedFlag defines a reserved property
  71321. * @returns the world matrix
  71322. */
  71323. computeWorldMatrix(): Matrix;
  71324. /**
  71325. * Returns the integer 3.
  71326. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  71327. */
  71328. getTypeID(): number;
  71329. /**
  71330. * Prepares the list of defines specific to the light type.
  71331. * @param defines the list of defines
  71332. * @param lightIndex defines the index of the light for the effect
  71333. */
  71334. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  71335. }
  71336. }
  71337. declare module BABYLON {
  71338. /**
  71339. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  71340. * IMPORTANT!! The data is right-hand data.
  71341. * @export
  71342. * @interface DevicePose
  71343. */
  71344. export interface DevicePose {
  71345. /**
  71346. * The position of the device, values in array are [x,y,z].
  71347. */
  71348. readonly position: Nullable<Float32Array>;
  71349. /**
  71350. * The linearVelocity of the device, values in array are [x,y,z].
  71351. */
  71352. readonly linearVelocity: Nullable<Float32Array>;
  71353. /**
  71354. * The linearAcceleration of the device, values in array are [x,y,z].
  71355. */
  71356. readonly linearAcceleration: Nullable<Float32Array>;
  71357. /**
  71358. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  71359. */
  71360. readonly orientation: Nullable<Float32Array>;
  71361. /**
  71362. * The angularVelocity of the device, values in array are [x,y,z].
  71363. */
  71364. readonly angularVelocity: Nullable<Float32Array>;
  71365. /**
  71366. * The angularAcceleration of the device, values in array are [x,y,z].
  71367. */
  71368. readonly angularAcceleration: Nullable<Float32Array>;
  71369. }
  71370. /**
  71371. * Interface representing a pose controlled object in Babylon.
  71372. * A pose controlled object has both regular pose values as well as pose values
  71373. * from an external device such as a VR head mounted display
  71374. */
  71375. export interface PoseControlled {
  71376. /**
  71377. * The position of the object in babylon space.
  71378. */
  71379. position: Vector3;
  71380. /**
  71381. * The rotation quaternion of the object in babylon space.
  71382. */
  71383. rotationQuaternion: Quaternion;
  71384. /**
  71385. * The position of the device in babylon space.
  71386. */
  71387. devicePosition?: Vector3;
  71388. /**
  71389. * The rotation quaternion of the device in babylon space.
  71390. */
  71391. deviceRotationQuaternion: Quaternion;
  71392. /**
  71393. * The raw pose coming from the device.
  71394. */
  71395. rawPose: Nullable<DevicePose>;
  71396. /**
  71397. * The scale of the device to be used when translating from device space to babylon space.
  71398. */
  71399. deviceScaleFactor: number;
  71400. /**
  71401. * Updates the poseControlled values based on the input device pose.
  71402. * @param poseData the pose data to update the object with
  71403. */
  71404. updateFromDevice(poseData: DevicePose): void;
  71405. }
  71406. /**
  71407. * Set of options to customize the webVRCamera
  71408. */
  71409. export interface WebVROptions {
  71410. /**
  71411. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  71412. */
  71413. trackPosition?: boolean;
  71414. /**
  71415. * Sets the scale of the vrDevice in babylon space. (default: 1)
  71416. */
  71417. positionScale?: number;
  71418. /**
  71419. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  71420. */
  71421. displayName?: string;
  71422. /**
  71423. * Should the native controller meshes be initialized. (default: true)
  71424. */
  71425. controllerMeshes?: boolean;
  71426. /**
  71427. * Creating a default HemiLight only on controllers. (default: true)
  71428. */
  71429. defaultLightingOnControllers?: boolean;
  71430. /**
  71431. * If you don't want to use the default VR button of the helper. (default: false)
  71432. */
  71433. useCustomVRButton?: boolean;
  71434. /**
  71435. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  71436. */
  71437. customVRButton?: HTMLButtonElement;
  71438. /**
  71439. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  71440. */
  71441. rayLength?: number;
  71442. /**
  71443. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  71444. */
  71445. defaultHeight?: number;
  71446. }
  71447. /**
  71448. * This represents a WebVR camera.
  71449. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  71450. * @example http://doc.babylonjs.com/how_to/webvr_camera
  71451. */
  71452. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  71453. private webVROptions;
  71454. /**
  71455. * @hidden
  71456. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  71457. */
  71458. _vrDevice: any;
  71459. /**
  71460. * The rawPose of the vrDevice.
  71461. */
  71462. rawPose: Nullable<DevicePose>;
  71463. private _onVREnabled;
  71464. private _specsVersion;
  71465. private _attached;
  71466. private _frameData;
  71467. protected _descendants: Array<Node>;
  71468. private _deviceRoomPosition;
  71469. /** @hidden */
  71470. _deviceRoomRotationQuaternion: Quaternion;
  71471. private _standingMatrix;
  71472. /**
  71473. * Represents device position in babylon space.
  71474. */
  71475. devicePosition: Vector3;
  71476. /**
  71477. * Represents device rotation in babylon space.
  71478. */
  71479. deviceRotationQuaternion: Quaternion;
  71480. /**
  71481. * The scale of the device to be used when translating from device space to babylon space.
  71482. */
  71483. deviceScaleFactor: number;
  71484. private _deviceToWorld;
  71485. private _worldToDevice;
  71486. /**
  71487. * References to the webVR controllers for the vrDevice.
  71488. */
  71489. controllers: Array<WebVRController>;
  71490. /**
  71491. * Emits an event when a controller is attached.
  71492. */
  71493. onControllersAttachedObservable: Observable<WebVRController[]>;
  71494. /**
  71495. * Emits an event when a controller's mesh has been loaded;
  71496. */
  71497. onControllerMeshLoadedObservable: Observable<WebVRController>;
  71498. /**
  71499. * Emits an event when the HMD's pose has been updated.
  71500. */
  71501. onPoseUpdatedFromDeviceObservable: Observable<any>;
  71502. private _poseSet;
  71503. /**
  71504. * If the rig cameras be used as parent instead of this camera.
  71505. */
  71506. rigParenting: boolean;
  71507. private _lightOnControllers;
  71508. private _defaultHeight?;
  71509. /**
  71510. * Instantiates a WebVRFreeCamera.
  71511. * @param name The name of the WebVRFreeCamera
  71512. * @param position The starting anchor position for the camera
  71513. * @param scene The scene the camera belongs to
  71514. * @param webVROptions a set of customizable options for the webVRCamera
  71515. */
  71516. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  71517. /**
  71518. * Gets the device distance from the ground in meters.
  71519. * @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.
  71520. */
  71521. deviceDistanceToRoomGround(): number;
  71522. /**
  71523. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  71524. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  71525. */
  71526. useStandingMatrix(callback?: (bool: boolean) => void): void;
  71527. /**
  71528. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  71529. * @returns A promise with a boolean set to if the standing matrix is supported.
  71530. */
  71531. useStandingMatrixAsync(): Promise<boolean>;
  71532. /**
  71533. * Disposes the camera
  71534. */
  71535. dispose(): void;
  71536. /**
  71537. * Gets a vrController by name.
  71538. * @param name The name of the controller to retreive
  71539. * @returns the controller matching the name specified or null if not found
  71540. */
  71541. getControllerByName(name: string): Nullable<WebVRController>;
  71542. private _leftController;
  71543. /**
  71544. * The controller corrisponding to the users left hand.
  71545. */
  71546. readonly leftController: Nullable<WebVRController>;
  71547. private _rightController;
  71548. /**
  71549. * The controller corrisponding to the users right hand.
  71550. */
  71551. readonly rightController: Nullable<WebVRController>;
  71552. /**
  71553. * Casts a ray forward from the vrCamera's gaze.
  71554. * @param length Length of the ray (default: 100)
  71555. * @returns the ray corrisponding to the gaze
  71556. */
  71557. getForwardRay(length?: number): Ray;
  71558. /**
  71559. * @hidden
  71560. * Updates the camera based on device's frame data
  71561. */
  71562. _checkInputs(): void;
  71563. /**
  71564. * Updates the poseControlled values based on the input device pose.
  71565. * @param poseData Pose coming from the device
  71566. */
  71567. updateFromDevice(poseData: DevicePose): void;
  71568. private _htmlElementAttached;
  71569. private _detachIfAttached;
  71570. /**
  71571. * WebVR's attach control will start broadcasting frames to the device.
  71572. * Note that in certain browsers (chrome for example) this function must be called
  71573. * within a user-interaction callback. Example:
  71574. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  71575. *
  71576. * @param element html element to attach the vrDevice to
  71577. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  71578. */
  71579. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71580. /**
  71581. * Detaches the camera from the html element and disables VR
  71582. *
  71583. * @param element html element to detach from
  71584. */
  71585. detachControl(element: HTMLElement): void;
  71586. /**
  71587. * @returns the name of this class
  71588. */
  71589. getClassName(): string;
  71590. /**
  71591. * Calls resetPose on the vrDisplay
  71592. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  71593. */
  71594. resetToCurrentRotation(): void;
  71595. /**
  71596. * @hidden
  71597. * Updates the rig cameras (left and right eye)
  71598. */
  71599. _updateRigCameras(): void;
  71600. private _workingVector;
  71601. private _oneVector;
  71602. private _workingMatrix;
  71603. private updateCacheCalled;
  71604. private _correctPositionIfNotTrackPosition;
  71605. /**
  71606. * @hidden
  71607. * Updates the cached values of the camera
  71608. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  71609. */
  71610. _updateCache(ignoreParentClass?: boolean): void;
  71611. /**
  71612. * @hidden
  71613. * Get current device position in babylon world
  71614. */
  71615. _computeDevicePosition(): void;
  71616. /**
  71617. * Updates the current device position and rotation in the babylon world
  71618. */
  71619. update(): void;
  71620. /**
  71621. * @hidden
  71622. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  71623. * @returns an identity matrix
  71624. */
  71625. _getViewMatrix(): Matrix;
  71626. private _tmpMatrix;
  71627. /**
  71628. * This function is called by the two RIG cameras.
  71629. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  71630. * @hidden
  71631. */
  71632. _getWebVRViewMatrix(): Matrix;
  71633. /** @hidden */
  71634. _getWebVRProjectionMatrix(): Matrix;
  71635. private _onGamepadConnectedObserver;
  71636. private _onGamepadDisconnectedObserver;
  71637. private _updateCacheWhenTrackingDisabledObserver;
  71638. /**
  71639. * Initializes the controllers and their meshes
  71640. */
  71641. initControllers(): void;
  71642. }
  71643. }
  71644. declare module BABYLON {
  71645. /**
  71646. * Size options for a post process
  71647. */
  71648. export type PostProcessOptions = {
  71649. width: number;
  71650. height: number;
  71651. };
  71652. /**
  71653. * PostProcess can be used to apply a shader to a texture after it has been rendered
  71654. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71655. */
  71656. export class PostProcess {
  71657. /** Name of the PostProcess. */
  71658. name: string;
  71659. /**
  71660. * Gets or sets the unique id of the post process
  71661. */
  71662. uniqueId: number;
  71663. /**
  71664. * Width of the texture to apply the post process on
  71665. */
  71666. width: number;
  71667. /**
  71668. * Height of the texture to apply the post process on
  71669. */
  71670. height: number;
  71671. /**
  71672. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  71673. * @hidden
  71674. */
  71675. _outputTexture: Nullable<InternalTexture>;
  71676. /**
  71677. * Sampling mode used by the shader
  71678. * See https://doc.babylonjs.com/classes/3.1/texture
  71679. */
  71680. renderTargetSamplingMode: number;
  71681. /**
  71682. * Clear color to use when screen clearing
  71683. */
  71684. clearColor: Color4;
  71685. /**
  71686. * If the buffer needs to be cleared before applying the post process. (default: true)
  71687. * Should be set to false if shader will overwrite all previous pixels.
  71688. */
  71689. autoClear: boolean;
  71690. /**
  71691. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  71692. */
  71693. alphaMode: number;
  71694. /**
  71695. * Sets the setAlphaBlendConstants of the babylon engine
  71696. */
  71697. alphaConstants: Color4;
  71698. /**
  71699. * Animations to be used for the post processing
  71700. */
  71701. animations: Animation[];
  71702. /**
  71703. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  71704. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  71705. */
  71706. enablePixelPerfectMode: boolean;
  71707. /**
  71708. * Force the postprocess to be applied without taking in account viewport
  71709. */
  71710. forceFullscreenViewport: boolean;
  71711. /**
  71712. * List of inspectable custom properties (used by the Inspector)
  71713. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  71714. */
  71715. inspectableCustomProperties: IInspectable[];
  71716. /**
  71717. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  71718. *
  71719. * | Value | Type | Description |
  71720. * | ----- | ----------------------------------- | ----------- |
  71721. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  71722. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  71723. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  71724. *
  71725. */
  71726. scaleMode: number;
  71727. /**
  71728. * Force textures to be a power of two (default: false)
  71729. */
  71730. alwaysForcePOT: boolean;
  71731. private _samples;
  71732. /**
  71733. * Number of sample textures (default: 1)
  71734. */
  71735. samples: number;
  71736. /**
  71737. * Modify the scale of the post process to be the same as the viewport (default: false)
  71738. */
  71739. adaptScaleToCurrentViewport: boolean;
  71740. private _camera;
  71741. private _scene;
  71742. private _engine;
  71743. private _options;
  71744. private _reusable;
  71745. private _textureType;
  71746. /**
  71747. * Smart array of input and output textures for the post process.
  71748. * @hidden
  71749. */
  71750. _textures: SmartArray<InternalTexture>;
  71751. /**
  71752. * The index in _textures that corresponds to the output texture.
  71753. * @hidden
  71754. */
  71755. _currentRenderTextureInd: number;
  71756. private _effect;
  71757. private _samplers;
  71758. private _fragmentUrl;
  71759. private _vertexUrl;
  71760. private _parameters;
  71761. private _scaleRatio;
  71762. protected _indexParameters: any;
  71763. private _shareOutputWithPostProcess;
  71764. private _texelSize;
  71765. private _forcedOutputTexture;
  71766. /**
  71767. * Returns the fragment url or shader name used in the post process.
  71768. * @returns the fragment url or name in the shader store.
  71769. */
  71770. getEffectName(): string;
  71771. /**
  71772. * An event triggered when the postprocess is activated.
  71773. */
  71774. onActivateObservable: Observable<Camera>;
  71775. private _onActivateObserver;
  71776. /**
  71777. * A function that is added to the onActivateObservable
  71778. */
  71779. onActivate: Nullable<(camera: Camera) => void>;
  71780. /**
  71781. * An event triggered when the postprocess changes its size.
  71782. */
  71783. onSizeChangedObservable: Observable<PostProcess>;
  71784. private _onSizeChangedObserver;
  71785. /**
  71786. * A function that is added to the onSizeChangedObservable
  71787. */
  71788. onSizeChanged: (postProcess: PostProcess) => void;
  71789. /**
  71790. * An event triggered when the postprocess applies its effect.
  71791. */
  71792. onApplyObservable: Observable<Effect>;
  71793. private _onApplyObserver;
  71794. /**
  71795. * A function that is added to the onApplyObservable
  71796. */
  71797. onApply: (effect: Effect) => void;
  71798. /**
  71799. * An event triggered before rendering the postprocess
  71800. */
  71801. onBeforeRenderObservable: Observable<Effect>;
  71802. private _onBeforeRenderObserver;
  71803. /**
  71804. * A function that is added to the onBeforeRenderObservable
  71805. */
  71806. onBeforeRender: (effect: Effect) => void;
  71807. /**
  71808. * An event triggered after rendering the postprocess
  71809. */
  71810. onAfterRenderObservable: Observable<Effect>;
  71811. private _onAfterRenderObserver;
  71812. /**
  71813. * A function that is added to the onAfterRenderObservable
  71814. */
  71815. onAfterRender: (efect: Effect) => void;
  71816. /**
  71817. * 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
  71818. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  71819. */
  71820. inputTexture: InternalTexture;
  71821. /**
  71822. * Gets the camera which post process is applied to.
  71823. * @returns The camera the post process is applied to.
  71824. */
  71825. getCamera(): Camera;
  71826. /**
  71827. * Gets the texel size of the postprocess.
  71828. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  71829. */
  71830. readonly texelSize: Vector2;
  71831. /**
  71832. * Creates a new instance PostProcess
  71833. * @param name The name of the PostProcess.
  71834. * @param fragmentUrl The url of the fragment shader to be used.
  71835. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  71836. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  71837. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  71838. * @param camera The camera to apply the render pass to.
  71839. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71840. * @param engine The engine which the post process will be applied. (default: current engine)
  71841. * @param reusable If the post process can be reused on the same frame. (default: false)
  71842. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  71843. * @param textureType Type of textures used when performing the post process. (default: 0)
  71844. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  71845. * @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
  71846. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  71847. */
  71848. constructor(
  71849. /** Name of the PostProcess. */
  71850. 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);
  71851. /**
  71852. * Gets a string idenfifying the name of the class
  71853. * @returns "PostProcess" string
  71854. */
  71855. getClassName(): string;
  71856. /**
  71857. * Gets the engine which this post process belongs to.
  71858. * @returns The engine the post process was enabled with.
  71859. */
  71860. getEngine(): Engine;
  71861. /**
  71862. * The effect that is created when initializing the post process.
  71863. * @returns The created effect corrisponding the the postprocess.
  71864. */
  71865. getEffect(): Effect;
  71866. /**
  71867. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  71868. * @param postProcess The post process to share the output with.
  71869. * @returns This post process.
  71870. */
  71871. shareOutputWith(postProcess: PostProcess): PostProcess;
  71872. /**
  71873. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  71874. * This should be called if the post process that shares output with this post process is disabled/disposed.
  71875. */
  71876. useOwnOutput(): void;
  71877. /**
  71878. * Updates the effect with the current post process compile time values and recompiles the shader.
  71879. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  71880. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  71881. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  71882. * @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
  71883. * @param onCompiled Called when the shader has been compiled.
  71884. * @param onError Called if there is an error when compiling a shader.
  71885. */
  71886. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  71887. /**
  71888. * The post process is reusable if it can be used multiple times within one frame.
  71889. * @returns If the post process is reusable
  71890. */
  71891. isReusable(): boolean;
  71892. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  71893. markTextureDirty(): void;
  71894. /**
  71895. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  71896. * 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.
  71897. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  71898. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  71899. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  71900. * @returns The target texture that was bound to be written to.
  71901. */
  71902. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  71903. /**
  71904. * If the post process is supported.
  71905. */
  71906. readonly isSupported: boolean;
  71907. /**
  71908. * The aspect ratio of the output texture.
  71909. */
  71910. readonly aspectRatio: number;
  71911. /**
  71912. * Get a value indicating if the post-process is ready to be used
  71913. * @returns true if the post-process is ready (shader is compiled)
  71914. */
  71915. isReady(): boolean;
  71916. /**
  71917. * Binds all textures and uniforms to the shader, this will be run on every pass.
  71918. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  71919. */
  71920. apply(): Nullable<Effect>;
  71921. private _disposeTextures;
  71922. /**
  71923. * Disposes the post process.
  71924. * @param camera The camera to dispose the post process on.
  71925. */
  71926. dispose(camera?: Camera): void;
  71927. }
  71928. }
  71929. declare module BABYLON {
  71930. /**
  71931. * PostProcessManager is used to manage one or more post processes or post process pipelines
  71932. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71933. */
  71934. export class PostProcessManager {
  71935. private _scene;
  71936. private _indexBuffer;
  71937. private _vertexBuffers;
  71938. /**
  71939. * Creates a new instance PostProcess
  71940. * @param scene The scene that the post process is associated with.
  71941. */
  71942. constructor(scene: Scene);
  71943. private _prepareBuffers;
  71944. private _buildIndexBuffer;
  71945. /**
  71946. * Rebuilds the vertex buffers of the manager.
  71947. * @hidden
  71948. */
  71949. _rebuild(): void;
  71950. /**
  71951. * Prepares a frame to be run through a post process.
  71952. * @param sourceTexture The input texture to the post procesess. (default: null)
  71953. * @param postProcesses An array of post processes to be run. (default: null)
  71954. * @returns True if the post processes were able to be run.
  71955. * @hidden
  71956. */
  71957. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  71958. /**
  71959. * Manually render a set of post processes to a texture.
  71960. * @param postProcesses An array of post processes to be run.
  71961. * @param targetTexture The target texture to render to.
  71962. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  71963. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  71964. * @param lodLevel defines which lod of the texture to render to
  71965. */
  71966. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  71967. /**
  71968. * Finalize the result of the output of the postprocesses.
  71969. * @param doNotPresent If true the result will not be displayed to the screen.
  71970. * @param targetTexture The target texture to render to.
  71971. * @param faceIndex The index of the face to bind the target texture to.
  71972. * @param postProcesses The array of post processes to render.
  71973. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  71974. * @hidden
  71975. */
  71976. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  71977. /**
  71978. * Disposes of the post process manager.
  71979. */
  71980. dispose(): void;
  71981. }
  71982. }
  71983. declare module BABYLON {
  71984. interface AbstractScene {
  71985. /**
  71986. * The list of layers (background and foreground) of the scene
  71987. */
  71988. layers: Array<Layer>;
  71989. }
  71990. /**
  71991. * Defines the layer scene component responsible to manage any layers
  71992. * in a given scene.
  71993. */
  71994. export class LayerSceneComponent implements ISceneComponent {
  71995. /**
  71996. * The component name helpfull to identify the component in the list of scene components.
  71997. */
  71998. readonly name: string;
  71999. /**
  72000. * The scene the component belongs to.
  72001. */
  72002. scene: Scene;
  72003. private _engine;
  72004. /**
  72005. * Creates a new instance of the component for the given scene
  72006. * @param scene Defines the scene to register the component in
  72007. */
  72008. constructor(scene: Scene);
  72009. /**
  72010. * Registers the component in a given scene
  72011. */
  72012. register(): void;
  72013. /**
  72014. * Rebuilds the elements related to this component in case of
  72015. * context lost for instance.
  72016. */
  72017. rebuild(): void;
  72018. /**
  72019. * Disposes the component and the associated ressources.
  72020. */
  72021. dispose(): void;
  72022. private _draw;
  72023. private _drawCameraPredicate;
  72024. private _drawCameraBackground;
  72025. private _drawCameraForeground;
  72026. private _drawRenderTargetPredicate;
  72027. private _drawRenderTargetBackground;
  72028. private _drawRenderTargetForeground;
  72029. }
  72030. }
  72031. declare module BABYLON {
  72032. /** @hidden */
  72033. export var layerPixelShader: {
  72034. name: string;
  72035. shader: string;
  72036. };
  72037. }
  72038. declare module BABYLON {
  72039. /** @hidden */
  72040. export var layerVertexShader: {
  72041. name: string;
  72042. shader: string;
  72043. };
  72044. }
  72045. declare module BABYLON {
  72046. /**
  72047. * This represents a full screen 2d layer.
  72048. * This can be useful to display a picture in the background of your scene for instance.
  72049. * @see https://www.babylonjs-playground.com/#08A2BS#1
  72050. */
  72051. export class Layer {
  72052. /**
  72053. * Define the name of the layer.
  72054. */
  72055. name: string;
  72056. /**
  72057. * Define the texture the layer should display.
  72058. */
  72059. texture: Nullable<Texture>;
  72060. /**
  72061. * Is the layer in background or foreground.
  72062. */
  72063. isBackground: boolean;
  72064. /**
  72065. * Define the color of the layer (instead of texture).
  72066. */
  72067. color: Color4;
  72068. /**
  72069. * Define the scale of the layer in order to zoom in out of the texture.
  72070. */
  72071. scale: Vector2;
  72072. /**
  72073. * Define an offset for the layer in order to shift the texture.
  72074. */
  72075. offset: Vector2;
  72076. /**
  72077. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  72078. */
  72079. alphaBlendingMode: number;
  72080. /**
  72081. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  72082. * Alpha test will not mix with the background color in case of transparency.
  72083. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  72084. */
  72085. alphaTest: boolean;
  72086. /**
  72087. * Define a mask to restrict the layer to only some of the scene cameras.
  72088. */
  72089. layerMask: number;
  72090. /**
  72091. * Define the list of render target the layer is visible into.
  72092. */
  72093. renderTargetTextures: RenderTargetTexture[];
  72094. /**
  72095. * Define if the layer is only used in renderTarget or if it also
  72096. * renders in the main frame buffer of the canvas.
  72097. */
  72098. renderOnlyInRenderTargetTextures: boolean;
  72099. private _scene;
  72100. private _vertexBuffers;
  72101. private _indexBuffer;
  72102. private _effect;
  72103. private _alphaTestEffect;
  72104. /**
  72105. * An event triggered when the layer is disposed.
  72106. */
  72107. onDisposeObservable: Observable<Layer>;
  72108. private _onDisposeObserver;
  72109. /**
  72110. * Back compatibility with callback before the onDisposeObservable existed.
  72111. * The set callback will be triggered when the layer has been disposed.
  72112. */
  72113. onDispose: () => void;
  72114. /**
  72115. * An event triggered before rendering the scene
  72116. */
  72117. onBeforeRenderObservable: Observable<Layer>;
  72118. private _onBeforeRenderObserver;
  72119. /**
  72120. * Back compatibility with callback before the onBeforeRenderObservable existed.
  72121. * The set callback will be triggered just before rendering the layer.
  72122. */
  72123. onBeforeRender: () => void;
  72124. /**
  72125. * An event triggered after rendering the scene
  72126. */
  72127. onAfterRenderObservable: Observable<Layer>;
  72128. private _onAfterRenderObserver;
  72129. /**
  72130. * Back compatibility with callback before the onAfterRenderObservable existed.
  72131. * The set callback will be triggered just after rendering the layer.
  72132. */
  72133. onAfterRender: () => void;
  72134. /**
  72135. * Instantiates a new layer.
  72136. * This represents a full screen 2d layer.
  72137. * This can be useful to display a picture in the background of your scene for instance.
  72138. * @see https://www.babylonjs-playground.com/#08A2BS#1
  72139. * @param name Define the name of the layer in the scene
  72140. * @param imgUrl Define the url of the texture to display in the layer
  72141. * @param scene Define the scene the layer belongs to
  72142. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  72143. * @param color Defines a color for the layer
  72144. */
  72145. constructor(
  72146. /**
  72147. * Define the name of the layer.
  72148. */
  72149. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  72150. private _createIndexBuffer;
  72151. /** @hidden */
  72152. _rebuild(): void;
  72153. /**
  72154. * Renders the layer in the scene.
  72155. */
  72156. render(): void;
  72157. /**
  72158. * Disposes and releases the associated ressources.
  72159. */
  72160. dispose(): void;
  72161. }
  72162. }
  72163. declare module BABYLON {
  72164. interface AbstractScene {
  72165. /**
  72166. * The list of procedural textures added to the scene
  72167. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  72168. */
  72169. proceduralTextures: Array<ProceduralTexture>;
  72170. }
  72171. /**
  72172. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  72173. * in a given scene.
  72174. */
  72175. export class ProceduralTextureSceneComponent implements ISceneComponent {
  72176. /**
  72177. * The component name helpfull to identify the component in the list of scene components.
  72178. */
  72179. readonly name: string;
  72180. /**
  72181. * The scene the component belongs to.
  72182. */
  72183. scene: Scene;
  72184. /**
  72185. * Creates a new instance of the component for the given scene
  72186. * @param scene Defines the scene to register the component in
  72187. */
  72188. constructor(scene: Scene);
  72189. /**
  72190. * Registers the component in a given scene
  72191. */
  72192. register(): void;
  72193. /**
  72194. * Rebuilds the elements related to this component in case of
  72195. * context lost for instance.
  72196. */
  72197. rebuild(): void;
  72198. /**
  72199. * Disposes the component and the associated ressources.
  72200. */
  72201. dispose(): void;
  72202. private _beforeClear;
  72203. }
  72204. }
  72205. declare module BABYLON {
  72206. /** @hidden */
  72207. export var proceduralVertexShader: {
  72208. name: string;
  72209. shader: string;
  72210. };
  72211. }
  72212. declare module BABYLON {
  72213. /**
  72214. * 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.
  72215. * This is the base class of any Procedural texture and contains most of the shareable code.
  72216. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  72217. */
  72218. export class ProceduralTexture extends Texture {
  72219. isCube: boolean;
  72220. /**
  72221. * Define if the texture is enabled or not (disabled texture will not render)
  72222. */
  72223. isEnabled: boolean;
  72224. /**
  72225. * Define if the texture must be cleared before rendering (default is true)
  72226. */
  72227. autoClear: boolean;
  72228. /**
  72229. * Callback called when the texture is generated
  72230. */
  72231. onGenerated: () => void;
  72232. /**
  72233. * Event raised when the texture is generated
  72234. */
  72235. onGeneratedObservable: Observable<ProceduralTexture>;
  72236. /** @hidden */
  72237. _generateMipMaps: boolean;
  72238. /** @hidden **/
  72239. _effect: Effect;
  72240. /** @hidden */
  72241. _textures: {
  72242. [key: string]: Texture;
  72243. };
  72244. private _size;
  72245. private _currentRefreshId;
  72246. private _refreshRate;
  72247. private _vertexBuffers;
  72248. private _indexBuffer;
  72249. private _uniforms;
  72250. private _samplers;
  72251. private _fragment;
  72252. private _floats;
  72253. private _ints;
  72254. private _floatsArrays;
  72255. private _colors3;
  72256. private _colors4;
  72257. private _vectors2;
  72258. private _vectors3;
  72259. private _matrices;
  72260. private _fallbackTexture;
  72261. private _fallbackTextureUsed;
  72262. private _engine;
  72263. private _cachedDefines;
  72264. private _contentUpdateId;
  72265. private _contentData;
  72266. /**
  72267. * Instantiates a new procedural texture.
  72268. * 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.
  72269. * This is the base class of any Procedural texture and contains most of the shareable code.
  72270. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  72271. * @param name Define the name of the texture
  72272. * @param size Define the size of the texture to create
  72273. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  72274. * @param scene Define the scene the texture belongs to
  72275. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  72276. * @param generateMipMaps Define if the texture should creates mip maps or not
  72277. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  72278. */
  72279. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  72280. /**
  72281. * The effect that is created when initializing the post process.
  72282. * @returns The created effect corrisponding the the postprocess.
  72283. */
  72284. getEffect(): Effect;
  72285. /**
  72286. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  72287. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  72288. */
  72289. getContent(): Nullable<ArrayBufferView>;
  72290. private _createIndexBuffer;
  72291. /** @hidden */
  72292. _rebuild(): void;
  72293. /**
  72294. * Resets the texture in order to recreate its associated resources.
  72295. * This can be called in case of context loss
  72296. */
  72297. reset(): void;
  72298. protected _getDefines(): string;
  72299. /**
  72300. * Is the texture ready to be used ? (rendered at least once)
  72301. * @returns true if ready, otherwise, false.
  72302. */
  72303. isReady(): boolean;
  72304. /**
  72305. * Resets the refresh counter of the texture and start bak from scratch.
  72306. * Could be useful to regenerate the texture if it is setup to render only once.
  72307. */
  72308. resetRefreshCounter(): void;
  72309. /**
  72310. * Set the fragment shader to use in order to render the texture.
  72311. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  72312. */
  72313. setFragment(fragment: any): void;
  72314. /**
  72315. * Define the refresh rate of the texture or the rendering frequency.
  72316. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  72317. */
  72318. refreshRate: number;
  72319. /** @hidden */
  72320. _shouldRender(): boolean;
  72321. /**
  72322. * Get the size the texture is rendering at.
  72323. * @returns the size (texture is always squared)
  72324. */
  72325. getRenderSize(): number;
  72326. /**
  72327. * Resize the texture to new value.
  72328. * @param size Define the new size the texture should have
  72329. * @param generateMipMaps Define whether the new texture should create mip maps
  72330. */
  72331. resize(size: number, generateMipMaps: boolean): void;
  72332. private _checkUniform;
  72333. /**
  72334. * Set a texture in the shader program used to render.
  72335. * @param name Define the name of the uniform samplers as defined in the shader
  72336. * @param texture Define the texture to bind to this sampler
  72337. * @return the texture itself allowing "fluent" like uniform updates
  72338. */
  72339. setTexture(name: string, texture: Texture): ProceduralTexture;
  72340. /**
  72341. * Set a float in the shader.
  72342. * @param name Define the name of the uniform as defined in the shader
  72343. * @param value Define the value to give to the uniform
  72344. * @return the texture itself allowing "fluent" like uniform updates
  72345. */
  72346. setFloat(name: string, value: number): ProceduralTexture;
  72347. /**
  72348. * Set a int in the shader.
  72349. * @param name Define the name of the uniform as defined in the shader
  72350. * @param value Define the value to give to the uniform
  72351. * @return the texture itself allowing "fluent" like uniform updates
  72352. */
  72353. setInt(name: string, value: number): ProceduralTexture;
  72354. /**
  72355. * Set an array of floats in the shader.
  72356. * @param name Define the name of the uniform as defined in the shader
  72357. * @param value Define the value to give to the uniform
  72358. * @return the texture itself allowing "fluent" like uniform updates
  72359. */
  72360. setFloats(name: string, value: number[]): ProceduralTexture;
  72361. /**
  72362. * Set a vec3 in the shader from a Color3.
  72363. * @param name Define the name of the uniform as defined in the shader
  72364. * @param value Define the value to give to the uniform
  72365. * @return the texture itself allowing "fluent" like uniform updates
  72366. */
  72367. setColor3(name: string, value: Color3): ProceduralTexture;
  72368. /**
  72369. * Set a vec4 in the shader from a Color4.
  72370. * @param name Define the name of the uniform as defined in the shader
  72371. * @param value Define the value to give to the uniform
  72372. * @return the texture itself allowing "fluent" like uniform updates
  72373. */
  72374. setColor4(name: string, value: Color4): ProceduralTexture;
  72375. /**
  72376. * Set a vec2 in the shader from a Vector2.
  72377. * @param name Define the name of the uniform as defined in the shader
  72378. * @param value Define the value to give to the uniform
  72379. * @return the texture itself allowing "fluent" like uniform updates
  72380. */
  72381. setVector2(name: string, value: Vector2): ProceduralTexture;
  72382. /**
  72383. * Set a vec3 in the shader from a Vector3.
  72384. * @param name Define the name of the uniform as defined in the shader
  72385. * @param value Define the value to give to the uniform
  72386. * @return the texture itself allowing "fluent" like uniform updates
  72387. */
  72388. setVector3(name: string, value: Vector3): ProceduralTexture;
  72389. /**
  72390. * Set a mat4 in the shader from a MAtrix.
  72391. * @param name Define the name of the uniform as defined in the shader
  72392. * @param value Define the value to give to the uniform
  72393. * @return the texture itself allowing "fluent" like uniform updates
  72394. */
  72395. setMatrix(name: string, value: Matrix): ProceduralTexture;
  72396. /**
  72397. * Render the texture to its associated render target.
  72398. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  72399. */
  72400. render(useCameraPostProcess?: boolean): void;
  72401. /**
  72402. * Clone the texture.
  72403. * @returns the cloned texture
  72404. */
  72405. clone(): ProceduralTexture;
  72406. /**
  72407. * Dispose the texture and release its asoociated resources.
  72408. */
  72409. dispose(): void;
  72410. }
  72411. }
  72412. declare module BABYLON {
  72413. /**
  72414. * This represents the base class for particle system in Babylon.
  72415. * 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.
  72416. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  72417. * @example https://doc.babylonjs.com/babylon101/particles
  72418. */
  72419. export class BaseParticleSystem {
  72420. /**
  72421. * Source color is added to the destination color without alpha affecting the result
  72422. */
  72423. static BLENDMODE_ONEONE: number;
  72424. /**
  72425. * Blend current color and particle color using particle’s alpha
  72426. */
  72427. static BLENDMODE_STANDARD: number;
  72428. /**
  72429. * Add current color and particle color multiplied by particle’s alpha
  72430. */
  72431. static BLENDMODE_ADD: number;
  72432. /**
  72433. * Multiply current color with particle color
  72434. */
  72435. static BLENDMODE_MULTIPLY: number;
  72436. /**
  72437. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  72438. */
  72439. static BLENDMODE_MULTIPLYADD: number;
  72440. /**
  72441. * List of animations used by the particle system.
  72442. */
  72443. animations: Animation[];
  72444. /**
  72445. * The id of the Particle system.
  72446. */
  72447. id: string;
  72448. /**
  72449. * The friendly name of the Particle system.
  72450. */
  72451. name: string;
  72452. /**
  72453. * The rendering group used by the Particle system to chose when to render.
  72454. */
  72455. renderingGroupId: number;
  72456. /**
  72457. * The emitter represents the Mesh or position we are attaching the particle system to.
  72458. */
  72459. emitter: Nullable<AbstractMesh | Vector3>;
  72460. /**
  72461. * The maximum number of particles to emit per frame
  72462. */
  72463. emitRate: number;
  72464. /**
  72465. * If you want to launch only a few particles at once, that can be done, as well.
  72466. */
  72467. manualEmitCount: number;
  72468. /**
  72469. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  72470. */
  72471. updateSpeed: number;
  72472. /**
  72473. * The amount of time the particle system is running (depends of the overall update speed).
  72474. */
  72475. targetStopDuration: number;
  72476. /**
  72477. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  72478. */
  72479. disposeOnStop: boolean;
  72480. /**
  72481. * Minimum power of emitting particles.
  72482. */
  72483. minEmitPower: number;
  72484. /**
  72485. * Maximum power of emitting particles.
  72486. */
  72487. maxEmitPower: number;
  72488. /**
  72489. * Minimum life time of emitting particles.
  72490. */
  72491. minLifeTime: number;
  72492. /**
  72493. * Maximum life time of emitting particles.
  72494. */
  72495. maxLifeTime: number;
  72496. /**
  72497. * Minimum Size of emitting particles.
  72498. */
  72499. minSize: number;
  72500. /**
  72501. * Maximum Size of emitting particles.
  72502. */
  72503. maxSize: number;
  72504. /**
  72505. * Minimum scale of emitting particles on X axis.
  72506. */
  72507. minScaleX: number;
  72508. /**
  72509. * Maximum scale of emitting particles on X axis.
  72510. */
  72511. maxScaleX: number;
  72512. /**
  72513. * Minimum scale of emitting particles on Y axis.
  72514. */
  72515. minScaleY: number;
  72516. /**
  72517. * Maximum scale of emitting particles on Y axis.
  72518. */
  72519. maxScaleY: number;
  72520. /**
  72521. * Gets or sets the minimal initial rotation in radians.
  72522. */
  72523. minInitialRotation: number;
  72524. /**
  72525. * Gets or sets the maximal initial rotation in radians.
  72526. */
  72527. maxInitialRotation: number;
  72528. /**
  72529. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  72530. */
  72531. minAngularSpeed: number;
  72532. /**
  72533. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  72534. */
  72535. maxAngularSpeed: number;
  72536. /**
  72537. * The texture used to render each particle. (this can be a spritesheet)
  72538. */
  72539. particleTexture: Nullable<Texture>;
  72540. /**
  72541. * The layer mask we are rendering the particles through.
  72542. */
  72543. layerMask: number;
  72544. /**
  72545. * This can help using your own shader to render the particle system.
  72546. * The according effect will be created
  72547. */
  72548. customShader: any;
  72549. /**
  72550. * By default particle system starts as soon as they are created. This prevents the
  72551. * automatic start to happen and let you decide when to start emitting particles.
  72552. */
  72553. preventAutoStart: boolean;
  72554. private _noiseTexture;
  72555. /**
  72556. * Gets or sets a texture used to add random noise to particle positions
  72557. */
  72558. noiseTexture: Nullable<ProceduralTexture>;
  72559. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  72560. noiseStrength: Vector3;
  72561. /**
  72562. * Callback triggered when the particle animation is ending.
  72563. */
  72564. onAnimationEnd: Nullable<() => void>;
  72565. /**
  72566. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  72567. */
  72568. blendMode: number;
  72569. /**
  72570. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  72571. * to override the particles.
  72572. */
  72573. forceDepthWrite: boolean;
  72574. /** 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 */
  72575. preWarmCycles: number;
  72576. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  72577. preWarmStepOffset: number;
  72578. /**
  72579. * 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)
  72580. */
  72581. spriteCellChangeSpeed: number;
  72582. /**
  72583. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  72584. */
  72585. startSpriteCellID: number;
  72586. /**
  72587. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  72588. */
  72589. endSpriteCellID: number;
  72590. /**
  72591. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  72592. */
  72593. spriteCellWidth: number;
  72594. /**
  72595. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  72596. */
  72597. spriteCellHeight: number;
  72598. /**
  72599. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  72600. */
  72601. spriteRandomStartCell: boolean;
  72602. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  72603. translationPivot: Vector2;
  72604. /** @hidden */
  72605. protected _isAnimationSheetEnabled: boolean;
  72606. /**
  72607. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  72608. */
  72609. beginAnimationOnStart: boolean;
  72610. /**
  72611. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  72612. */
  72613. beginAnimationFrom: number;
  72614. /**
  72615. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  72616. */
  72617. beginAnimationTo: number;
  72618. /**
  72619. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  72620. */
  72621. beginAnimationLoop: boolean;
  72622. /**
  72623. * Gets or sets a world offset applied to all particles
  72624. */
  72625. worldOffset: Vector3;
  72626. /**
  72627. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  72628. */
  72629. isAnimationSheetEnabled: boolean;
  72630. /**
  72631. * Get hosting scene
  72632. * @returns the scene
  72633. */
  72634. getScene(): Scene;
  72635. /**
  72636. * You can use gravity if you want to give an orientation to your particles.
  72637. */
  72638. gravity: Vector3;
  72639. protected _colorGradients: Nullable<Array<ColorGradient>>;
  72640. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  72641. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  72642. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  72643. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  72644. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  72645. protected _dragGradients: Nullable<Array<FactorGradient>>;
  72646. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  72647. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  72648. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  72649. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  72650. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  72651. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  72652. /**
  72653. * Defines the delay in milliseconds before starting the system (0 by default)
  72654. */
  72655. startDelay: number;
  72656. /**
  72657. * Gets the current list of drag gradients.
  72658. * You must use addDragGradient and removeDragGradient to udpate this list
  72659. * @returns the list of drag gradients
  72660. */
  72661. getDragGradients(): Nullable<Array<FactorGradient>>;
  72662. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  72663. limitVelocityDamping: number;
  72664. /**
  72665. * Gets the current list of limit velocity gradients.
  72666. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  72667. * @returns the list of limit velocity gradients
  72668. */
  72669. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  72670. /**
  72671. * Gets the current list of color gradients.
  72672. * You must use addColorGradient and removeColorGradient to udpate this list
  72673. * @returns the list of color gradients
  72674. */
  72675. getColorGradients(): Nullable<Array<ColorGradient>>;
  72676. /**
  72677. * Gets the current list of size gradients.
  72678. * You must use addSizeGradient and removeSizeGradient to udpate this list
  72679. * @returns the list of size gradients
  72680. */
  72681. getSizeGradients(): Nullable<Array<FactorGradient>>;
  72682. /**
  72683. * Gets the current list of color remap gradients.
  72684. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  72685. * @returns the list of color remap gradients
  72686. */
  72687. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  72688. /**
  72689. * Gets the current list of alpha remap gradients.
  72690. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  72691. * @returns the list of alpha remap gradients
  72692. */
  72693. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  72694. /**
  72695. * Gets the current list of life time gradients.
  72696. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  72697. * @returns the list of life time gradients
  72698. */
  72699. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  72700. /**
  72701. * Gets the current list of angular speed gradients.
  72702. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  72703. * @returns the list of angular speed gradients
  72704. */
  72705. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  72706. /**
  72707. * Gets the current list of velocity gradients.
  72708. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  72709. * @returns the list of velocity gradients
  72710. */
  72711. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  72712. /**
  72713. * Gets the current list of start size gradients.
  72714. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  72715. * @returns the list of start size gradients
  72716. */
  72717. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  72718. /**
  72719. * Gets the current list of emit rate gradients.
  72720. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  72721. * @returns the list of emit rate gradients
  72722. */
  72723. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  72724. /**
  72725. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72726. * This only works when particleEmitterTyps is a BoxParticleEmitter
  72727. */
  72728. direction1: Vector3;
  72729. /**
  72730. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72731. * This only works when particleEmitterTyps is a BoxParticleEmitter
  72732. */
  72733. direction2: Vector3;
  72734. /**
  72735. * 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.
  72736. * This only works when particleEmitterTyps is a BoxParticleEmitter
  72737. */
  72738. minEmitBox: Vector3;
  72739. /**
  72740. * 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.
  72741. * This only works when particleEmitterTyps is a BoxParticleEmitter
  72742. */
  72743. maxEmitBox: Vector3;
  72744. /**
  72745. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  72746. */
  72747. color1: Color4;
  72748. /**
  72749. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  72750. */
  72751. color2: Color4;
  72752. /**
  72753. * Color the particle will have at the end of its lifetime
  72754. */
  72755. colorDead: Color4;
  72756. /**
  72757. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  72758. */
  72759. textureMask: Color4;
  72760. /**
  72761. * The particle emitter type defines the emitter used by the particle system.
  72762. * It can be for example box, sphere, or cone...
  72763. */
  72764. particleEmitterType: IParticleEmitterType;
  72765. /** @hidden */
  72766. _isSubEmitter: boolean;
  72767. /**
  72768. * Gets or sets the billboard mode to use when isBillboardBased = true.
  72769. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  72770. */
  72771. billboardMode: number;
  72772. protected _isBillboardBased: boolean;
  72773. /**
  72774. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  72775. */
  72776. isBillboardBased: boolean;
  72777. /**
  72778. * The scene the particle system belongs to.
  72779. */
  72780. protected _scene: Scene;
  72781. /**
  72782. * Local cache of defines for image processing.
  72783. */
  72784. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  72785. /**
  72786. * Default configuration related to image processing available in the standard Material.
  72787. */
  72788. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  72789. /**
  72790. * Gets the image processing configuration used either in this material.
  72791. */
  72792. /**
  72793. * Sets the Default image processing configuration used either in the this material.
  72794. *
  72795. * If sets to null, the scene one is in use.
  72796. */
  72797. imageProcessingConfiguration: ImageProcessingConfiguration;
  72798. /**
  72799. * Attaches a new image processing configuration to the Standard Material.
  72800. * @param configuration
  72801. */
  72802. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  72803. /** @hidden */
  72804. protected _reset(): void;
  72805. /** @hidden */
  72806. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  72807. /**
  72808. * Instantiates a particle system.
  72809. * 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.
  72810. * @param name The name of the particle system
  72811. */
  72812. constructor(name: string);
  72813. /**
  72814. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  72815. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  72816. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  72817. * @returns the emitter
  72818. */
  72819. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  72820. /**
  72821. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  72822. * @param radius The radius of the hemisphere to emit from
  72823. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  72824. * @returns the emitter
  72825. */
  72826. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  72827. /**
  72828. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  72829. * @param radius The radius of the sphere to emit from
  72830. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  72831. * @returns the emitter
  72832. */
  72833. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  72834. /**
  72835. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  72836. * @param radius The radius of the sphere to emit from
  72837. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  72838. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  72839. * @returns the emitter
  72840. */
  72841. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  72842. /**
  72843. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  72844. * @param radius The radius of the emission cylinder
  72845. * @param height The height of the emission cylinder
  72846. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  72847. * @param directionRandomizer How much to randomize the particle direction [0-1]
  72848. * @returns the emitter
  72849. */
  72850. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  72851. /**
  72852. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  72853. * @param radius The radius of the cylinder to emit from
  72854. * @param height The height of the emission cylinder
  72855. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72856. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  72857. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  72858. * @returns the emitter
  72859. */
  72860. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  72861. /**
  72862. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  72863. * @param radius The radius of the cone to emit from
  72864. * @param angle The base angle of the cone
  72865. * @returns the emitter
  72866. */
  72867. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  72868. /**
  72869. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  72870. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  72871. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  72872. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  72873. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  72874. * @returns the emitter
  72875. */
  72876. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  72877. }
  72878. }
  72879. declare module BABYLON {
  72880. /**
  72881. * Type of sub emitter
  72882. */
  72883. export enum SubEmitterType {
  72884. /**
  72885. * Attached to the particle over it's lifetime
  72886. */
  72887. ATTACHED = 0,
  72888. /**
  72889. * Created when the particle dies
  72890. */
  72891. END = 1
  72892. }
  72893. /**
  72894. * Sub emitter class used to emit particles from an existing particle
  72895. */
  72896. export class SubEmitter {
  72897. /**
  72898. * the particle system to be used by the sub emitter
  72899. */
  72900. particleSystem: ParticleSystem;
  72901. /**
  72902. * Type of the submitter (Default: END)
  72903. */
  72904. type: SubEmitterType;
  72905. /**
  72906. * 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)
  72907. * Note: This only is supported when using an emitter of type Mesh
  72908. */
  72909. inheritDirection: boolean;
  72910. /**
  72911. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  72912. */
  72913. inheritedVelocityAmount: number;
  72914. /**
  72915. * Creates a sub emitter
  72916. * @param particleSystem the particle system to be used by the sub emitter
  72917. */
  72918. constructor(
  72919. /**
  72920. * the particle system to be used by the sub emitter
  72921. */
  72922. particleSystem: ParticleSystem);
  72923. /**
  72924. * Clones the sub emitter
  72925. * @returns the cloned sub emitter
  72926. */
  72927. clone(): SubEmitter;
  72928. /**
  72929. * Serialize current object to a JSON object
  72930. * @returns the serialized object
  72931. */
  72932. serialize(): any;
  72933. /** @hidden */
  72934. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  72935. /**
  72936. * Creates a new SubEmitter from a serialized JSON version
  72937. * @param serializationObject defines the JSON object to read from
  72938. * @param scene defines the hosting scene
  72939. * @param rootUrl defines the rootUrl for data loading
  72940. * @returns a new SubEmitter
  72941. */
  72942. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  72943. /** Release associated resources */
  72944. dispose(): void;
  72945. }
  72946. }
  72947. declare module BABYLON {
  72948. /** @hidden */
  72949. export var clipPlaneFragmentDeclaration: {
  72950. name: string;
  72951. shader: string;
  72952. };
  72953. }
  72954. declare module BABYLON {
  72955. /** @hidden */
  72956. export var imageProcessingDeclaration: {
  72957. name: string;
  72958. shader: string;
  72959. };
  72960. }
  72961. declare module BABYLON {
  72962. /** @hidden */
  72963. export var imageProcessingFunctions: {
  72964. name: string;
  72965. shader: string;
  72966. };
  72967. }
  72968. declare module BABYLON {
  72969. /** @hidden */
  72970. export var clipPlaneFragment: {
  72971. name: string;
  72972. shader: string;
  72973. };
  72974. }
  72975. declare module BABYLON {
  72976. /** @hidden */
  72977. export var particlesPixelShader: {
  72978. name: string;
  72979. shader: string;
  72980. };
  72981. }
  72982. declare module BABYLON {
  72983. /** @hidden */
  72984. export var clipPlaneVertexDeclaration: {
  72985. name: string;
  72986. shader: string;
  72987. };
  72988. }
  72989. declare module BABYLON {
  72990. /** @hidden */
  72991. export var clipPlaneVertex: {
  72992. name: string;
  72993. shader: string;
  72994. };
  72995. }
  72996. declare module BABYLON {
  72997. /** @hidden */
  72998. export var particlesVertexShader: {
  72999. name: string;
  73000. shader: string;
  73001. };
  73002. }
  73003. declare module BABYLON {
  73004. /**
  73005. * This represents a particle system in Babylon.
  73006. * 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.
  73007. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  73008. * @example https://doc.babylonjs.com/babylon101/particles
  73009. */
  73010. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  73011. /**
  73012. * Billboard mode will only apply to Y axis
  73013. */
  73014. static readonly BILLBOARDMODE_Y: number;
  73015. /**
  73016. * Billboard mode will apply to all axes
  73017. */
  73018. static readonly BILLBOARDMODE_ALL: number;
  73019. /**
  73020. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  73021. */
  73022. static readonly BILLBOARDMODE_STRETCHED: number;
  73023. /**
  73024. * This function can be defined to provide custom update for active particles.
  73025. * This function will be called instead of regular update (age, position, color, etc.).
  73026. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  73027. */
  73028. updateFunction: (particles: Particle[]) => void;
  73029. private _emitterWorldMatrix;
  73030. /**
  73031. * This function can be defined to specify initial direction for every new particle.
  73032. * It by default use the emitterType defined function
  73033. */
  73034. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  73035. /**
  73036. * This function can be defined to specify initial position for every new particle.
  73037. * It by default use the emitterType defined function
  73038. */
  73039. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  73040. /**
  73041. * @hidden
  73042. */
  73043. _inheritedVelocityOffset: Vector3;
  73044. /**
  73045. * An event triggered when the system is disposed
  73046. */
  73047. onDisposeObservable: Observable<ParticleSystem>;
  73048. private _onDisposeObserver;
  73049. /**
  73050. * Sets a callback that will be triggered when the system is disposed
  73051. */
  73052. onDispose: () => void;
  73053. private _particles;
  73054. private _epsilon;
  73055. private _capacity;
  73056. private _stockParticles;
  73057. private _newPartsExcess;
  73058. private _vertexData;
  73059. private _vertexBuffer;
  73060. private _vertexBuffers;
  73061. private _spriteBuffer;
  73062. private _indexBuffer;
  73063. private _effect;
  73064. private _customEffect;
  73065. private _cachedDefines;
  73066. private _scaledColorStep;
  73067. private _colorDiff;
  73068. private _scaledDirection;
  73069. private _scaledGravity;
  73070. private _currentRenderId;
  73071. private _alive;
  73072. private _useInstancing;
  73073. private _started;
  73074. private _stopped;
  73075. private _actualFrame;
  73076. private _scaledUpdateSpeed;
  73077. private _vertexBufferSize;
  73078. /** @hidden */
  73079. _currentEmitRateGradient: Nullable<FactorGradient>;
  73080. /** @hidden */
  73081. _currentEmitRate1: number;
  73082. /** @hidden */
  73083. _currentEmitRate2: number;
  73084. /** @hidden */
  73085. _currentStartSizeGradient: Nullable<FactorGradient>;
  73086. /** @hidden */
  73087. _currentStartSize1: number;
  73088. /** @hidden */
  73089. _currentStartSize2: number;
  73090. private readonly _rawTextureWidth;
  73091. private _rampGradientsTexture;
  73092. private _useRampGradients;
  73093. /** Gets or sets a boolean indicating that ramp gradients must be used
  73094. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  73095. */
  73096. useRampGradients: boolean;
  73097. /**
  73098. * 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.
  73099. * 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: [])
  73100. */
  73101. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  73102. private _subEmitters;
  73103. /**
  73104. * @hidden
  73105. * If the particle systems emitter should be disposed when the particle system is disposed
  73106. */
  73107. _disposeEmitterOnDispose: boolean;
  73108. /**
  73109. * The current active Sub-systems, this property is used by the root particle system only.
  73110. */
  73111. activeSubSystems: Array<ParticleSystem>;
  73112. private _rootParticleSystem;
  73113. /**
  73114. * Gets the current list of active particles
  73115. */
  73116. readonly particles: Particle[];
  73117. /**
  73118. * Returns the string "ParticleSystem"
  73119. * @returns a string containing the class name
  73120. */
  73121. getClassName(): string;
  73122. /**
  73123. * Instantiates a particle system.
  73124. * 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.
  73125. * @param name The name of the particle system
  73126. * @param capacity The max number of particles alive at the same time
  73127. * @param scene The scene the particle system belongs to
  73128. * @param customEffect a custom effect used to change the way particles are rendered by default
  73129. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  73130. * @param epsilon Offset used to render the particles
  73131. */
  73132. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  73133. private _addFactorGradient;
  73134. private _removeFactorGradient;
  73135. /**
  73136. * Adds a new life time gradient
  73137. * @param gradient defines the gradient to use (between 0 and 1)
  73138. * @param factor defines the life time factor to affect to the specified gradient
  73139. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73140. * @returns the current particle system
  73141. */
  73142. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73143. /**
  73144. * Remove a specific life time gradient
  73145. * @param gradient defines the gradient to remove
  73146. * @returns the current particle system
  73147. */
  73148. removeLifeTimeGradient(gradient: number): IParticleSystem;
  73149. /**
  73150. * Adds a new size gradient
  73151. * @param gradient defines the gradient to use (between 0 and 1)
  73152. * @param factor defines the size factor to affect to the specified gradient
  73153. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73154. * @returns the current particle system
  73155. */
  73156. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73157. /**
  73158. * Remove a specific size gradient
  73159. * @param gradient defines the gradient to remove
  73160. * @returns the current particle system
  73161. */
  73162. removeSizeGradient(gradient: number): IParticleSystem;
  73163. /**
  73164. * Adds a new color remap gradient
  73165. * @param gradient defines the gradient to use (between 0 and 1)
  73166. * @param min defines the color remap minimal range
  73167. * @param max defines the color remap maximal range
  73168. * @returns the current particle system
  73169. */
  73170. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73171. /**
  73172. * Remove a specific color remap gradient
  73173. * @param gradient defines the gradient to remove
  73174. * @returns the current particle system
  73175. */
  73176. removeColorRemapGradient(gradient: number): IParticleSystem;
  73177. /**
  73178. * Adds a new alpha remap gradient
  73179. * @param gradient defines the gradient to use (between 0 and 1)
  73180. * @param min defines the alpha remap minimal range
  73181. * @param max defines the alpha remap maximal range
  73182. * @returns the current particle system
  73183. */
  73184. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73185. /**
  73186. * Remove a specific alpha remap gradient
  73187. * @param gradient defines the gradient to remove
  73188. * @returns the current particle system
  73189. */
  73190. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  73191. /**
  73192. * Adds a new angular speed gradient
  73193. * @param gradient defines the gradient to use (between 0 and 1)
  73194. * @param factor defines the angular speed to affect to the specified gradient
  73195. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73196. * @returns the current particle system
  73197. */
  73198. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73199. /**
  73200. * Remove a specific angular speed gradient
  73201. * @param gradient defines the gradient to remove
  73202. * @returns the current particle system
  73203. */
  73204. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  73205. /**
  73206. * Adds a new velocity gradient
  73207. * @param gradient defines the gradient to use (between 0 and 1)
  73208. * @param factor defines the velocity to affect to the specified gradient
  73209. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73210. * @returns the current particle system
  73211. */
  73212. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73213. /**
  73214. * Remove a specific velocity gradient
  73215. * @param gradient defines the gradient to remove
  73216. * @returns the current particle system
  73217. */
  73218. removeVelocityGradient(gradient: number): IParticleSystem;
  73219. /**
  73220. * Adds a new limit velocity gradient
  73221. * @param gradient defines the gradient to use (between 0 and 1)
  73222. * @param factor defines the limit velocity value to affect to the specified gradient
  73223. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73224. * @returns the current particle system
  73225. */
  73226. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73227. /**
  73228. * Remove a specific limit velocity gradient
  73229. * @param gradient defines the gradient to remove
  73230. * @returns the current particle system
  73231. */
  73232. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  73233. /**
  73234. * Adds a new drag gradient
  73235. * @param gradient defines the gradient to use (between 0 and 1)
  73236. * @param factor defines the drag value to affect to the specified gradient
  73237. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73238. * @returns the current particle system
  73239. */
  73240. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73241. /**
  73242. * Remove a specific drag gradient
  73243. * @param gradient defines the gradient to remove
  73244. * @returns the current particle system
  73245. */
  73246. removeDragGradient(gradient: number): IParticleSystem;
  73247. /**
  73248. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  73249. * @param gradient defines the gradient to use (between 0 and 1)
  73250. * @param factor defines the emit rate value to affect to the specified gradient
  73251. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73252. * @returns the current particle system
  73253. */
  73254. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73255. /**
  73256. * Remove a specific emit rate gradient
  73257. * @param gradient defines the gradient to remove
  73258. * @returns the current particle system
  73259. */
  73260. removeEmitRateGradient(gradient: number): IParticleSystem;
  73261. /**
  73262. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  73263. * @param gradient defines the gradient to use (between 0 and 1)
  73264. * @param factor defines the start size value to affect to the specified gradient
  73265. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73266. * @returns the current particle system
  73267. */
  73268. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73269. /**
  73270. * Remove a specific start size gradient
  73271. * @param gradient defines the gradient to remove
  73272. * @returns the current particle system
  73273. */
  73274. removeStartSizeGradient(gradient: number): IParticleSystem;
  73275. private _createRampGradientTexture;
  73276. /**
  73277. * Gets the current list of ramp gradients.
  73278. * You must use addRampGradient and removeRampGradient to udpate this list
  73279. * @returns the list of ramp gradients
  73280. */
  73281. getRampGradients(): Nullable<Array<Color3Gradient>>;
  73282. /**
  73283. * Adds a new ramp gradient used to remap particle colors
  73284. * @param gradient defines the gradient to use (between 0 and 1)
  73285. * @param color defines the color to affect to the specified gradient
  73286. * @returns the current particle system
  73287. */
  73288. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  73289. /**
  73290. * Remove a specific ramp gradient
  73291. * @param gradient defines the gradient to remove
  73292. * @returns the current particle system
  73293. */
  73294. removeRampGradient(gradient: number): ParticleSystem;
  73295. /**
  73296. * Adds a new color gradient
  73297. * @param gradient defines the gradient to use (between 0 and 1)
  73298. * @param color1 defines the color to affect to the specified gradient
  73299. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  73300. * @returns this particle system
  73301. */
  73302. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  73303. /**
  73304. * Remove a specific color gradient
  73305. * @param gradient defines the gradient to remove
  73306. * @returns this particle system
  73307. */
  73308. removeColorGradient(gradient: number): IParticleSystem;
  73309. private _fetchR;
  73310. protected _reset(): void;
  73311. private _resetEffect;
  73312. private _createVertexBuffers;
  73313. private _createIndexBuffer;
  73314. /**
  73315. * Gets the maximum number of particles active at the same time.
  73316. * @returns The max number of active particles.
  73317. */
  73318. getCapacity(): number;
  73319. /**
  73320. * Gets whether there are still active particles in the system.
  73321. * @returns True if it is alive, otherwise false.
  73322. */
  73323. isAlive(): boolean;
  73324. /**
  73325. * Gets if the system has been started. (Note: this will still be true after stop is called)
  73326. * @returns True if it has been started, otherwise false.
  73327. */
  73328. isStarted(): boolean;
  73329. private _prepareSubEmitterInternalArray;
  73330. /**
  73331. * Starts the particle system and begins to emit
  73332. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  73333. */
  73334. start(delay?: number): void;
  73335. /**
  73336. * Stops the particle system.
  73337. * @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.
  73338. */
  73339. stop(stopSubEmitters?: boolean): void;
  73340. /**
  73341. * Remove all active particles
  73342. */
  73343. reset(): void;
  73344. /**
  73345. * @hidden (for internal use only)
  73346. */
  73347. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  73348. /**
  73349. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  73350. * Its lifetime will start back at 0.
  73351. */
  73352. recycleParticle: (particle: Particle) => void;
  73353. private _stopSubEmitters;
  73354. private _createParticle;
  73355. private _removeFromRoot;
  73356. private _emitFromParticle;
  73357. private _update;
  73358. /** @hidden */
  73359. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  73360. /** @hidden */
  73361. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  73362. /** @hidden */
  73363. private _getEffect;
  73364. /**
  73365. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  73366. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  73367. */
  73368. animate(preWarmOnly?: boolean): void;
  73369. private _appendParticleVertices;
  73370. /**
  73371. * Rebuilds the particle system.
  73372. */
  73373. rebuild(): void;
  73374. /**
  73375. * Is this system ready to be used/rendered
  73376. * @return true if the system is ready
  73377. */
  73378. isReady(): boolean;
  73379. private _render;
  73380. /**
  73381. * Renders the particle system in its current state.
  73382. * @returns the current number of particles
  73383. */
  73384. render(): number;
  73385. /**
  73386. * Disposes the particle system and free the associated resources
  73387. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  73388. */
  73389. dispose(disposeTexture?: boolean): void;
  73390. /**
  73391. * Clones the particle system.
  73392. * @param name The name of the cloned object
  73393. * @param newEmitter The new emitter to use
  73394. * @returns the cloned particle system
  73395. */
  73396. clone(name: string, newEmitter: any): ParticleSystem;
  73397. /**
  73398. * Serializes the particle system to a JSON object.
  73399. * @returns the JSON object
  73400. */
  73401. serialize(): any;
  73402. /** @hidden */
  73403. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  73404. /** @hidden */
  73405. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  73406. /**
  73407. * Parses a JSON object to create a particle system.
  73408. * @param parsedParticleSystem The JSON object to parse
  73409. * @param scene The scene to create the particle system in
  73410. * @param rootUrl The root url to use to load external dependencies like texture
  73411. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  73412. * @returns the Parsed particle system
  73413. */
  73414. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  73415. }
  73416. }
  73417. declare module BABYLON {
  73418. /**
  73419. * A particle represents one of the element emitted by a particle system.
  73420. * This is mainly define by its coordinates, direction, velocity and age.
  73421. */
  73422. export class Particle {
  73423. /**
  73424. * The particle system the particle belongs to.
  73425. */
  73426. particleSystem: ParticleSystem;
  73427. private static _Count;
  73428. /**
  73429. * Unique ID of the particle
  73430. */
  73431. id: number;
  73432. /**
  73433. * The world position of the particle in the scene.
  73434. */
  73435. position: Vector3;
  73436. /**
  73437. * The world direction of the particle in the scene.
  73438. */
  73439. direction: Vector3;
  73440. /**
  73441. * The color of the particle.
  73442. */
  73443. color: Color4;
  73444. /**
  73445. * The color change of the particle per step.
  73446. */
  73447. colorStep: Color4;
  73448. /**
  73449. * Defines how long will the life of the particle be.
  73450. */
  73451. lifeTime: number;
  73452. /**
  73453. * The current age of the particle.
  73454. */
  73455. age: number;
  73456. /**
  73457. * The current size of the particle.
  73458. */
  73459. size: number;
  73460. /**
  73461. * The current scale of the particle.
  73462. */
  73463. scale: Vector2;
  73464. /**
  73465. * The current angle of the particle.
  73466. */
  73467. angle: number;
  73468. /**
  73469. * Defines how fast is the angle changing.
  73470. */
  73471. angularSpeed: number;
  73472. /**
  73473. * Defines the cell index used by the particle to be rendered from a sprite.
  73474. */
  73475. cellIndex: number;
  73476. /**
  73477. * The information required to support color remapping
  73478. */
  73479. remapData: Vector4;
  73480. /** @hidden */
  73481. _randomCellOffset?: number;
  73482. /** @hidden */
  73483. _initialDirection: Nullable<Vector3>;
  73484. /** @hidden */
  73485. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  73486. /** @hidden */
  73487. _initialStartSpriteCellID: number;
  73488. /** @hidden */
  73489. _initialEndSpriteCellID: number;
  73490. /** @hidden */
  73491. _currentColorGradient: Nullable<ColorGradient>;
  73492. /** @hidden */
  73493. _currentColor1: Color4;
  73494. /** @hidden */
  73495. _currentColor2: Color4;
  73496. /** @hidden */
  73497. _currentSizeGradient: Nullable<FactorGradient>;
  73498. /** @hidden */
  73499. _currentSize1: number;
  73500. /** @hidden */
  73501. _currentSize2: number;
  73502. /** @hidden */
  73503. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  73504. /** @hidden */
  73505. _currentAngularSpeed1: number;
  73506. /** @hidden */
  73507. _currentAngularSpeed2: number;
  73508. /** @hidden */
  73509. _currentVelocityGradient: Nullable<FactorGradient>;
  73510. /** @hidden */
  73511. _currentVelocity1: number;
  73512. /** @hidden */
  73513. _currentVelocity2: number;
  73514. /** @hidden */
  73515. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  73516. /** @hidden */
  73517. _currentLimitVelocity1: number;
  73518. /** @hidden */
  73519. _currentLimitVelocity2: number;
  73520. /** @hidden */
  73521. _currentDragGradient: Nullable<FactorGradient>;
  73522. /** @hidden */
  73523. _currentDrag1: number;
  73524. /** @hidden */
  73525. _currentDrag2: number;
  73526. /** @hidden */
  73527. _randomNoiseCoordinates1: Vector3;
  73528. /** @hidden */
  73529. _randomNoiseCoordinates2: Vector3;
  73530. /**
  73531. * Creates a new instance Particle
  73532. * @param particleSystem the particle system the particle belongs to
  73533. */
  73534. constructor(
  73535. /**
  73536. * The particle system the particle belongs to.
  73537. */
  73538. particleSystem: ParticleSystem);
  73539. private updateCellInfoFromSystem;
  73540. /**
  73541. * Defines how the sprite cell index is updated for the particle
  73542. */
  73543. updateCellIndex(): void;
  73544. /** @hidden */
  73545. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  73546. /** @hidden */
  73547. _inheritParticleInfoToSubEmitters(): void;
  73548. /** @hidden */
  73549. _reset(): void;
  73550. /**
  73551. * Copy the properties of particle to another one.
  73552. * @param other the particle to copy the information to.
  73553. */
  73554. copyTo(other: Particle): void;
  73555. }
  73556. }
  73557. declare module BABYLON {
  73558. /**
  73559. * Particle emitter represents a volume emitting particles.
  73560. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  73561. */
  73562. export interface IParticleEmitterType {
  73563. /**
  73564. * Called by the particle System when the direction is computed for the created particle.
  73565. * @param worldMatrix is the world matrix of the particle system
  73566. * @param directionToUpdate is the direction vector to update with the result
  73567. * @param particle is the particle we are computed the direction for
  73568. */
  73569. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73570. /**
  73571. * Called by the particle System when the position is computed for the created particle.
  73572. * @param worldMatrix is the world matrix of the particle system
  73573. * @param positionToUpdate is the position vector to update with the result
  73574. * @param particle is the particle we are computed the position for
  73575. */
  73576. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73577. /**
  73578. * Clones the current emitter and returns a copy of it
  73579. * @returns the new emitter
  73580. */
  73581. clone(): IParticleEmitterType;
  73582. /**
  73583. * Called by the GPUParticleSystem to setup the update shader
  73584. * @param effect defines the update shader
  73585. */
  73586. applyToShader(effect: Effect): void;
  73587. /**
  73588. * Returns a string to use to update the GPU particles update shader
  73589. * @returns the effect defines string
  73590. */
  73591. getEffectDefines(): string;
  73592. /**
  73593. * Returns a string representing the class name
  73594. * @returns a string containing the class name
  73595. */
  73596. getClassName(): string;
  73597. /**
  73598. * Serializes the particle system to a JSON object.
  73599. * @returns the JSON object
  73600. */
  73601. serialize(): any;
  73602. /**
  73603. * Parse properties from a JSON object
  73604. * @param serializationObject defines the JSON object
  73605. */
  73606. parse(serializationObject: any): void;
  73607. }
  73608. }
  73609. declare module BABYLON {
  73610. /**
  73611. * Particle emitter emitting particles from the inside of a box.
  73612. * It emits the particles randomly between 2 given directions.
  73613. */
  73614. export class BoxParticleEmitter implements IParticleEmitterType {
  73615. /**
  73616. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73617. */
  73618. direction1: Vector3;
  73619. /**
  73620. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73621. */
  73622. direction2: Vector3;
  73623. /**
  73624. * 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.
  73625. */
  73626. minEmitBox: Vector3;
  73627. /**
  73628. * 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.
  73629. */
  73630. maxEmitBox: Vector3;
  73631. /**
  73632. * Creates a new instance BoxParticleEmitter
  73633. */
  73634. constructor();
  73635. /**
  73636. * Called by the particle System when the direction is computed for the created particle.
  73637. * @param worldMatrix is the world matrix of the particle system
  73638. * @param directionToUpdate is the direction vector to update with the result
  73639. * @param particle is the particle we are computed the direction for
  73640. */
  73641. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73642. /**
  73643. * Called by the particle System when the position is computed for the created particle.
  73644. * @param worldMatrix is the world matrix of the particle system
  73645. * @param positionToUpdate is the position vector to update with the result
  73646. * @param particle is the particle we are computed the position for
  73647. */
  73648. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73649. /**
  73650. * Clones the current emitter and returns a copy of it
  73651. * @returns the new emitter
  73652. */
  73653. clone(): BoxParticleEmitter;
  73654. /**
  73655. * Called by the GPUParticleSystem to setup the update shader
  73656. * @param effect defines the update shader
  73657. */
  73658. applyToShader(effect: Effect): void;
  73659. /**
  73660. * Returns a string to use to update the GPU particles update shader
  73661. * @returns a string containng the defines string
  73662. */
  73663. getEffectDefines(): string;
  73664. /**
  73665. * Returns the string "BoxParticleEmitter"
  73666. * @returns a string containing the class name
  73667. */
  73668. getClassName(): string;
  73669. /**
  73670. * Serializes the particle system to a JSON object.
  73671. * @returns the JSON object
  73672. */
  73673. serialize(): any;
  73674. /**
  73675. * Parse properties from a JSON object
  73676. * @param serializationObject defines the JSON object
  73677. */
  73678. parse(serializationObject: any): void;
  73679. }
  73680. }
  73681. declare module BABYLON {
  73682. /**
  73683. * Particle emitter emitting particles from the inside of a cone.
  73684. * It emits the particles alongside the cone volume from the base to the particle.
  73685. * The emission direction might be randomized.
  73686. */
  73687. export class ConeParticleEmitter implements IParticleEmitterType {
  73688. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  73689. directionRandomizer: number;
  73690. private _radius;
  73691. private _angle;
  73692. private _height;
  73693. /**
  73694. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  73695. */
  73696. radiusRange: number;
  73697. /**
  73698. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  73699. */
  73700. heightRange: number;
  73701. /**
  73702. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  73703. */
  73704. emitFromSpawnPointOnly: boolean;
  73705. /**
  73706. * Gets or sets the radius of the emission cone
  73707. */
  73708. radius: number;
  73709. /**
  73710. * Gets or sets the angle of the emission cone
  73711. */
  73712. angle: number;
  73713. private _buildHeight;
  73714. /**
  73715. * Creates a new instance ConeParticleEmitter
  73716. * @param radius the radius of the emission cone (1 by default)
  73717. * @param angle the cone base angle (PI by default)
  73718. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  73719. */
  73720. constructor(radius?: number, angle?: number,
  73721. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  73722. directionRandomizer?: number);
  73723. /**
  73724. * Called by the particle System when the direction is computed for the created particle.
  73725. * @param worldMatrix is the world matrix of the particle system
  73726. * @param directionToUpdate is the direction vector to update with the result
  73727. * @param particle is the particle we are computed the direction for
  73728. */
  73729. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73730. /**
  73731. * Called by the particle System when the position is computed for the created particle.
  73732. * @param worldMatrix is the world matrix of the particle system
  73733. * @param positionToUpdate is the position vector to update with the result
  73734. * @param particle is the particle we are computed the position for
  73735. */
  73736. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73737. /**
  73738. * Clones the current emitter and returns a copy of it
  73739. * @returns the new emitter
  73740. */
  73741. clone(): ConeParticleEmitter;
  73742. /**
  73743. * Called by the GPUParticleSystem to setup the update shader
  73744. * @param effect defines the update shader
  73745. */
  73746. applyToShader(effect: Effect): void;
  73747. /**
  73748. * Returns a string to use to update the GPU particles update shader
  73749. * @returns a string containng the defines string
  73750. */
  73751. getEffectDefines(): string;
  73752. /**
  73753. * Returns the string "ConeParticleEmitter"
  73754. * @returns a string containing the class name
  73755. */
  73756. getClassName(): string;
  73757. /**
  73758. * Serializes the particle system to a JSON object.
  73759. * @returns the JSON object
  73760. */
  73761. serialize(): any;
  73762. /**
  73763. * Parse properties from a JSON object
  73764. * @param serializationObject defines the JSON object
  73765. */
  73766. parse(serializationObject: any): void;
  73767. }
  73768. }
  73769. declare module BABYLON {
  73770. /**
  73771. * Particle emitter emitting particles from the inside of a cylinder.
  73772. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  73773. */
  73774. export class CylinderParticleEmitter implements IParticleEmitterType {
  73775. /**
  73776. * The radius of the emission cylinder.
  73777. */
  73778. radius: number;
  73779. /**
  73780. * The height of the emission cylinder.
  73781. */
  73782. height: number;
  73783. /**
  73784. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73785. */
  73786. radiusRange: number;
  73787. /**
  73788. * How much to randomize the particle direction [0-1].
  73789. */
  73790. directionRandomizer: number;
  73791. /**
  73792. * Creates a new instance CylinderParticleEmitter
  73793. * @param radius the radius of the emission cylinder (1 by default)
  73794. * @param height the height of the emission cylinder (1 by default)
  73795. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73796. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  73797. */
  73798. constructor(
  73799. /**
  73800. * The radius of the emission cylinder.
  73801. */
  73802. radius?: number,
  73803. /**
  73804. * The height of the emission cylinder.
  73805. */
  73806. height?: number,
  73807. /**
  73808. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73809. */
  73810. radiusRange?: number,
  73811. /**
  73812. * How much to randomize the particle direction [0-1].
  73813. */
  73814. directionRandomizer?: number);
  73815. /**
  73816. * Called by the particle System when the direction is computed for the created particle.
  73817. * @param worldMatrix is the world matrix of the particle system
  73818. * @param directionToUpdate is the direction vector to update with the result
  73819. * @param particle is the particle we are computed the direction for
  73820. */
  73821. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73822. /**
  73823. * Called by the particle System when the position is computed for the created particle.
  73824. * @param worldMatrix is the world matrix of the particle system
  73825. * @param positionToUpdate is the position vector to update with the result
  73826. * @param particle is the particle we are computed the position for
  73827. */
  73828. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73829. /**
  73830. * Clones the current emitter and returns a copy of it
  73831. * @returns the new emitter
  73832. */
  73833. clone(): CylinderParticleEmitter;
  73834. /**
  73835. * Called by the GPUParticleSystem to setup the update shader
  73836. * @param effect defines the update shader
  73837. */
  73838. applyToShader(effect: Effect): void;
  73839. /**
  73840. * Returns a string to use to update the GPU particles update shader
  73841. * @returns a string containng the defines string
  73842. */
  73843. getEffectDefines(): string;
  73844. /**
  73845. * Returns the string "CylinderParticleEmitter"
  73846. * @returns a string containing the class name
  73847. */
  73848. getClassName(): string;
  73849. /**
  73850. * Serializes the particle system to a JSON object.
  73851. * @returns the JSON object
  73852. */
  73853. serialize(): any;
  73854. /**
  73855. * Parse properties from a JSON object
  73856. * @param serializationObject defines the JSON object
  73857. */
  73858. parse(serializationObject: any): void;
  73859. }
  73860. /**
  73861. * Particle emitter emitting particles from the inside of a cylinder.
  73862. * It emits the particles randomly between two vectors.
  73863. */
  73864. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  73865. /**
  73866. * The min limit of the emission direction.
  73867. */
  73868. direction1: Vector3;
  73869. /**
  73870. * The max limit of the emission direction.
  73871. */
  73872. direction2: Vector3;
  73873. /**
  73874. * Creates a new instance CylinderDirectedParticleEmitter
  73875. * @param radius the radius of the emission cylinder (1 by default)
  73876. * @param height the height of the emission cylinder (1 by default)
  73877. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73878. * @param direction1 the min limit of the emission direction (up vector by default)
  73879. * @param direction2 the max limit of the emission direction (up vector by default)
  73880. */
  73881. constructor(radius?: number, height?: number, radiusRange?: number,
  73882. /**
  73883. * The min limit of the emission direction.
  73884. */
  73885. direction1?: Vector3,
  73886. /**
  73887. * The max limit of the emission direction.
  73888. */
  73889. direction2?: Vector3);
  73890. /**
  73891. * Called by the particle System when the direction is computed for the created particle.
  73892. * @param worldMatrix is the world matrix of the particle system
  73893. * @param directionToUpdate is the direction vector to update with the result
  73894. * @param particle is the particle we are computed the direction for
  73895. */
  73896. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73897. /**
  73898. * Clones the current emitter and returns a copy of it
  73899. * @returns the new emitter
  73900. */
  73901. clone(): CylinderDirectedParticleEmitter;
  73902. /**
  73903. * Called by the GPUParticleSystem to setup the update shader
  73904. * @param effect defines the update shader
  73905. */
  73906. applyToShader(effect: Effect): void;
  73907. /**
  73908. * Returns a string to use to update the GPU particles update shader
  73909. * @returns a string containng the defines string
  73910. */
  73911. getEffectDefines(): string;
  73912. /**
  73913. * Returns the string "CylinderDirectedParticleEmitter"
  73914. * @returns a string containing the class name
  73915. */
  73916. getClassName(): string;
  73917. /**
  73918. * Serializes the particle system to a JSON object.
  73919. * @returns the JSON object
  73920. */
  73921. serialize(): any;
  73922. /**
  73923. * Parse properties from a JSON object
  73924. * @param serializationObject defines the JSON object
  73925. */
  73926. parse(serializationObject: any): void;
  73927. }
  73928. }
  73929. declare module BABYLON {
  73930. /**
  73931. * Particle emitter emitting particles from the inside of a hemisphere.
  73932. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  73933. */
  73934. export class HemisphericParticleEmitter implements IParticleEmitterType {
  73935. /**
  73936. * The radius of the emission hemisphere.
  73937. */
  73938. radius: number;
  73939. /**
  73940. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73941. */
  73942. radiusRange: number;
  73943. /**
  73944. * How much to randomize the particle direction [0-1].
  73945. */
  73946. directionRandomizer: number;
  73947. /**
  73948. * Creates a new instance HemisphericParticleEmitter
  73949. * @param radius the radius of the emission hemisphere (1 by default)
  73950. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73951. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  73952. */
  73953. constructor(
  73954. /**
  73955. * The radius of the emission hemisphere.
  73956. */
  73957. radius?: number,
  73958. /**
  73959. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73960. */
  73961. radiusRange?: number,
  73962. /**
  73963. * How much to randomize the particle direction [0-1].
  73964. */
  73965. directionRandomizer?: number);
  73966. /**
  73967. * Called by the particle System when the direction is computed for the created particle.
  73968. * @param worldMatrix is the world matrix of the particle system
  73969. * @param directionToUpdate is the direction vector to update with the result
  73970. * @param particle is the particle we are computed the direction for
  73971. */
  73972. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73973. /**
  73974. * Called by the particle System when the position is computed for the created particle.
  73975. * @param worldMatrix is the world matrix of the particle system
  73976. * @param positionToUpdate is the position vector to update with the result
  73977. * @param particle is the particle we are computed the position for
  73978. */
  73979. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73980. /**
  73981. * Clones the current emitter and returns a copy of it
  73982. * @returns the new emitter
  73983. */
  73984. clone(): HemisphericParticleEmitter;
  73985. /**
  73986. * Called by the GPUParticleSystem to setup the update shader
  73987. * @param effect defines the update shader
  73988. */
  73989. applyToShader(effect: Effect): void;
  73990. /**
  73991. * Returns a string to use to update the GPU particles update shader
  73992. * @returns a string containng the defines string
  73993. */
  73994. getEffectDefines(): string;
  73995. /**
  73996. * Returns the string "HemisphericParticleEmitter"
  73997. * @returns a string containing the class name
  73998. */
  73999. getClassName(): string;
  74000. /**
  74001. * Serializes the particle system to a JSON object.
  74002. * @returns the JSON object
  74003. */
  74004. serialize(): any;
  74005. /**
  74006. * Parse properties from a JSON object
  74007. * @param serializationObject defines the JSON object
  74008. */
  74009. parse(serializationObject: any): void;
  74010. }
  74011. }
  74012. declare module BABYLON {
  74013. /**
  74014. * Particle emitter emitting particles from a point.
  74015. * It emits the particles randomly between 2 given directions.
  74016. */
  74017. export class PointParticleEmitter implements IParticleEmitterType {
  74018. /**
  74019. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74020. */
  74021. direction1: Vector3;
  74022. /**
  74023. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74024. */
  74025. direction2: Vector3;
  74026. /**
  74027. * Creates a new instance PointParticleEmitter
  74028. */
  74029. constructor();
  74030. /**
  74031. * Called by the particle System when the direction is computed for the created particle.
  74032. * @param worldMatrix is the world matrix of the particle system
  74033. * @param directionToUpdate is the direction vector to update with the result
  74034. * @param particle is the particle we are computed the direction for
  74035. */
  74036. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74037. /**
  74038. * Called by the particle System when the position is computed for the created particle.
  74039. * @param worldMatrix is the world matrix of the particle system
  74040. * @param positionToUpdate is the position vector to update with the result
  74041. * @param particle is the particle we are computed the position for
  74042. */
  74043. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74044. /**
  74045. * Clones the current emitter and returns a copy of it
  74046. * @returns the new emitter
  74047. */
  74048. clone(): PointParticleEmitter;
  74049. /**
  74050. * Called by the GPUParticleSystem to setup the update shader
  74051. * @param effect defines the update shader
  74052. */
  74053. applyToShader(effect: Effect): void;
  74054. /**
  74055. * Returns a string to use to update the GPU particles update shader
  74056. * @returns a string containng the defines string
  74057. */
  74058. getEffectDefines(): string;
  74059. /**
  74060. * Returns the string "PointParticleEmitter"
  74061. * @returns a string containing the class name
  74062. */
  74063. getClassName(): string;
  74064. /**
  74065. * Serializes the particle system to a JSON object.
  74066. * @returns the JSON object
  74067. */
  74068. serialize(): any;
  74069. /**
  74070. * Parse properties from a JSON object
  74071. * @param serializationObject defines the JSON object
  74072. */
  74073. parse(serializationObject: any): void;
  74074. }
  74075. }
  74076. declare module BABYLON {
  74077. /**
  74078. * Particle emitter emitting particles from the inside of a sphere.
  74079. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  74080. */
  74081. export class SphereParticleEmitter implements IParticleEmitterType {
  74082. /**
  74083. * The radius of the emission sphere.
  74084. */
  74085. radius: number;
  74086. /**
  74087. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74088. */
  74089. radiusRange: number;
  74090. /**
  74091. * How much to randomize the particle direction [0-1].
  74092. */
  74093. directionRandomizer: number;
  74094. /**
  74095. * Creates a new instance SphereParticleEmitter
  74096. * @param radius the radius of the emission sphere (1 by default)
  74097. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74098. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  74099. */
  74100. constructor(
  74101. /**
  74102. * The radius of the emission sphere.
  74103. */
  74104. radius?: number,
  74105. /**
  74106. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74107. */
  74108. radiusRange?: number,
  74109. /**
  74110. * How much to randomize the particle direction [0-1].
  74111. */
  74112. directionRandomizer?: number);
  74113. /**
  74114. * Called by the particle System when the direction is computed for the created particle.
  74115. * @param worldMatrix is the world matrix of the particle system
  74116. * @param directionToUpdate is the direction vector to update with the result
  74117. * @param particle is the particle we are computed the direction for
  74118. */
  74119. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74120. /**
  74121. * Called by the particle System when the position is computed for the created particle.
  74122. * @param worldMatrix is the world matrix of the particle system
  74123. * @param positionToUpdate is the position vector to update with the result
  74124. * @param particle is the particle we are computed the position for
  74125. */
  74126. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74127. /**
  74128. * Clones the current emitter and returns a copy of it
  74129. * @returns the new emitter
  74130. */
  74131. clone(): SphereParticleEmitter;
  74132. /**
  74133. * Called by the GPUParticleSystem to setup the update shader
  74134. * @param effect defines the update shader
  74135. */
  74136. applyToShader(effect: Effect): void;
  74137. /**
  74138. * Returns a string to use to update the GPU particles update shader
  74139. * @returns a string containng the defines string
  74140. */
  74141. getEffectDefines(): string;
  74142. /**
  74143. * Returns the string "SphereParticleEmitter"
  74144. * @returns a string containing the class name
  74145. */
  74146. getClassName(): string;
  74147. /**
  74148. * Serializes the particle system to a JSON object.
  74149. * @returns the JSON object
  74150. */
  74151. serialize(): any;
  74152. /**
  74153. * Parse properties from a JSON object
  74154. * @param serializationObject defines the JSON object
  74155. */
  74156. parse(serializationObject: any): void;
  74157. }
  74158. /**
  74159. * Particle emitter emitting particles from the inside of a sphere.
  74160. * It emits the particles randomly between two vectors.
  74161. */
  74162. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  74163. /**
  74164. * The min limit of the emission direction.
  74165. */
  74166. direction1: Vector3;
  74167. /**
  74168. * The max limit of the emission direction.
  74169. */
  74170. direction2: Vector3;
  74171. /**
  74172. * Creates a new instance SphereDirectedParticleEmitter
  74173. * @param radius the radius of the emission sphere (1 by default)
  74174. * @param direction1 the min limit of the emission direction (up vector by default)
  74175. * @param direction2 the max limit of the emission direction (up vector by default)
  74176. */
  74177. constructor(radius?: number,
  74178. /**
  74179. * The min limit of the emission direction.
  74180. */
  74181. direction1?: Vector3,
  74182. /**
  74183. * The max limit of the emission direction.
  74184. */
  74185. direction2?: Vector3);
  74186. /**
  74187. * Called by the particle System when the direction is computed for the created particle.
  74188. * @param worldMatrix is the world matrix of the particle system
  74189. * @param directionToUpdate is the direction vector to update with the result
  74190. * @param particle is the particle we are computed the direction for
  74191. */
  74192. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74193. /**
  74194. * Clones the current emitter and returns a copy of it
  74195. * @returns the new emitter
  74196. */
  74197. clone(): SphereDirectedParticleEmitter;
  74198. /**
  74199. * Called by the GPUParticleSystem to setup the update shader
  74200. * @param effect defines the update shader
  74201. */
  74202. applyToShader(effect: Effect): void;
  74203. /**
  74204. * Returns a string to use to update the GPU particles update shader
  74205. * @returns a string containng the defines string
  74206. */
  74207. getEffectDefines(): string;
  74208. /**
  74209. * Returns the string "SphereDirectedParticleEmitter"
  74210. * @returns a string containing the class name
  74211. */
  74212. getClassName(): string;
  74213. /**
  74214. * Serializes the particle system to a JSON object.
  74215. * @returns the JSON object
  74216. */
  74217. serialize(): any;
  74218. /**
  74219. * Parse properties from a JSON object
  74220. * @param serializationObject defines the JSON object
  74221. */
  74222. parse(serializationObject: any): void;
  74223. }
  74224. }
  74225. declare module BABYLON {
  74226. /**
  74227. * Interface representing a particle system in Babylon.js.
  74228. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  74229. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  74230. */
  74231. export interface IParticleSystem {
  74232. /**
  74233. * List of animations used by the particle system.
  74234. */
  74235. animations: Animation[];
  74236. /**
  74237. * The id of the Particle system.
  74238. */
  74239. id: string;
  74240. /**
  74241. * The name of the Particle system.
  74242. */
  74243. name: string;
  74244. /**
  74245. * The emitter represents the Mesh or position we are attaching the particle system to.
  74246. */
  74247. emitter: Nullable<AbstractMesh | Vector3>;
  74248. /**
  74249. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  74250. */
  74251. isBillboardBased: boolean;
  74252. /**
  74253. * The rendering group used by the Particle system to chose when to render.
  74254. */
  74255. renderingGroupId: number;
  74256. /**
  74257. * The layer mask we are rendering the particles through.
  74258. */
  74259. layerMask: number;
  74260. /**
  74261. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  74262. */
  74263. updateSpeed: number;
  74264. /**
  74265. * The amount of time the particle system is running (depends of the overall update speed).
  74266. */
  74267. targetStopDuration: number;
  74268. /**
  74269. * The texture used to render each particle. (this can be a spritesheet)
  74270. */
  74271. particleTexture: Nullable<Texture>;
  74272. /**
  74273. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  74274. */
  74275. blendMode: number;
  74276. /**
  74277. * Minimum life time of emitting particles.
  74278. */
  74279. minLifeTime: number;
  74280. /**
  74281. * Maximum life time of emitting particles.
  74282. */
  74283. maxLifeTime: number;
  74284. /**
  74285. * Minimum Size of emitting particles.
  74286. */
  74287. minSize: number;
  74288. /**
  74289. * Maximum Size of emitting particles.
  74290. */
  74291. maxSize: number;
  74292. /**
  74293. * Minimum scale of emitting particles on X axis.
  74294. */
  74295. minScaleX: number;
  74296. /**
  74297. * Maximum scale of emitting particles on X axis.
  74298. */
  74299. maxScaleX: number;
  74300. /**
  74301. * Minimum scale of emitting particles on Y axis.
  74302. */
  74303. minScaleY: number;
  74304. /**
  74305. * Maximum scale of emitting particles on Y axis.
  74306. */
  74307. maxScaleY: number;
  74308. /**
  74309. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  74310. */
  74311. color1: Color4;
  74312. /**
  74313. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  74314. */
  74315. color2: Color4;
  74316. /**
  74317. * Color the particle will have at the end of its lifetime.
  74318. */
  74319. colorDead: Color4;
  74320. /**
  74321. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  74322. */
  74323. emitRate: number;
  74324. /**
  74325. * You can use gravity if you want to give an orientation to your particles.
  74326. */
  74327. gravity: Vector3;
  74328. /**
  74329. * Minimum power of emitting particles.
  74330. */
  74331. minEmitPower: number;
  74332. /**
  74333. * Maximum power of emitting particles.
  74334. */
  74335. maxEmitPower: number;
  74336. /**
  74337. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  74338. */
  74339. minAngularSpeed: number;
  74340. /**
  74341. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  74342. */
  74343. maxAngularSpeed: number;
  74344. /**
  74345. * Gets or sets the minimal initial rotation in radians.
  74346. */
  74347. minInitialRotation: number;
  74348. /**
  74349. * Gets or sets the maximal initial rotation in radians.
  74350. */
  74351. maxInitialRotation: number;
  74352. /**
  74353. * The particle emitter type defines the emitter used by the particle system.
  74354. * It can be for example box, sphere, or cone...
  74355. */
  74356. particleEmitterType: Nullable<IParticleEmitterType>;
  74357. /**
  74358. * Defines the delay in milliseconds before starting the system (0 by default)
  74359. */
  74360. startDelay: number;
  74361. /**
  74362. * 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
  74363. */
  74364. preWarmCycles: number;
  74365. /**
  74366. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  74367. */
  74368. preWarmStepOffset: number;
  74369. /**
  74370. * 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)
  74371. */
  74372. spriteCellChangeSpeed: number;
  74373. /**
  74374. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  74375. */
  74376. startSpriteCellID: number;
  74377. /**
  74378. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  74379. */
  74380. endSpriteCellID: number;
  74381. /**
  74382. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  74383. */
  74384. spriteCellWidth: number;
  74385. /**
  74386. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  74387. */
  74388. spriteCellHeight: number;
  74389. /**
  74390. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  74391. */
  74392. spriteRandomStartCell: boolean;
  74393. /**
  74394. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  74395. */
  74396. isAnimationSheetEnabled: boolean;
  74397. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  74398. translationPivot: Vector2;
  74399. /**
  74400. * Gets or sets a texture used to add random noise to particle positions
  74401. */
  74402. noiseTexture: Nullable<BaseTexture>;
  74403. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  74404. noiseStrength: Vector3;
  74405. /**
  74406. * Gets or sets the billboard mode to use when isBillboardBased = true.
  74407. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  74408. */
  74409. billboardMode: number;
  74410. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  74411. limitVelocityDamping: number;
  74412. /**
  74413. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  74414. */
  74415. beginAnimationOnStart: boolean;
  74416. /**
  74417. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  74418. */
  74419. beginAnimationFrom: number;
  74420. /**
  74421. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  74422. */
  74423. beginAnimationTo: number;
  74424. /**
  74425. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  74426. */
  74427. beginAnimationLoop: boolean;
  74428. /**
  74429. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  74430. */
  74431. disposeOnStop: boolean;
  74432. /**
  74433. * Gets the maximum number of particles active at the same time.
  74434. * @returns The max number of active particles.
  74435. */
  74436. getCapacity(): number;
  74437. /**
  74438. * Gets if the system has been started. (Note: this will still be true after stop is called)
  74439. * @returns True if it has been started, otherwise false.
  74440. */
  74441. isStarted(): boolean;
  74442. /**
  74443. * Animates the particle system for this frame.
  74444. */
  74445. animate(): void;
  74446. /**
  74447. * Renders the particle system in its current state.
  74448. * @returns the current number of particles
  74449. */
  74450. render(): number;
  74451. /**
  74452. * Dispose the particle system and frees its associated resources.
  74453. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  74454. */
  74455. dispose(disposeTexture?: boolean): void;
  74456. /**
  74457. * Clones the particle system.
  74458. * @param name The name of the cloned object
  74459. * @param newEmitter The new emitter to use
  74460. * @returns the cloned particle system
  74461. */
  74462. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  74463. /**
  74464. * Serializes the particle system to a JSON object.
  74465. * @returns the JSON object
  74466. */
  74467. serialize(): any;
  74468. /**
  74469. * Rebuild the particle system
  74470. */
  74471. rebuild(): void;
  74472. /**
  74473. * Starts the particle system and begins to emit
  74474. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  74475. */
  74476. start(delay?: number): void;
  74477. /**
  74478. * Stops the particle system.
  74479. */
  74480. stop(): void;
  74481. /**
  74482. * Remove all active particles
  74483. */
  74484. reset(): void;
  74485. /**
  74486. * Is this system ready to be used/rendered
  74487. * @return true if the system is ready
  74488. */
  74489. isReady(): boolean;
  74490. /**
  74491. * Adds a new color gradient
  74492. * @param gradient defines the gradient to use (between 0 and 1)
  74493. * @param color1 defines the color to affect to the specified gradient
  74494. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  74495. * @returns the current particle system
  74496. */
  74497. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  74498. /**
  74499. * Remove a specific color gradient
  74500. * @param gradient defines the gradient to remove
  74501. * @returns the current particle system
  74502. */
  74503. removeColorGradient(gradient: number): IParticleSystem;
  74504. /**
  74505. * Adds a new size gradient
  74506. * @param gradient defines the gradient to use (between 0 and 1)
  74507. * @param factor defines the size factor to affect to the specified gradient
  74508. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74509. * @returns the current particle system
  74510. */
  74511. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74512. /**
  74513. * Remove a specific size gradient
  74514. * @param gradient defines the gradient to remove
  74515. * @returns the current particle system
  74516. */
  74517. removeSizeGradient(gradient: number): IParticleSystem;
  74518. /**
  74519. * Gets the current list of color gradients.
  74520. * You must use addColorGradient and removeColorGradient to udpate this list
  74521. * @returns the list of color gradients
  74522. */
  74523. getColorGradients(): Nullable<Array<ColorGradient>>;
  74524. /**
  74525. * Gets the current list of size gradients.
  74526. * You must use addSizeGradient and removeSizeGradient to udpate this list
  74527. * @returns the list of size gradients
  74528. */
  74529. getSizeGradients(): Nullable<Array<FactorGradient>>;
  74530. /**
  74531. * Gets the current list of angular speed gradients.
  74532. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  74533. * @returns the list of angular speed gradients
  74534. */
  74535. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  74536. /**
  74537. * Adds a new angular speed gradient
  74538. * @param gradient defines the gradient to use (between 0 and 1)
  74539. * @param factor defines the angular speed to affect to the specified gradient
  74540. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74541. * @returns the current particle system
  74542. */
  74543. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74544. /**
  74545. * Remove a specific angular speed gradient
  74546. * @param gradient defines the gradient to remove
  74547. * @returns the current particle system
  74548. */
  74549. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  74550. /**
  74551. * Gets the current list of velocity gradients.
  74552. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  74553. * @returns the list of velocity gradients
  74554. */
  74555. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  74556. /**
  74557. * Adds a new velocity gradient
  74558. * @param gradient defines the gradient to use (between 0 and 1)
  74559. * @param factor defines the velocity to affect to the specified gradient
  74560. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74561. * @returns the current particle system
  74562. */
  74563. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74564. /**
  74565. * Remove a specific velocity gradient
  74566. * @param gradient defines the gradient to remove
  74567. * @returns the current particle system
  74568. */
  74569. removeVelocityGradient(gradient: number): IParticleSystem;
  74570. /**
  74571. * Gets the current list of limit velocity gradients.
  74572. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  74573. * @returns the list of limit velocity gradients
  74574. */
  74575. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  74576. /**
  74577. * Adds a new limit velocity gradient
  74578. * @param gradient defines the gradient to use (between 0 and 1)
  74579. * @param factor defines the limit velocity to affect to the specified gradient
  74580. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74581. * @returns the current particle system
  74582. */
  74583. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74584. /**
  74585. * Remove a specific limit velocity gradient
  74586. * @param gradient defines the gradient to remove
  74587. * @returns the current particle system
  74588. */
  74589. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  74590. /**
  74591. * Adds a new drag gradient
  74592. * @param gradient defines the gradient to use (between 0 and 1)
  74593. * @param factor defines the drag to affect to the specified gradient
  74594. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74595. * @returns the current particle system
  74596. */
  74597. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74598. /**
  74599. * Remove a specific drag gradient
  74600. * @param gradient defines the gradient to remove
  74601. * @returns the current particle system
  74602. */
  74603. removeDragGradient(gradient: number): IParticleSystem;
  74604. /**
  74605. * Gets the current list of drag gradients.
  74606. * You must use addDragGradient and removeDragGradient to udpate this list
  74607. * @returns the list of drag gradients
  74608. */
  74609. getDragGradients(): Nullable<Array<FactorGradient>>;
  74610. /**
  74611. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  74612. * @param gradient defines the gradient to use (between 0 and 1)
  74613. * @param factor defines the emit rate to affect to the specified gradient
  74614. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74615. * @returns the current particle system
  74616. */
  74617. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74618. /**
  74619. * Remove a specific emit rate gradient
  74620. * @param gradient defines the gradient to remove
  74621. * @returns the current particle system
  74622. */
  74623. removeEmitRateGradient(gradient: number): IParticleSystem;
  74624. /**
  74625. * Gets the current list of emit rate gradients.
  74626. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  74627. * @returns the list of emit rate gradients
  74628. */
  74629. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  74630. /**
  74631. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  74632. * @param gradient defines the gradient to use (between 0 and 1)
  74633. * @param factor defines the start size to affect to the specified gradient
  74634. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74635. * @returns the current particle system
  74636. */
  74637. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74638. /**
  74639. * Remove a specific start size gradient
  74640. * @param gradient defines the gradient to remove
  74641. * @returns the current particle system
  74642. */
  74643. removeStartSizeGradient(gradient: number): IParticleSystem;
  74644. /**
  74645. * Gets the current list of start size gradients.
  74646. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  74647. * @returns the list of start size gradients
  74648. */
  74649. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  74650. /**
  74651. * Adds a new life time gradient
  74652. * @param gradient defines the gradient to use (between 0 and 1)
  74653. * @param factor defines the life time factor to affect to the specified gradient
  74654. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74655. * @returns the current particle system
  74656. */
  74657. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74658. /**
  74659. * Remove a specific life time gradient
  74660. * @param gradient defines the gradient to remove
  74661. * @returns the current particle system
  74662. */
  74663. removeLifeTimeGradient(gradient: number): IParticleSystem;
  74664. /**
  74665. * Gets the current list of life time gradients.
  74666. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  74667. * @returns the list of life time gradients
  74668. */
  74669. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  74670. /**
  74671. * Gets the current list of color gradients.
  74672. * You must use addColorGradient and removeColorGradient to udpate this list
  74673. * @returns the list of color gradients
  74674. */
  74675. getColorGradients(): Nullable<Array<ColorGradient>>;
  74676. /**
  74677. * Adds a new ramp gradient used to remap particle colors
  74678. * @param gradient defines the gradient to use (between 0 and 1)
  74679. * @param color defines the color to affect to the specified gradient
  74680. * @returns the current particle system
  74681. */
  74682. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  74683. /**
  74684. * Gets the current list of ramp gradients.
  74685. * You must use addRampGradient and removeRampGradient to udpate this list
  74686. * @returns the list of ramp gradients
  74687. */
  74688. getRampGradients(): Nullable<Array<Color3Gradient>>;
  74689. /** Gets or sets a boolean indicating that ramp gradients must be used
  74690. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  74691. */
  74692. useRampGradients: boolean;
  74693. /**
  74694. * Adds a new color remap gradient
  74695. * @param gradient defines the gradient to use (between 0 and 1)
  74696. * @param min defines the color remap minimal range
  74697. * @param max defines the color remap maximal range
  74698. * @returns the current particle system
  74699. */
  74700. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  74701. /**
  74702. * Gets the current list of color remap gradients.
  74703. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  74704. * @returns the list of color remap gradients
  74705. */
  74706. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  74707. /**
  74708. * Adds a new alpha remap gradient
  74709. * @param gradient defines the gradient to use (between 0 and 1)
  74710. * @param min defines the alpha remap minimal range
  74711. * @param max defines the alpha remap maximal range
  74712. * @returns the current particle system
  74713. */
  74714. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  74715. /**
  74716. * Gets the current list of alpha remap gradients.
  74717. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  74718. * @returns the list of alpha remap gradients
  74719. */
  74720. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  74721. /**
  74722. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  74723. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  74724. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  74725. * @returns the emitter
  74726. */
  74727. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  74728. /**
  74729. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  74730. * @param radius The radius of the hemisphere to emit from
  74731. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  74732. * @returns the emitter
  74733. */
  74734. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  74735. /**
  74736. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  74737. * @param radius The radius of the sphere to emit from
  74738. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  74739. * @returns the emitter
  74740. */
  74741. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  74742. /**
  74743. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  74744. * @param radius The radius of the sphere to emit from
  74745. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  74746. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  74747. * @returns the emitter
  74748. */
  74749. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  74750. /**
  74751. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  74752. * @param radius The radius of the emission cylinder
  74753. * @param height The height of the emission cylinder
  74754. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  74755. * @param directionRandomizer How much to randomize the particle direction [0-1]
  74756. * @returns the emitter
  74757. */
  74758. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  74759. /**
  74760. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  74761. * @param radius The radius of the cylinder to emit from
  74762. * @param height The height of the emission cylinder
  74763. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74764. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  74765. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  74766. * @returns the emitter
  74767. */
  74768. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  74769. /**
  74770. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  74771. * @param radius The radius of the cone to emit from
  74772. * @param angle The base angle of the cone
  74773. * @returns the emitter
  74774. */
  74775. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  74776. /**
  74777. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  74778. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  74779. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  74780. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74781. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74782. * @returns the emitter
  74783. */
  74784. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  74785. /**
  74786. * Get hosting scene
  74787. * @returns the scene
  74788. */
  74789. getScene(): Scene;
  74790. }
  74791. }
  74792. declare module BABYLON {
  74793. /**
  74794. * Creates an instance based on a source mesh.
  74795. */
  74796. export class InstancedMesh extends AbstractMesh {
  74797. private _sourceMesh;
  74798. private _currentLOD;
  74799. /** @hidden */
  74800. _indexInSourceMeshInstanceArray: number;
  74801. constructor(name: string, source: Mesh);
  74802. /**
  74803. * Returns the string "InstancedMesh".
  74804. */
  74805. getClassName(): string;
  74806. /**
  74807. * If the source mesh receives shadows
  74808. */
  74809. readonly receiveShadows: boolean;
  74810. /**
  74811. * The material of the source mesh
  74812. */
  74813. readonly material: Nullable<Material>;
  74814. /**
  74815. * Visibility of the source mesh
  74816. */
  74817. readonly visibility: number;
  74818. /**
  74819. * Skeleton of the source mesh
  74820. */
  74821. readonly skeleton: Nullable<Skeleton>;
  74822. /**
  74823. * Rendering ground id of the source mesh
  74824. */
  74825. renderingGroupId: number;
  74826. /**
  74827. * Returns the total number of vertices (integer).
  74828. */
  74829. getTotalVertices(): number;
  74830. /**
  74831. * Returns a positive integer : the total number of indices in this mesh geometry.
  74832. * @returns the numner of indices or zero if the mesh has no geometry.
  74833. */
  74834. getTotalIndices(): number;
  74835. /**
  74836. * The source mesh of the instance
  74837. */
  74838. readonly sourceMesh: Mesh;
  74839. /**
  74840. * Is this node ready to be used/rendered
  74841. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  74842. * @return {boolean} is it ready
  74843. */
  74844. isReady(completeCheck?: boolean): boolean;
  74845. /**
  74846. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  74847. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  74848. * @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.
  74849. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  74850. */
  74851. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  74852. /**
  74853. * Sets the vertex data of the mesh geometry for the requested `kind`.
  74854. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  74855. * The `data` are either a numeric array either a Float32Array.
  74856. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  74857. * 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).
  74858. * Note that a new underlying VertexBuffer object is created each call.
  74859. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  74860. *
  74861. * Possible `kind` values :
  74862. * - VertexBuffer.PositionKind
  74863. * - VertexBuffer.UVKind
  74864. * - VertexBuffer.UV2Kind
  74865. * - VertexBuffer.UV3Kind
  74866. * - VertexBuffer.UV4Kind
  74867. * - VertexBuffer.UV5Kind
  74868. * - VertexBuffer.UV6Kind
  74869. * - VertexBuffer.ColorKind
  74870. * - VertexBuffer.MatricesIndicesKind
  74871. * - VertexBuffer.MatricesIndicesExtraKind
  74872. * - VertexBuffer.MatricesWeightsKind
  74873. * - VertexBuffer.MatricesWeightsExtraKind
  74874. *
  74875. * Returns the Mesh.
  74876. */
  74877. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  74878. /**
  74879. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  74880. * If the mesh has no geometry, it is simply returned as it is.
  74881. * The `data` are either a numeric array either a Float32Array.
  74882. * No new underlying VertexBuffer object is created.
  74883. * 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.
  74884. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  74885. *
  74886. * Possible `kind` values :
  74887. * - VertexBuffer.PositionKind
  74888. * - VertexBuffer.UVKind
  74889. * - VertexBuffer.UV2Kind
  74890. * - VertexBuffer.UV3Kind
  74891. * - VertexBuffer.UV4Kind
  74892. * - VertexBuffer.UV5Kind
  74893. * - VertexBuffer.UV6Kind
  74894. * - VertexBuffer.ColorKind
  74895. * - VertexBuffer.MatricesIndicesKind
  74896. * - VertexBuffer.MatricesIndicesExtraKind
  74897. * - VertexBuffer.MatricesWeightsKind
  74898. * - VertexBuffer.MatricesWeightsExtraKind
  74899. *
  74900. * Returns the Mesh.
  74901. */
  74902. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  74903. /**
  74904. * Sets the mesh indices.
  74905. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  74906. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  74907. * This method creates a new index buffer each call.
  74908. * Returns the Mesh.
  74909. */
  74910. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  74911. /**
  74912. * Boolean : True if the mesh owns the requested kind of data.
  74913. */
  74914. isVerticesDataPresent(kind: string): boolean;
  74915. /**
  74916. * Returns an array of indices (IndicesArray).
  74917. */
  74918. getIndices(): Nullable<IndicesArray>;
  74919. readonly _positions: Nullable<Vector3[]>;
  74920. /**
  74921. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  74922. * This means the mesh underlying bounding box and sphere are recomputed.
  74923. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  74924. * @returns the current mesh
  74925. */
  74926. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  74927. /** @hidden */
  74928. _preActivate(): InstancedMesh;
  74929. /** @hidden */
  74930. _activate(renderId: number): InstancedMesh;
  74931. /**
  74932. * Returns the current associated LOD AbstractMesh.
  74933. */
  74934. getLOD(camera: Camera): AbstractMesh;
  74935. /** @hidden */
  74936. _syncSubMeshes(): InstancedMesh;
  74937. /** @hidden */
  74938. _generatePointsArray(): boolean;
  74939. /**
  74940. * Creates a new InstancedMesh from the current mesh.
  74941. * - name (string) : the cloned mesh name
  74942. * - newParent (optional Node) : the optional Node to parent the clone to.
  74943. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  74944. *
  74945. * Returns the clone.
  74946. */
  74947. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  74948. /**
  74949. * Disposes the InstancedMesh.
  74950. * Returns nothing.
  74951. */
  74952. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  74953. }
  74954. }
  74955. declare module BABYLON {
  74956. /**
  74957. * Defines the options associated with the creation of a shader material.
  74958. */
  74959. export interface IShaderMaterialOptions {
  74960. /**
  74961. * Does the material work in alpha blend mode
  74962. */
  74963. needAlphaBlending: boolean;
  74964. /**
  74965. * Does the material work in alpha test mode
  74966. */
  74967. needAlphaTesting: boolean;
  74968. /**
  74969. * The list of attribute names used in the shader
  74970. */
  74971. attributes: string[];
  74972. /**
  74973. * The list of unifrom names used in the shader
  74974. */
  74975. uniforms: string[];
  74976. /**
  74977. * The list of UBO names used in the shader
  74978. */
  74979. uniformBuffers: string[];
  74980. /**
  74981. * The list of sampler names used in the shader
  74982. */
  74983. samplers: string[];
  74984. /**
  74985. * The list of defines used in the shader
  74986. */
  74987. defines: string[];
  74988. }
  74989. /**
  74990. * 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.
  74991. *
  74992. * This returned material effects how the mesh will look based on the code in the shaders.
  74993. *
  74994. * @see http://doc.babylonjs.com/how_to/shader_material
  74995. */
  74996. export class ShaderMaterial extends Material {
  74997. private _shaderPath;
  74998. private _options;
  74999. private _textures;
  75000. private _textureArrays;
  75001. private _floats;
  75002. private _ints;
  75003. private _floatsArrays;
  75004. private _colors3;
  75005. private _colors3Arrays;
  75006. private _colors4;
  75007. private _vectors2;
  75008. private _vectors3;
  75009. private _vectors4;
  75010. private _matrices;
  75011. private _matrices3x3;
  75012. private _matrices2x2;
  75013. private _vectors2Arrays;
  75014. private _vectors3Arrays;
  75015. private _cachedWorldViewMatrix;
  75016. private _renderId;
  75017. /**
  75018. * Instantiate a new shader material.
  75019. * 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.
  75020. * This returned material effects how the mesh will look based on the code in the shaders.
  75021. * @see http://doc.babylonjs.com/how_to/shader_material
  75022. * @param name Define the name of the material in the scene
  75023. * @param scene Define the scene the material belongs to
  75024. * @param shaderPath Defines the route to the shader code in one of three ways:
  75025. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  75026. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  75027. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  75028. * @param options Define the options used to create the shader
  75029. */
  75030. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  75031. /**
  75032. * Gets the options used to compile the shader.
  75033. * They can be modified to trigger a new compilation
  75034. */
  75035. readonly options: IShaderMaterialOptions;
  75036. /**
  75037. * Gets the current class name of the material e.g. "ShaderMaterial"
  75038. * Mainly use in serialization.
  75039. * @returns the class name
  75040. */
  75041. getClassName(): string;
  75042. /**
  75043. * Specifies if the material will require alpha blending
  75044. * @returns a boolean specifying if alpha blending is needed
  75045. */
  75046. needAlphaBlending(): boolean;
  75047. /**
  75048. * Specifies if this material should be rendered in alpha test mode
  75049. * @returns a boolean specifying if an alpha test is needed.
  75050. */
  75051. needAlphaTesting(): boolean;
  75052. private _checkUniform;
  75053. /**
  75054. * Set a texture in the shader.
  75055. * @param name Define the name of the uniform samplers as defined in the shader
  75056. * @param texture Define the texture to bind to this sampler
  75057. * @return the material itself allowing "fluent" like uniform updates
  75058. */
  75059. setTexture(name: string, texture: Texture): ShaderMaterial;
  75060. /**
  75061. * Set a texture array in the shader.
  75062. * @param name Define the name of the uniform sampler array as defined in the shader
  75063. * @param textures Define the list of textures to bind to this sampler
  75064. * @return the material itself allowing "fluent" like uniform updates
  75065. */
  75066. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  75067. /**
  75068. * Set a float in the shader.
  75069. * @param name Define the name of the uniform as defined in the shader
  75070. * @param value Define the value to give to the uniform
  75071. * @return the material itself allowing "fluent" like uniform updates
  75072. */
  75073. setFloat(name: string, value: number): ShaderMaterial;
  75074. /**
  75075. * Set a int in the shader.
  75076. * @param name Define the name of the uniform as defined in the shader
  75077. * @param value Define the value to give to the uniform
  75078. * @return the material itself allowing "fluent" like uniform updates
  75079. */
  75080. setInt(name: string, value: number): ShaderMaterial;
  75081. /**
  75082. * Set an array of floats in the shader.
  75083. * @param name Define the name of the uniform as defined in the shader
  75084. * @param value Define the value to give to the uniform
  75085. * @return the material itself allowing "fluent" like uniform updates
  75086. */
  75087. setFloats(name: string, value: number[]): ShaderMaterial;
  75088. /**
  75089. * Set a vec3 in the shader from a Color3.
  75090. * @param name Define the name of the uniform as defined in the shader
  75091. * @param value Define the value to give to the uniform
  75092. * @return the material itself allowing "fluent" like uniform updates
  75093. */
  75094. setColor3(name: string, value: Color3): ShaderMaterial;
  75095. /**
  75096. * Set a vec3 array in the shader from a Color3 array.
  75097. * @param name Define the name of the uniform as defined in the shader
  75098. * @param value Define the value to give to the uniform
  75099. * @return the material itself allowing "fluent" like uniform updates
  75100. */
  75101. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  75102. /**
  75103. * Set a vec4 in the shader from a Color4.
  75104. * @param name Define the name of the uniform as defined in the shader
  75105. * @param value Define the value to give to the uniform
  75106. * @return the material itself allowing "fluent" like uniform updates
  75107. */
  75108. setColor4(name: string, value: Color4): ShaderMaterial;
  75109. /**
  75110. * Set a vec2 in the shader from a Vector2.
  75111. * @param name Define the name of the uniform as defined in the shader
  75112. * @param value Define the value to give to the uniform
  75113. * @return the material itself allowing "fluent" like uniform updates
  75114. */
  75115. setVector2(name: string, value: Vector2): ShaderMaterial;
  75116. /**
  75117. * Set a vec3 in the shader from a Vector3.
  75118. * @param name Define the name of the uniform as defined in the shader
  75119. * @param value Define the value to give to the uniform
  75120. * @return the material itself allowing "fluent" like uniform updates
  75121. */
  75122. setVector3(name: string, value: Vector3): ShaderMaterial;
  75123. /**
  75124. * Set a vec4 in the shader from a Vector4.
  75125. * @param name Define the name of the uniform as defined in the shader
  75126. * @param value Define the value to give to the uniform
  75127. * @return the material itself allowing "fluent" like uniform updates
  75128. */
  75129. setVector4(name: string, value: Vector4): ShaderMaterial;
  75130. /**
  75131. * Set a mat4 in the shader from a Matrix.
  75132. * @param name Define the name of the uniform as defined in the shader
  75133. * @param value Define the value to give to the uniform
  75134. * @return the material itself allowing "fluent" like uniform updates
  75135. */
  75136. setMatrix(name: string, value: Matrix): ShaderMaterial;
  75137. /**
  75138. * Set a mat3 in the shader from a Float32Array.
  75139. * @param name Define the name of the uniform as defined in the shader
  75140. * @param value Define the value to give to the uniform
  75141. * @return the material itself allowing "fluent" like uniform updates
  75142. */
  75143. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  75144. /**
  75145. * Set a mat2 in the shader from a Float32Array.
  75146. * @param name Define the name of the uniform as defined in the shader
  75147. * @param value Define the value to give to the uniform
  75148. * @return the material itself allowing "fluent" like uniform updates
  75149. */
  75150. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  75151. /**
  75152. * Set a vec2 array in the shader from a number array.
  75153. * @param name Define the name of the uniform as defined in the shader
  75154. * @param value Define the value to give to the uniform
  75155. * @return the material itself allowing "fluent" like uniform updates
  75156. */
  75157. setArray2(name: string, value: number[]): ShaderMaterial;
  75158. /**
  75159. * Set a vec3 array in the shader from a number array.
  75160. * @param name Define the name of the uniform as defined in the shader
  75161. * @param value Define the value to give to the uniform
  75162. * @return the material itself allowing "fluent" like uniform updates
  75163. */
  75164. setArray3(name: string, value: number[]): ShaderMaterial;
  75165. private _checkCache;
  75166. /**
  75167. * Checks if the material is ready to render the requested mesh
  75168. * @param mesh Define the mesh to render
  75169. * @param useInstances Define whether or not the material is used with instances
  75170. * @returns true if ready, otherwise false
  75171. */
  75172. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  75173. /**
  75174. * Binds the world matrix to the material
  75175. * @param world defines the world transformation matrix
  75176. */
  75177. bindOnlyWorldMatrix(world: Matrix): void;
  75178. /**
  75179. * Binds the material to the mesh
  75180. * @param world defines the world transformation matrix
  75181. * @param mesh defines the mesh to bind the material to
  75182. */
  75183. bind(world: Matrix, mesh?: Mesh): void;
  75184. /**
  75185. * Gets the active textures from the material
  75186. * @returns an array of textures
  75187. */
  75188. getActiveTextures(): BaseTexture[];
  75189. /**
  75190. * Specifies if the material uses a texture
  75191. * @param texture defines the texture to check against the material
  75192. * @returns a boolean specifying if the material uses the texture
  75193. */
  75194. hasTexture(texture: BaseTexture): boolean;
  75195. /**
  75196. * Makes a duplicate of the material, and gives it a new name
  75197. * @param name defines the new name for the duplicated material
  75198. * @returns the cloned material
  75199. */
  75200. clone(name: string): ShaderMaterial;
  75201. /**
  75202. * Disposes the material
  75203. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  75204. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  75205. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  75206. */
  75207. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  75208. /**
  75209. * Serializes this material in a JSON representation
  75210. * @returns the serialized material object
  75211. */
  75212. serialize(): any;
  75213. /**
  75214. * Creates a shader material from parsed shader material data
  75215. * @param source defines the JSON represnetation of the material
  75216. * @param scene defines the hosting scene
  75217. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  75218. * @returns a new material
  75219. */
  75220. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  75221. }
  75222. }
  75223. declare module BABYLON {
  75224. /** @hidden */
  75225. export var colorPixelShader: {
  75226. name: string;
  75227. shader: string;
  75228. };
  75229. }
  75230. declare module BABYLON {
  75231. /** @hidden */
  75232. export var colorVertexShader: {
  75233. name: string;
  75234. shader: string;
  75235. };
  75236. }
  75237. declare module BABYLON {
  75238. /**
  75239. * Line mesh
  75240. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  75241. */
  75242. export class LinesMesh extends Mesh {
  75243. /**
  75244. * If vertex color should be applied to the mesh
  75245. */
  75246. useVertexColor?: boolean | undefined;
  75247. /**
  75248. * If vertex alpha should be applied to the mesh
  75249. */
  75250. useVertexAlpha?: boolean | undefined;
  75251. /**
  75252. * Color of the line (Default: White)
  75253. */
  75254. color: Color3;
  75255. /**
  75256. * Alpha of the line (Default: 1)
  75257. */
  75258. alpha: number;
  75259. /**
  75260. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  75261. * This margin is expressed in world space coordinates, so its value may vary.
  75262. * Default value is 0.1
  75263. */
  75264. intersectionThreshold: number;
  75265. private _colorShader;
  75266. /**
  75267. * Creates a new LinesMesh
  75268. * @param name defines the name
  75269. * @param scene defines the hosting scene
  75270. * @param parent defines the parent mesh if any
  75271. * @param source defines the optional source LinesMesh used to clone data from
  75272. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  75273. * When false, achieved by calling a clone(), also passing False.
  75274. * This will make creation of children, recursive.
  75275. * @param useVertexColor defines if this LinesMesh supports vertex color
  75276. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  75277. */
  75278. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  75279. /**
  75280. * If vertex color should be applied to the mesh
  75281. */
  75282. useVertexColor?: boolean | undefined,
  75283. /**
  75284. * If vertex alpha should be applied to the mesh
  75285. */
  75286. useVertexAlpha?: boolean | undefined);
  75287. private _addClipPlaneDefine;
  75288. private _removeClipPlaneDefine;
  75289. isReady(): boolean;
  75290. /**
  75291. * Returns the string "LineMesh"
  75292. */
  75293. getClassName(): string;
  75294. /**
  75295. * @hidden
  75296. */
  75297. /**
  75298. * @hidden
  75299. */
  75300. material: Material;
  75301. /**
  75302. * @hidden
  75303. */
  75304. readonly checkCollisions: boolean;
  75305. /** @hidden */
  75306. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  75307. /** @hidden */
  75308. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  75309. /**
  75310. * Disposes of the line mesh
  75311. * @param doNotRecurse If children should be disposed
  75312. */
  75313. dispose(doNotRecurse?: boolean): void;
  75314. /**
  75315. * Returns a new LineMesh object cloned from the current one.
  75316. */
  75317. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  75318. /**
  75319. * Creates a new InstancedLinesMesh object from the mesh model.
  75320. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  75321. * @param name defines the name of the new instance
  75322. * @returns a new InstancedLinesMesh
  75323. */
  75324. createInstance(name: string): InstancedLinesMesh;
  75325. }
  75326. /**
  75327. * Creates an instance based on a source LinesMesh
  75328. */
  75329. export class InstancedLinesMesh extends InstancedMesh {
  75330. /**
  75331. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  75332. * This margin is expressed in world space coordinates, so its value may vary.
  75333. * Initilized with the intersectionThreshold value of the source LinesMesh
  75334. */
  75335. intersectionThreshold: number;
  75336. constructor(name: string, source: LinesMesh);
  75337. /**
  75338. * Returns the string "InstancedLinesMesh".
  75339. */
  75340. getClassName(): string;
  75341. }
  75342. }
  75343. declare module BABYLON {
  75344. /** @hidden */
  75345. export var linePixelShader: {
  75346. name: string;
  75347. shader: string;
  75348. };
  75349. }
  75350. declare module BABYLON {
  75351. /** @hidden */
  75352. export var lineVertexShader: {
  75353. name: string;
  75354. shader: string;
  75355. };
  75356. }
  75357. declare module BABYLON {
  75358. interface AbstractMesh {
  75359. /**
  75360. * Disables the mesh edge rendering mode
  75361. * @returns the currentAbstractMesh
  75362. */
  75363. disableEdgesRendering(): AbstractMesh;
  75364. /**
  75365. * Enables the edge rendering mode on the mesh.
  75366. * This mode makes the mesh edges visible
  75367. * @param epsilon defines the maximal distance between two angles to detect a face
  75368. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  75369. * @returns the currentAbstractMesh
  75370. * @see https://www.babylonjs-playground.com/#19O9TU#0
  75371. */
  75372. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  75373. /**
  75374. * Gets the edgesRenderer associated with the mesh
  75375. */
  75376. edgesRenderer: Nullable<EdgesRenderer>;
  75377. }
  75378. interface LinesMesh {
  75379. /**
  75380. * Enables the edge rendering mode on the mesh.
  75381. * This mode makes the mesh edges visible
  75382. * @param epsilon defines the maximal distance between two angles to detect a face
  75383. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  75384. * @returns the currentAbstractMesh
  75385. * @see https://www.babylonjs-playground.com/#19O9TU#0
  75386. */
  75387. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  75388. }
  75389. interface InstancedLinesMesh {
  75390. /**
  75391. * Enables the edge rendering mode on the mesh.
  75392. * This mode makes the mesh edges visible
  75393. * @param epsilon defines the maximal distance between two angles to detect a face
  75394. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  75395. * @returns the current InstancedLinesMesh
  75396. * @see https://www.babylonjs-playground.com/#19O9TU#0
  75397. */
  75398. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  75399. }
  75400. /**
  75401. * Defines the minimum contract an Edges renderer should follow.
  75402. */
  75403. export interface IEdgesRenderer extends IDisposable {
  75404. /**
  75405. * Gets or sets a boolean indicating if the edgesRenderer is active
  75406. */
  75407. isEnabled: boolean;
  75408. /**
  75409. * Renders the edges of the attached mesh,
  75410. */
  75411. render(): void;
  75412. /**
  75413. * Checks wether or not the edges renderer is ready to render.
  75414. * @return true if ready, otherwise false.
  75415. */
  75416. isReady(): boolean;
  75417. }
  75418. /**
  75419. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  75420. */
  75421. export class EdgesRenderer implements IEdgesRenderer {
  75422. /**
  75423. * Define the size of the edges with an orthographic camera
  75424. */
  75425. edgesWidthScalerForOrthographic: number;
  75426. /**
  75427. * Define the size of the edges with a perspective camera
  75428. */
  75429. edgesWidthScalerForPerspective: number;
  75430. protected _source: AbstractMesh;
  75431. protected _linesPositions: number[];
  75432. protected _linesNormals: number[];
  75433. protected _linesIndices: number[];
  75434. protected _epsilon: number;
  75435. protected _indicesCount: number;
  75436. protected _lineShader: ShaderMaterial;
  75437. protected _ib: WebGLBuffer;
  75438. protected _buffers: {
  75439. [key: string]: Nullable<VertexBuffer>;
  75440. };
  75441. protected _checkVerticesInsteadOfIndices: boolean;
  75442. private _meshRebuildObserver;
  75443. private _meshDisposeObserver;
  75444. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  75445. isEnabled: boolean;
  75446. /**
  75447. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  75448. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  75449. * @param source Mesh used to create edges
  75450. * @param epsilon sum of angles in adjacency to check for edge
  75451. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  75452. * @param generateEdgesLines - should generate Lines or only prepare resources.
  75453. */
  75454. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  75455. protected _prepareRessources(): void;
  75456. /** @hidden */
  75457. _rebuild(): void;
  75458. /**
  75459. * Releases the required resources for the edges renderer
  75460. */
  75461. dispose(): void;
  75462. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  75463. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  75464. /**
  75465. * Checks if the pair of p0 and p1 is en edge
  75466. * @param faceIndex
  75467. * @param edge
  75468. * @param faceNormals
  75469. * @param p0
  75470. * @param p1
  75471. * @private
  75472. */
  75473. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  75474. /**
  75475. * push line into the position, normal and index buffer
  75476. * @protected
  75477. */
  75478. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  75479. /**
  75480. * Generates lines edges from adjacencjes
  75481. * @private
  75482. */
  75483. _generateEdgesLines(): void;
  75484. /**
  75485. * Checks wether or not the edges renderer is ready to render.
  75486. * @return true if ready, otherwise false.
  75487. */
  75488. isReady(): boolean;
  75489. /**
  75490. * Renders the edges of the attached mesh,
  75491. */
  75492. render(): void;
  75493. }
  75494. /**
  75495. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  75496. */
  75497. export class LineEdgesRenderer extends EdgesRenderer {
  75498. /**
  75499. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  75500. * @param source LineMesh used to generate edges
  75501. * @param epsilon not important (specified angle for edge detection)
  75502. * @param checkVerticesInsteadOfIndices not important for LineMesh
  75503. */
  75504. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  75505. /**
  75506. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  75507. */
  75508. _generateEdgesLines(): void;
  75509. }
  75510. }
  75511. declare module BABYLON {
  75512. /**
  75513. * This represents the object necessary to create a rendering group.
  75514. * This is exclusively used and created by the rendering manager.
  75515. * To modify the behavior, you use the available helpers in your scene or meshes.
  75516. * @hidden
  75517. */
  75518. export class RenderingGroup {
  75519. index: number;
  75520. private _scene;
  75521. private _opaqueSubMeshes;
  75522. private _transparentSubMeshes;
  75523. private _alphaTestSubMeshes;
  75524. private _depthOnlySubMeshes;
  75525. private _particleSystems;
  75526. private _spriteManagers;
  75527. private _opaqueSortCompareFn;
  75528. private _alphaTestSortCompareFn;
  75529. private _transparentSortCompareFn;
  75530. private _renderOpaque;
  75531. private _renderAlphaTest;
  75532. private _renderTransparent;
  75533. private _edgesRenderers;
  75534. onBeforeTransparentRendering: () => void;
  75535. /**
  75536. * Set the opaque sort comparison function.
  75537. * If null the sub meshes will be render in the order they were created
  75538. */
  75539. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  75540. /**
  75541. * Set the alpha test sort comparison function.
  75542. * If null the sub meshes will be render in the order they were created
  75543. */
  75544. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  75545. /**
  75546. * Set the transparent sort comparison function.
  75547. * If null the sub meshes will be render in the order they were created
  75548. */
  75549. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  75550. /**
  75551. * Creates a new rendering group.
  75552. * @param index The rendering group index
  75553. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  75554. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  75555. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  75556. */
  75557. 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>);
  75558. /**
  75559. * Render all the sub meshes contained in the group.
  75560. * @param customRenderFunction Used to override the default render behaviour of the group.
  75561. * @returns true if rendered some submeshes.
  75562. */
  75563. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  75564. /**
  75565. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  75566. * @param subMeshes The submeshes to render
  75567. */
  75568. private renderOpaqueSorted;
  75569. /**
  75570. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  75571. * @param subMeshes The submeshes to render
  75572. */
  75573. private renderAlphaTestSorted;
  75574. /**
  75575. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  75576. * @param subMeshes The submeshes to render
  75577. */
  75578. private renderTransparentSorted;
  75579. /**
  75580. * Renders the submeshes in a specified order.
  75581. * @param subMeshes The submeshes to sort before render
  75582. * @param sortCompareFn The comparison function use to sort
  75583. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  75584. * @param transparent Specifies to activate blending if true
  75585. */
  75586. private static renderSorted;
  75587. /**
  75588. * Renders the submeshes in the order they were dispatched (no sort applied).
  75589. * @param subMeshes The submeshes to render
  75590. */
  75591. private static renderUnsorted;
  75592. /**
  75593. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  75594. * are rendered back to front if in the same alpha index.
  75595. *
  75596. * @param a The first submesh
  75597. * @param b The second submesh
  75598. * @returns The result of the comparison
  75599. */
  75600. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  75601. /**
  75602. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  75603. * are rendered back to front.
  75604. *
  75605. * @param a The first submesh
  75606. * @param b The second submesh
  75607. * @returns The result of the comparison
  75608. */
  75609. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  75610. /**
  75611. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  75612. * are rendered front to back (prevent overdraw).
  75613. *
  75614. * @param a The first submesh
  75615. * @param b The second submesh
  75616. * @returns The result of the comparison
  75617. */
  75618. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  75619. /**
  75620. * Resets the different lists of submeshes to prepare a new frame.
  75621. */
  75622. prepare(): void;
  75623. dispose(): void;
  75624. /**
  75625. * Inserts the submesh in its correct queue depending on its material.
  75626. * @param subMesh The submesh to dispatch
  75627. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  75628. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  75629. */
  75630. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  75631. dispatchSprites(spriteManager: ISpriteManager): void;
  75632. dispatchParticles(particleSystem: IParticleSystem): void;
  75633. private _renderParticles;
  75634. private _renderSprites;
  75635. }
  75636. }
  75637. declare module BABYLON {
  75638. /**
  75639. * Interface describing the different options available in the rendering manager
  75640. * regarding Auto Clear between groups.
  75641. */
  75642. export interface IRenderingManagerAutoClearSetup {
  75643. /**
  75644. * Defines whether or not autoclear is enable.
  75645. */
  75646. autoClear: boolean;
  75647. /**
  75648. * Defines whether or not to autoclear the depth buffer.
  75649. */
  75650. depth: boolean;
  75651. /**
  75652. * Defines whether or not to autoclear the stencil buffer.
  75653. */
  75654. stencil: boolean;
  75655. }
  75656. /**
  75657. * This class is used by the onRenderingGroupObservable
  75658. */
  75659. export class RenderingGroupInfo {
  75660. /**
  75661. * The Scene that being rendered
  75662. */
  75663. scene: Scene;
  75664. /**
  75665. * The camera currently used for the rendering pass
  75666. */
  75667. camera: Nullable<Camera>;
  75668. /**
  75669. * The ID of the renderingGroup being processed
  75670. */
  75671. renderingGroupId: number;
  75672. }
  75673. /**
  75674. * This is the manager responsible of all the rendering for meshes sprites and particles.
  75675. * It is enable to manage the different groups as well as the different necessary sort functions.
  75676. * This should not be used directly aside of the few static configurations
  75677. */
  75678. export class RenderingManager {
  75679. /**
  75680. * The max id used for rendering groups (not included)
  75681. */
  75682. static MAX_RENDERINGGROUPS: number;
  75683. /**
  75684. * The min id used for rendering groups (included)
  75685. */
  75686. static MIN_RENDERINGGROUPS: number;
  75687. /**
  75688. * Used to globally prevent autoclearing scenes.
  75689. */
  75690. static AUTOCLEAR: boolean;
  75691. /**
  75692. * @hidden
  75693. */
  75694. _useSceneAutoClearSetup: boolean;
  75695. private _scene;
  75696. private _renderingGroups;
  75697. private _depthStencilBufferAlreadyCleaned;
  75698. private _autoClearDepthStencil;
  75699. private _customOpaqueSortCompareFn;
  75700. private _customAlphaTestSortCompareFn;
  75701. private _customTransparentSortCompareFn;
  75702. private _renderingGroupInfo;
  75703. /**
  75704. * Instantiates a new rendering group for a particular scene
  75705. * @param scene Defines the scene the groups belongs to
  75706. */
  75707. constructor(scene: Scene);
  75708. private _clearDepthStencilBuffer;
  75709. /**
  75710. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  75711. * @hidden
  75712. */
  75713. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  75714. /**
  75715. * Resets the different information of the group to prepare a new frame
  75716. * @hidden
  75717. */
  75718. reset(): void;
  75719. /**
  75720. * Dispose and release the group and its associated resources.
  75721. * @hidden
  75722. */
  75723. dispose(): void;
  75724. /**
  75725. * Clear the info related to rendering groups preventing retention points during dispose.
  75726. */
  75727. freeRenderingGroups(): void;
  75728. private _prepareRenderingGroup;
  75729. /**
  75730. * Add a sprite manager to the rendering manager in order to render it this frame.
  75731. * @param spriteManager Define the sprite manager to render
  75732. */
  75733. dispatchSprites(spriteManager: ISpriteManager): void;
  75734. /**
  75735. * Add a particle system to the rendering manager in order to render it this frame.
  75736. * @param particleSystem Define the particle system to render
  75737. */
  75738. dispatchParticles(particleSystem: IParticleSystem): void;
  75739. /**
  75740. * Add a submesh to the manager in order to render it this frame
  75741. * @param subMesh The submesh to dispatch
  75742. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  75743. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  75744. */
  75745. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  75746. /**
  75747. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  75748. * This allowed control for front to back rendering or reversly depending of the special needs.
  75749. *
  75750. * @param renderingGroupId The rendering group id corresponding to its index
  75751. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  75752. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  75753. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  75754. */
  75755. 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;
  75756. /**
  75757. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  75758. *
  75759. * @param renderingGroupId The rendering group id corresponding to its index
  75760. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  75761. * @param depth Automatically clears depth between groups if true and autoClear is true.
  75762. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  75763. */
  75764. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  75765. /**
  75766. * Gets the current auto clear configuration for one rendering group of the rendering
  75767. * manager.
  75768. * @param index the rendering group index to get the information for
  75769. * @returns The auto clear setup for the requested rendering group
  75770. */
  75771. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  75772. }
  75773. }
  75774. declare module BABYLON {
  75775. /**
  75776. * This Helps creating a texture that will be created from a camera in your scene.
  75777. * It is basically a dynamic texture that could be used to create special effects for instance.
  75778. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  75779. */
  75780. export class RenderTargetTexture extends Texture {
  75781. isCube: boolean;
  75782. /**
  75783. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  75784. */
  75785. static readonly REFRESHRATE_RENDER_ONCE: number;
  75786. /**
  75787. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  75788. */
  75789. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  75790. /**
  75791. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  75792. * the central point of your effect and can save a lot of performances.
  75793. */
  75794. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  75795. /**
  75796. * Use this predicate to dynamically define the list of mesh you want to render.
  75797. * If set, the renderList property will be overwritten.
  75798. */
  75799. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  75800. private _renderList;
  75801. /**
  75802. * Use this list to define the list of mesh you want to render.
  75803. */
  75804. renderList: Nullable<Array<AbstractMesh>>;
  75805. private _hookArray;
  75806. /**
  75807. * Define if particles should be rendered in your texture.
  75808. */
  75809. renderParticles: boolean;
  75810. /**
  75811. * Define if sprites should be rendered in your texture.
  75812. */
  75813. renderSprites: boolean;
  75814. /**
  75815. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  75816. */
  75817. coordinatesMode: number;
  75818. /**
  75819. * Define the camera used to render the texture.
  75820. */
  75821. activeCamera: Nullable<Camera>;
  75822. /**
  75823. * Override the render function of the texture with your own one.
  75824. */
  75825. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  75826. /**
  75827. * Define if camera post processes should be use while rendering the texture.
  75828. */
  75829. useCameraPostProcesses: boolean;
  75830. /**
  75831. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  75832. */
  75833. ignoreCameraViewport: boolean;
  75834. private _postProcessManager;
  75835. private _postProcesses;
  75836. private _resizeObserver;
  75837. /**
  75838. * An event triggered when the texture is unbind.
  75839. */
  75840. onBeforeBindObservable: Observable<RenderTargetTexture>;
  75841. /**
  75842. * An event triggered when the texture is unbind.
  75843. */
  75844. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  75845. private _onAfterUnbindObserver;
  75846. /**
  75847. * Set a after unbind callback in the texture.
  75848. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  75849. */
  75850. onAfterUnbind: () => void;
  75851. /**
  75852. * An event triggered before rendering the texture
  75853. */
  75854. onBeforeRenderObservable: Observable<number>;
  75855. private _onBeforeRenderObserver;
  75856. /**
  75857. * Set a before render callback in the texture.
  75858. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  75859. */
  75860. onBeforeRender: (faceIndex: number) => void;
  75861. /**
  75862. * An event triggered after rendering the texture
  75863. */
  75864. onAfterRenderObservable: Observable<number>;
  75865. private _onAfterRenderObserver;
  75866. /**
  75867. * Set a after render callback in the texture.
  75868. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  75869. */
  75870. onAfterRender: (faceIndex: number) => void;
  75871. /**
  75872. * An event triggered after the texture clear
  75873. */
  75874. onClearObservable: Observable<Engine>;
  75875. private _onClearObserver;
  75876. /**
  75877. * Set a clear callback in the texture.
  75878. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  75879. */
  75880. onClear: (Engine: Engine) => void;
  75881. /**
  75882. * Define the clear color of the Render Target if it should be different from the scene.
  75883. */
  75884. clearColor: Color4;
  75885. protected _size: number | {
  75886. width: number;
  75887. height: number;
  75888. };
  75889. protected _initialSizeParameter: number | {
  75890. width: number;
  75891. height: number;
  75892. } | {
  75893. ratio: number;
  75894. };
  75895. protected _sizeRatio: Nullable<number>;
  75896. /** @hidden */
  75897. _generateMipMaps: boolean;
  75898. protected _renderingManager: RenderingManager;
  75899. /** @hidden */
  75900. _waitingRenderList: string[];
  75901. protected _doNotChangeAspectRatio: boolean;
  75902. protected _currentRefreshId: number;
  75903. protected _refreshRate: number;
  75904. protected _textureMatrix: Matrix;
  75905. protected _samples: number;
  75906. protected _renderTargetOptions: RenderTargetCreationOptions;
  75907. /**
  75908. * Gets render target creation options that were used.
  75909. */
  75910. readonly renderTargetOptions: RenderTargetCreationOptions;
  75911. protected _engine: Engine;
  75912. protected _onRatioRescale(): void;
  75913. /**
  75914. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  75915. * It must define where the camera used to render the texture is set
  75916. */
  75917. boundingBoxPosition: Vector3;
  75918. private _boundingBoxSize;
  75919. /**
  75920. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  75921. * When defined, the cubemap will switch to local mode
  75922. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  75923. * @example https://www.babylonjs-playground.com/#RNASML
  75924. */
  75925. boundingBoxSize: Vector3;
  75926. /**
  75927. * In case the RTT has been created with a depth texture, get the associated
  75928. * depth texture.
  75929. * Otherwise, return null.
  75930. */
  75931. depthStencilTexture: Nullable<InternalTexture>;
  75932. /**
  75933. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  75934. * or used a shadow, depth texture...
  75935. * @param name The friendly name of the texture
  75936. * @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)
  75937. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  75938. * @param generateMipMaps True if mip maps need to be generated after render.
  75939. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  75940. * @param type The type of the buffer in the RTT (int, half float, float...)
  75941. * @param isCube True if a cube texture needs to be created
  75942. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  75943. * @param generateDepthBuffer True to generate a depth buffer
  75944. * @param generateStencilBuffer True to generate a stencil buffer
  75945. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  75946. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  75947. * @param delayAllocation if the texture allocation should be delayed (default: false)
  75948. */
  75949. constructor(name: string, size: number | {
  75950. width: number;
  75951. height: number;
  75952. } | {
  75953. ratio: number;
  75954. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  75955. /**
  75956. * Creates a depth stencil texture.
  75957. * This is only available in WebGL 2 or with the depth texture extension available.
  75958. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  75959. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  75960. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  75961. */
  75962. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  75963. private _processSizeParameter;
  75964. /**
  75965. * Define the number of samples to use in case of MSAA.
  75966. * It defaults to one meaning no MSAA has been enabled.
  75967. */
  75968. samples: number;
  75969. /**
  75970. * Resets the refresh counter of the texture and start bak from scratch.
  75971. * Could be useful to regenerate the texture if it is setup to render only once.
  75972. */
  75973. resetRefreshCounter(): void;
  75974. /**
  75975. * Define the refresh rate of the texture or the rendering frequency.
  75976. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  75977. */
  75978. refreshRate: number;
  75979. /**
  75980. * Adds a post process to the render target rendering passes.
  75981. * @param postProcess define the post process to add
  75982. */
  75983. addPostProcess(postProcess: PostProcess): void;
  75984. /**
  75985. * Clear all the post processes attached to the render target
  75986. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  75987. */
  75988. clearPostProcesses(dispose?: boolean): void;
  75989. /**
  75990. * Remove one of the post process from the list of attached post processes to the texture
  75991. * @param postProcess define the post process to remove from the list
  75992. */
  75993. removePostProcess(postProcess: PostProcess): void;
  75994. /** @hidden */
  75995. _shouldRender(): boolean;
  75996. /**
  75997. * Gets the actual render size of the texture.
  75998. * @returns the width of the render size
  75999. */
  76000. getRenderSize(): number;
  76001. /**
  76002. * Gets the actual render width of the texture.
  76003. * @returns the width of the render size
  76004. */
  76005. getRenderWidth(): number;
  76006. /**
  76007. * Gets the actual render height of the texture.
  76008. * @returns the height of the render size
  76009. */
  76010. getRenderHeight(): number;
  76011. /**
  76012. * Get if the texture can be rescaled or not.
  76013. */
  76014. readonly canRescale: boolean;
  76015. /**
  76016. * Resize the texture using a ratio.
  76017. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  76018. */
  76019. scale(ratio: number): void;
  76020. /**
  76021. * Get the texture reflection matrix used to rotate/transform the reflection.
  76022. * @returns the reflection matrix
  76023. */
  76024. getReflectionTextureMatrix(): Matrix;
  76025. /**
  76026. * Resize the texture to a new desired size.
  76027. * Be carrefull as it will recreate all the data in the new texture.
  76028. * @param size Define the new size. It can be:
  76029. * - a number for squared texture,
  76030. * - an object containing { width: number, height: number }
  76031. * - or an object containing a ratio { ratio: number }
  76032. */
  76033. resize(size: number | {
  76034. width: number;
  76035. height: number;
  76036. } | {
  76037. ratio: number;
  76038. }): void;
  76039. /**
  76040. * Renders all the objects from the render list into the texture.
  76041. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  76042. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  76043. */
  76044. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  76045. private _bestReflectionRenderTargetDimension;
  76046. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  76047. private renderToTarget;
  76048. /**
  76049. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  76050. * This allowed control for front to back rendering or reversly depending of the special needs.
  76051. *
  76052. * @param renderingGroupId The rendering group id corresponding to its index
  76053. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  76054. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  76055. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  76056. */
  76057. 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;
  76058. /**
  76059. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  76060. *
  76061. * @param renderingGroupId The rendering group id corresponding to its index
  76062. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  76063. */
  76064. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  76065. /**
  76066. * Clones the texture.
  76067. * @returns the cloned texture
  76068. */
  76069. clone(): RenderTargetTexture;
  76070. /**
  76071. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  76072. * @returns The JSON representation of the texture
  76073. */
  76074. serialize(): any;
  76075. /**
  76076. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  76077. */
  76078. disposeFramebufferObjects(): void;
  76079. /**
  76080. * Dispose the texture and release its associated resources.
  76081. */
  76082. dispose(): void;
  76083. /** @hidden */
  76084. _rebuild(): void;
  76085. /**
  76086. * Clear the info related to rendering groups preventing retention point in material dispose.
  76087. */
  76088. freeRenderingGroups(): void;
  76089. }
  76090. }
  76091. declare module BABYLON {
  76092. /**
  76093. * Mirror texture can be used to simulate the view from a mirror in a scene.
  76094. * It will dynamically be rendered every frame to adapt to the camera point of view.
  76095. * You can then easily use it as a reflectionTexture on a flat surface.
  76096. * In case the surface is not a plane, please consider relying on reflection probes.
  76097. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  76098. */
  76099. export class MirrorTexture extends RenderTargetTexture {
  76100. private scene;
  76101. /**
  76102. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  76103. * 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.
  76104. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  76105. */
  76106. mirrorPlane: Plane;
  76107. /**
  76108. * Define the blur ratio used to blur the reflection if needed.
  76109. */
  76110. blurRatio: number;
  76111. /**
  76112. * Define the adaptive blur kernel used to blur the reflection if needed.
  76113. * This will autocompute the closest best match for the `blurKernel`
  76114. */
  76115. adaptiveBlurKernel: number;
  76116. /**
  76117. * Define the blur kernel used to blur the reflection if needed.
  76118. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  76119. */
  76120. blurKernel: number;
  76121. /**
  76122. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  76123. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  76124. */
  76125. blurKernelX: number;
  76126. /**
  76127. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  76128. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  76129. */
  76130. blurKernelY: number;
  76131. private _autoComputeBlurKernel;
  76132. protected _onRatioRescale(): void;
  76133. private _updateGammaSpace;
  76134. private _imageProcessingConfigChangeObserver;
  76135. private _transformMatrix;
  76136. private _mirrorMatrix;
  76137. private _savedViewMatrix;
  76138. private _blurX;
  76139. private _blurY;
  76140. private _adaptiveBlurKernel;
  76141. private _blurKernelX;
  76142. private _blurKernelY;
  76143. private _blurRatio;
  76144. /**
  76145. * Instantiates a Mirror Texture.
  76146. * Mirror texture can be used to simulate the view from a mirror in a scene.
  76147. * It will dynamically be rendered every frame to adapt to the camera point of view.
  76148. * You can then easily use it as a reflectionTexture on a flat surface.
  76149. * In case the surface is not a plane, please consider relying on reflection probes.
  76150. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  76151. * @param name
  76152. * @param size
  76153. * @param scene
  76154. * @param generateMipMaps
  76155. * @param type
  76156. * @param samplingMode
  76157. * @param generateDepthBuffer
  76158. */
  76159. constructor(name: string, size: number | {
  76160. width: number;
  76161. height: number;
  76162. } | {
  76163. ratio: number;
  76164. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  76165. private _preparePostProcesses;
  76166. /**
  76167. * Clone the mirror texture.
  76168. * @returns the cloned texture
  76169. */
  76170. clone(): MirrorTexture;
  76171. /**
  76172. * Serialize the texture to a JSON representation you could use in Parse later on
  76173. * @returns the serialized JSON representation
  76174. */
  76175. serialize(): any;
  76176. /**
  76177. * Dispose the texture and release its associated resources.
  76178. */
  76179. dispose(): void;
  76180. }
  76181. }
  76182. declare module BABYLON {
  76183. /**
  76184. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  76185. * @see http://doc.babylonjs.com/babylon101/materials#texture
  76186. */
  76187. export class Texture extends BaseTexture {
  76188. /** @hidden */
  76189. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  76190. /** @hidden */
  76191. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  76192. /** @hidden */
  76193. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  76194. /** nearest is mag = nearest and min = nearest and mip = linear */
  76195. static readonly NEAREST_SAMPLINGMODE: number;
  76196. /** nearest is mag = nearest and min = nearest and mip = linear */
  76197. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  76198. /** Bilinear is mag = linear and min = linear and mip = nearest */
  76199. static readonly BILINEAR_SAMPLINGMODE: number;
  76200. /** Bilinear is mag = linear and min = linear and mip = nearest */
  76201. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  76202. /** Trilinear is mag = linear and min = linear and mip = linear */
  76203. static readonly TRILINEAR_SAMPLINGMODE: number;
  76204. /** Trilinear is mag = linear and min = linear and mip = linear */
  76205. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  76206. /** mag = nearest and min = nearest and mip = nearest */
  76207. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  76208. /** mag = nearest and min = linear and mip = nearest */
  76209. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  76210. /** mag = nearest and min = linear and mip = linear */
  76211. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  76212. /** mag = nearest and min = linear and mip = none */
  76213. static readonly NEAREST_LINEAR: number;
  76214. /** mag = nearest and min = nearest and mip = none */
  76215. static readonly NEAREST_NEAREST: number;
  76216. /** mag = linear and min = nearest and mip = nearest */
  76217. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  76218. /** mag = linear and min = nearest and mip = linear */
  76219. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  76220. /** mag = linear and min = linear and mip = none */
  76221. static readonly LINEAR_LINEAR: number;
  76222. /** mag = linear and min = nearest and mip = none */
  76223. static readonly LINEAR_NEAREST: number;
  76224. /** Explicit coordinates mode */
  76225. static readonly EXPLICIT_MODE: number;
  76226. /** Spherical coordinates mode */
  76227. static readonly SPHERICAL_MODE: number;
  76228. /** Planar coordinates mode */
  76229. static readonly PLANAR_MODE: number;
  76230. /** Cubic coordinates mode */
  76231. static readonly CUBIC_MODE: number;
  76232. /** Projection coordinates mode */
  76233. static readonly PROJECTION_MODE: number;
  76234. /** Inverse Cubic coordinates mode */
  76235. static readonly SKYBOX_MODE: number;
  76236. /** Inverse Cubic coordinates mode */
  76237. static readonly INVCUBIC_MODE: number;
  76238. /** Equirectangular coordinates mode */
  76239. static readonly EQUIRECTANGULAR_MODE: number;
  76240. /** Equirectangular Fixed coordinates mode */
  76241. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  76242. /** Equirectangular Fixed Mirrored coordinates mode */
  76243. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  76244. /** Texture is not repeating outside of 0..1 UVs */
  76245. static readonly CLAMP_ADDRESSMODE: number;
  76246. /** Texture is repeating outside of 0..1 UVs */
  76247. static readonly WRAP_ADDRESSMODE: number;
  76248. /** Texture is repeating and mirrored */
  76249. static readonly MIRROR_ADDRESSMODE: number;
  76250. /**
  76251. * 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
  76252. */
  76253. static UseSerializedUrlIfAny: boolean;
  76254. /**
  76255. * Define the url of the texture.
  76256. */
  76257. url: Nullable<string>;
  76258. /**
  76259. * Define an offset on the texture to offset the u coordinates of the UVs
  76260. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  76261. */
  76262. uOffset: number;
  76263. /**
  76264. * Define an offset on the texture to offset the v coordinates of the UVs
  76265. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  76266. */
  76267. vOffset: number;
  76268. /**
  76269. * Define an offset on the texture to scale the u coordinates of the UVs
  76270. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  76271. */
  76272. uScale: number;
  76273. /**
  76274. * Define an offset on the texture to scale the v coordinates of the UVs
  76275. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  76276. */
  76277. vScale: number;
  76278. /**
  76279. * Define an offset on the texture to rotate around the u coordinates of the UVs
  76280. * @see http://doc.babylonjs.com/how_to/more_materials
  76281. */
  76282. uAng: number;
  76283. /**
  76284. * Define an offset on the texture to rotate around the v coordinates of the UVs
  76285. * @see http://doc.babylonjs.com/how_to/more_materials
  76286. */
  76287. vAng: number;
  76288. /**
  76289. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  76290. * @see http://doc.babylonjs.com/how_to/more_materials
  76291. */
  76292. wAng: number;
  76293. /**
  76294. * Defines the center of rotation (U)
  76295. */
  76296. uRotationCenter: number;
  76297. /**
  76298. * Defines the center of rotation (V)
  76299. */
  76300. vRotationCenter: number;
  76301. /**
  76302. * Defines the center of rotation (W)
  76303. */
  76304. wRotationCenter: number;
  76305. /**
  76306. * Are mip maps generated for this texture or not.
  76307. */
  76308. readonly noMipmap: boolean;
  76309. /**
  76310. * List of inspectable custom properties (used by the Inspector)
  76311. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  76312. */
  76313. inspectableCustomProperties: IInspectable[];
  76314. private _noMipmap;
  76315. /** @hidden */
  76316. _invertY: boolean;
  76317. private _rowGenerationMatrix;
  76318. private _cachedTextureMatrix;
  76319. private _projectionModeMatrix;
  76320. private _t0;
  76321. private _t1;
  76322. private _t2;
  76323. private _cachedUOffset;
  76324. private _cachedVOffset;
  76325. private _cachedUScale;
  76326. private _cachedVScale;
  76327. private _cachedUAng;
  76328. private _cachedVAng;
  76329. private _cachedWAng;
  76330. private _cachedProjectionMatrixId;
  76331. private _cachedCoordinatesMode;
  76332. /** @hidden */
  76333. protected _initialSamplingMode: number;
  76334. /** @hidden */
  76335. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  76336. private _deleteBuffer;
  76337. protected _format: Nullable<number>;
  76338. private _delayedOnLoad;
  76339. private _delayedOnError;
  76340. /**
  76341. * Observable triggered once the texture has been loaded.
  76342. */
  76343. onLoadObservable: Observable<Texture>;
  76344. protected _isBlocking: boolean;
  76345. /**
  76346. * Is the texture preventing material to render while loading.
  76347. * If false, a default texture will be used instead of the loading one during the preparation step.
  76348. */
  76349. isBlocking: boolean;
  76350. /**
  76351. * Get the current sampling mode associated with the texture.
  76352. */
  76353. readonly samplingMode: number;
  76354. /**
  76355. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  76356. */
  76357. readonly invertY: boolean;
  76358. /**
  76359. * Instantiates a new texture.
  76360. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  76361. * @see http://doc.babylonjs.com/babylon101/materials#texture
  76362. * @param url define the url of the picture to load as a texture
  76363. * @param scene define the scene the texture will belong to
  76364. * @param noMipmap define if the texture will require mip maps or not
  76365. * @param invertY define if the texture needs to be inverted on the y axis during loading
  76366. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  76367. * @param onLoad define a callback triggered when the texture has been loaded
  76368. * @param onError define a callback triggered when an error occurred during the loading session
  76369. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  76370. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  76371. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  76372. */
  76373. 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);
  76374. /**
  76375. * Update the url (and optional buffer) of this texture if url was null during construction.
  76376. * @param url the url of the texture
  76377. * @param buffer the buffer of the texture (defaults to null)
  76378. * @param onLoad callback called when the texture is loaded (defaults to null)
  76379. */
  76380. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  76381. /**
  76382. * Finish the loading sequence of a texture flagged as delayed load.
  76383. * @hidden
  76384. */
  76385. delayLoad(): void;
  76386. private _prepareRowForTextureGeneration;
  76387. /**
  76388. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  76389. * @returns the transform matrix of the texture.
  76390. */
  76391. getTextureMatrix(): Matrix;
  76392. /**
  76393. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  76394. * @returns The reflection texture transform
  76395. */
  76396. getReflectionTextureMatrix(): Matrix;
  76397. /**
  76398. * Clones the texture.
  76399. * @returns the cloned texture
  76400. */
  76401. clone(): Texture;
  76402. /**
  76403. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  76404. * @returns The JSON representation of the texture
  76405. */
  76406. serialize(): any;
  76407. /**
  76408. * Get the current class name of the texture useful for serialization or dynamic coding.
  76409. * @returns "Texture"
  76410. */
  76411. getClassName(): string;
  76412. /**
  76413. * Dispose the texture and release its associated resources.
  76414. */
  76415. dispose(): void;
  76416. /**
  76417. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  76418. * @param parsedTexture Define the JSON representation of the texture
  76419. * @param scene Define the scene the parsed texture should be instantiated in
  76420. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  76421. * @returns The parsed texture if successful
  76422. */
  76423. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  76424. /**
  76425. * Creates a texture from its base 64 representation.
  76426. * @param data Define the base64 payload without the data: prefix
  76427. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  76428. * @param scene Define the scene the texture should belong to
  76429. * @param noMipmap Forces the texture to not create mip map information if true
  76430. * @param invertY define if the texture needs to be inverted on the y axis during loading
  76431. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  76432. * @param onLoad define a callback triggered when the texture has been loaded
  76433. * @param onError define a callback triggered when an error occurred during the loading session
  76434. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  76435. * @returns the created texture
  76436. */
  76437. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  76438. /**
  76439. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  76440. * @param data Define the base64 payload without the data: prefix
  76441. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  76442. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  76443. * @param scene Define the scene the texture should belong to
  76444. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  76445. * @param noMipmap Forces the texture to not create mip map information if true
  76446. * @param invertY define if the texture needs to be inverted on the y axis during loading
  76447. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  76448. * @param onLoad define a callback triggered when the texture has been loaded
  76449. * @param onError define a callback triggered when an error occurred during the loading session
  76450. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  76451. * @returns the created texture
  76452. */
  76453. 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;
  76454. }
  76455. }
  76456. declare module BABYLON {
  76457. /**
  76458. * Raw texture can help creating a texture directly from an array of data.
  76459. * This can be super useful if you either get the data from an uncompressed source or
  76460. * if you wish to create your texture pixel by pixel.
  76461. */
  76462. export class RawTexture extends Texture {
  76463. /**
  76464. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76465. */
  76466. format: number;
  76467. private _engine;
  76468. /**
  76469. * Instantiates a new RawTexture.
  76470. * Raw texture can help creating a texture directly from an array of data.
  76471. * This can be super useful if you either get the data from an uncompressed source or
  76472. * if you wish to create your texture pixel by pixel.
  76473. * @param data define the array of data to use to create the texture
  76474. * @param width define the width of the texture
  76475. * @param height define the height of the texture
  76476. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76477. * @param scene define the scene the texture belongs to
  76478. * @param generateMipMaps define whether mip maps should be generated or not
  76479. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76480. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76481. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76482. */
  76483. constructor(data: ArrayBufferView, width: number, height: number,
  76484. /**
  76485. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76486. */
  76487. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  76488. /**
  76489. * Updates the texture underlying data.
  76490. * @param data Define the new data of the texture
  76491. */
  76492. update(data: ArrayBufferView): void;
  76493. /**
  76494. * Creates a luminance texture from some data.
  76495. * @param data Define the texture data
  76496. * @param width Define the width of the texture
  76497. * @param height Define the height of the texture
  76498. * @param scene Define the scene the texture belongs to
  76499. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76500. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76501. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76502. * @returns the luminance texture
  76503. */
  76504. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76505. /**
  76506. * Creates a luminance alpha texture from some data.
  76507. * @param data Define the texture data
  76508. * @param width Define the width of the texture
  76509. * @param height Define the height of the texture
  76510. * @param scene Define the scene the texture belongs to
  76511. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76512. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76513. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76514. * @returns the luminance alpha texture
  76515. */
  76516. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76517. /**
  76518. * Creates an alpha texture from some data.
  76519. * @param data Define the texture data
  76520. * @param width Define the width of the texture
  76521. * @param height Define the height of the texture
  76522. * @param scene Define the scene the texture belongs to
  76523. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76524. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76525. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76526. * @returns the alpha texture
  76527. */
  76528. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76529. /**
  76530. * Creates a RGB texture from some data.
  76531. * @param data Define the texture data
  76532. * @param width Define the width of the texture
  76533. * @param height Define the height of the texture
  76534. * @param scene Define the scene the texture belongs to
  76535. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76536. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76537. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76538. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76539. * @returns the RGB alpha texture
  76540. */
  76541. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76542. /**
  76543. * Creates a RGBA texture from some data.
  76544. * @param data Define the texture data
  76545. * @param width Define the width of the texture
  76546. * @param height Define the height of the texture
  76547. * @param scene Define the scene the texture belongs to
  76548. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76549. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76550. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76551. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76552. * @returns the RGBA texture
  76553. */
  76554. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76555. /**
  76556. * Creates a R texture from some data.
  76557. * @param data Define the texture data
  76558. * @param width Define the width of the texture
  76559. * @param height Define the height of the texture
  76560. * @param scene Define the scene the texture belongs to
  76561. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76562. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76563. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76564. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76565. * @returns the R texture
  76566. */
  76567. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76568. }
  76569. }
  76570. declare module BABYLON {
  76571. /**
  76572. * Defines a runtime animation
  76573. */
  76574. export class RuntimeAnimation {
  76575. private _events;
  76576. /**
  76577. * The current frame of the runtime animation
  76578. */
  76579. private _currentFrame;
  76580. /**
  76581. * The animation used by the runtime animation
  76582. */
  76583. private _animation;
  76584. /**
  76585. * The target of the runtime animation
  76586. */
  76587. private _target;
  76588. /**
  76589. * The initiating animatable
  76590. */
  76591. private _host;
  76592. /**
  76593. * The original value of the runtime animation
  76594. */
  76595. private _originalValue;
  76596. /**
  76597. * The original blend value of the runtime animation
  76598. */
  76599. private _originalBlendValue;
  76600. /**
  76601. * The offsets cache of the runtime animation
  76602. */
  76603. private _offsetsCache;
  76604. /**
  76605. * The high limits cache of the runtime animation
  76606. */
  76607. private _highLimitsCache;
  76608. /**
  76609. * Specifies if the runtime animation has been stopped
  76610. */
  76611. private _stopped;
  76612. /**
  76613. * The blending factor of the runtime animation
  76614. */
  76615. private _blendingFactor;
  76616. /**
  76617. * The BabylonJS scene
  76618. */
  76619. private _scene;
  76620. /**
  76621. * The current value of the runtime animation
  76622. */
  76623. private _currentValue;
  76624. /** @hidden */
  76625. _workValue: any;
  76626. /**
  76627. * The active target of the runtime animation
  76628. */
  76629. private _activeTarget;
  76630. /**
  76631. * The target path of the runtime animation
  76632. */
  76633. private _targetPath;
  76634. /**
  76635. * The weight of the runtime animation
  76636. */
  76637. private _weight;
  76638. /**
  76639. * The ratio offset of the runtime animation
  76640. */
  76641. private _ratioOffset;
  76642. /**
  76643. * The previous delay of the runtime animation
  76644. */
  76645. private _previousDelay;
  76646. /**
  76647. * The previous ratio of the runtime animation
  76648. */
  76649. private _previousRatio;
  76650. /**
  76651. * Gets the current frame of the runtime animation
  76652. */
  76653. readonly currentFrame: number;
  76654. /**
  76655. * Gets the weight of the runtime animation
  76656. */
  76657. readonly weight: number;
  76658. /**
  76659. * Gets the current value of the runtime animation
  76660. */
  76661. readonly currentValue: any;
  76662. /**
  76663. * Gets the target path of the runtime animation
  76664. */
  76665. readonly targetPath: string;
  76666. /**
  76667. * Gets the actual target of the runtime animation
  76668. */
  76669. readonly target: any;
  76670. /**
  76671. * Create a new RuntimeAnimation object
  76672. * @param target defines the target of the animation
  76673. * @param animation defines the source animation object
  76674. * @param scene defines the hosting scene
  76675. * @param host defines the initiating Animatable
  76676. */
  76677. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  76678. /**
  76679. * Gets the animation from the runtime animation
  76680. */
  76681. readonly animation: Animation;
  76682. /**
  76683. * Resets the runtime animation to the beginning
  76684. * @param restoreOriginal defines whether to restore the target property to the original value
  76685. */
  76686. reset(restoreOriginal?: boolean): void;
  76687. /**
  76688. * Specifies if the runtime animation is stopped
  76689. * @returns Boolean specifying if the runtime animation is stopped
  76690. */
  76691. isStopped(): boolean;
  76692. /**
  76693. * Disposes of the runtime animation
  76694. */
  76695. dispose(): void;
  76696. /**
  76697. * Interpolates the animation from the current frame
  76698. * @param currentFrame The frame to interpolate the animation to
  76699. * @param repeatCount The number of times that the animation should loop
  76700. * @param loopMode The type of looping mode to use
  76701. * @param offsetValue Animation offset value
  76702. * @param highLimitValue The high limit value
  76703. * @returns The interpolated value
  76704. */
  76705. private _interpolate;
  76706. /**
  76707. * Apply the interpolated value to the target
  76708. * @param currentValue defines the value computed by the animation
  76709. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  76710. */
  76711. setValue(currentValue: any, weight?: number): void;
  76712. private _setValue;
  76713. /**
  76714. * Gets the loop pmode of the runtime animation
  76715. * @returns Loop Mode
  76716. */
  76717. private _getCorrectLoopMode;
  76718. /**
  76719. * Move the current animation to a given frame
  76720. * @param frame defines the frame to move to
  76721. */
  76722. goToFrame(frame: number): void;
  76723. /**
  76724. * @hidden Internal use only
  76725. */
  76726. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  76727. /**
  76728. * Execute the current animation
  76729. * @param delay defines the delay to add to the current frame
  76730. * @param from defines the lower bound of the animation range
  76731. * @param to defines the upper bound of the animation range
  76732. * @param loop defines if the current animation must loop
  76733. * @param speedRatio defines the current speed ratio
  76734. * @param weight defines the weight of the animation (default is -1 so no weight)
  76735. * @param onLoop optional callback called when animation loops
  76736. * @returns a boolean indicating if the animation is running
  76737. */
  76738. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  76739. }
  76740. }
  76741. declare module BABYLON {
  76742. /**
  76743. * Class used to store an actual running animation
  76744. */
  76745. export class Animatable {
  76746. /** defines the target object */
  76747. target: any;
  76748. /** defines the starting frame number (default is 0) */
  76749. fromFrame: number;
  76750. /** defines the ending frame number (default is 100) */
  76751. toFrame: number;
  76752. /** defines if the animation must loop (default is false) */
  76753. loopAnimation: boolean;
  76754. /** defines a callback to call when animation ends if it is not looping */
  76755. onAnimationEnd?: (() => void) | null | undefined;
  76756. /** defines a callback to call when animation loops */
  76757. onAnimationLoop?: (() => void) | null | undefined;
  76758. private _localDelayOffset;
  76759. private _pausedDelay;
  76760. private _runtimeAnimations;
  76761. private _paused;
  76762. private _scene;
  76763. private _speedRatio;
  76764. private _weight;
  76765. private _syncRoot;
  76766. /**
  76767. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  76768. * This will only apply for non looping animation (default is true)
  76769. */
  76770. disposeOnEnd: boolean;
  76771. /**
  76772. * Gets a boolean indicating if the animation has started
  76773. */
  76774. animationStarted: boolean;
  76775. /**
  76776. * Observer raised when the animation ends
  76777. */
  76778. onAnimationEndObservable: Observable<Animatable>;
  76779. /**
  76780. * Observer raised when the animation loops
  76781. */
  76782. onAnimationLoopObservable: Observable<Animatable>;
  76783. /**
  76784. * Gets the root Animatable used to synchronize and normalize animations
  76785. */
  76786. readonly syncRoot: Animatable;
  76787. /**
  76788. * Gets the current frame of the first RuntimeAnimation
  76789. * Used to synchronize Animatables
  76790. */
  76791. readonly masterFrame: number;
  76792. /**
  76793. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  76794. */
  76795. weight: number;
  76796. /**
  76797. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  76798. */
  76799. speedRatio: number;
  76800. /**
  76801. * Creates a new Animatable
  76802. * @param scene defines the hosting scene
  76803. * @param target defines the target object
  76804. * @param fromFrame defines the starting frame number (default is 0)
  76805. * @param toFrame defines the ending frame number (default is 100)
  76806. * @param loopAnimation defines if the animation must loop (default is false)
  76807. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  76808. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  76809. * @param animations defines a group of animation to add to the new Animatable
  76810. * @param onAnimationLoop defines a callback to call when animation loops
  76811. */
  76812. constructor(scene: Scene,
  76813. /** defines the target object */
  76814. target: any,
  76815. /** defines the starting frame number (default is 0) */
  76816. fromFrame?: number,
  76817. /** defines the ending frame number (default is 100) */
  76818. toFrame?: number,
  76819. /** defines if the animation must loop (default is false) */
  76820. loopAnimation?: boolean, speedRatio?: number,
  76821. /** defines a callback to call when animation ends if it is not looping */
  76822. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  76823. /** defines a callback to call when animation loops */
  76824. onAnimationLoop?: (() => void) | null | undefined);
  76825. /**
  76826. * Synchronize and normalize current Animatable with a source Animatable
  76827. * This is useful when using animation weights and when animations are not of the same length
  76828. * @param root defines the root Animatable to synchronize with
  76829. * @returns the current Animatable
  76830. */
  76831. syncWith(root: Animatable): Animatable;
  76832. /**
  76833. * Gets the list of runtime animations
  76834. * @returns an array of RuntimeAnimation
  76835. */
  76836. getAnimations(): RuntimeAnimation[];
  76837. /**
  76838. * Adds more animations to the current animatable
  76839. * @param target defines the target of the animations
  76840. * @param animations defines the new animations to add
  76841. */
  76842. appendAnimations(target: any, animations: Animation[]): void;
  76843. /**
  76844. * Gets the source animation for a specific property
  76845. * @param property defines the propertyu to look for
  76846. * @returns null or the source animation for the given property
  76847. */
  76848. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  76849. /**
  76850. * Gets the runtime animation for a specific property
  76851. * @param property defines the propertyu to look for
  76852. * @returns null or the runtime animation for the given property
  76853. */
  76854. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  76855. /**
  76856. * Resets the animatable to its original state
  76857. */
  76858. reset(): void;
  76859. /**
  76860. * Allows the animatable to blend with current running animations
  76861. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  76862. * @param blendingSpeed defines the blending speed to use
  76863. */
  76864. enableBlending(blendingSpeed: number): void;
  76865. /**
  76866. * Disable animation blending
  76867. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  76868. */
  76869. disableBlending(): void;
  76870. /**
  76871. * Jump directly to a given frame
  76872. * @param frame defines the frame to jump to
  76873. */
  76874. goToFrame(frame: number): void;
  76875. /**
  76876. * Pause the animation
  76877. */
  76878. pause(): void;
  76879. /**
  76880. * Restart the animation
  76881. */
  76882. restart(): void;
  76883. private _raiseOnAnimationEnd;
  76884. /**
  76885. * Stop and delete the current animation
  76886. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  76887. * @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)
  76888. */
  76889. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  76890. /**
  76891. * Wait asynchronously for the animation to end
  76892. * @returns a promise which will be fullfilled when the animation ends
  76893. */
  76894. waitAsync(): Promise<Animatable>;
  76895. /** @hidden */
  76896. _animate(delay: number): boolean;
  76897. }
  76898. interface Scene {
  76899. /** @hidden */
  76900. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  76901. /** @hidden */
  76902. _processLateAnimationBindingsForMatrices(holder: {
  76903. totalWeight: number;
  76904. animations: RuntimeAnimation[];
  76905. originalValue: Matrix;
  76906. }): any;
  76907. /** @hidden */
  76908. _processLateAnimationBindingsForQuaternions(holder: {
  76909. totalWeight: number;
  76910. animations: RuntimeAnimation[];
  76911. originalValue: Quaternion;
  76912. }, refQuaternion: Quaternion): Quaternion;
  76913. /** @hidden */
  76914. _processLateAnimationBindings(): void;
  76915. /**
  76916. * Will start the animation sequence of a given target
  76917. * @param target defines the target
  76918. * @param from defines from which frame should animation start
  76919. * @param to defines until which frame should animation run.
  76920. * @param weight defines the weight to apply to the animation (1.0 by default)
  76921. * @param loop defines if the animation loops
  76922. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76923. * @param onAnimationEnd defines the function to be executed when the animation ends
  76924. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76925. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  76926. * @param onAnimationLoop defines the callback to call when an animation loops
  76927. * @returns the animatable object created for this animation
  76928. */
  76929. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  76930. /**
  76931. * Will start the animation sequence of a given target
  76932. * @param target defines the target
  76933. * @param from defines from which frame should animation start
  76934. * @param to defines until which frame should animation run.
  76935. * @param loop defines if the animation loops
  76936. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76937. * @param onAnimationEnd defines the function to be executed when the animation ends
  76938. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76939. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  76940. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  76941. * @param onAnimationLoop defines the callback to call when an animation loops
  76942. * @returns the animatable object created for this animation
  76943. */
  76944. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  76945. /**
  76946. * Will start the animation sequence of a given target and its hierarchy
  76947. * @param target defines the target
  76948. * @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.
  76949. * @param from defines from which frame should animation start
  76950. * @param to defines until which frame should animation run.
  76951. * @param loop defines if the animation loops
  76952. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76953. * @param onAnimationEnd defines the function to be executed when the animation ends
  76954. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76955. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  76956. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  76957. * @param onAnimationLoop defines the callback to call when an animation loops
  76958. * @returns the list of created animatables
  76959. */
  76960. 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[];
  76961. /**
  76962. * Begin a new animation on a given node
  76963. * @param target defines the target where the animation will take place
  76964. * @param animations defines the list of animations to start
  76965. * @param from defines the initial value
  76966. * @param to defines the final value
  76967. * @param loop defines if you want animation to loop (off by default)
  76968. * @param speedRatio defines the speed ratio to apply to all animations
  76969. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  76970. * @param onAnimationLoop defines the callback to call when an animation loops
  76971. * @returns the list of created animatables
  76972. */
  76973. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  76974. /**
  76975. * Begin a new animation on a given node and its hierarchy
  76976. * @param target defines the root node where the animation will take place
  76977. * @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.
  76978. * @param animations defines the list of animations to start
  76979. * @param from defines the initial value
  76980. * @param to defines the final value
  76981. * @param loop defines if you want animation to loop (off by default)
  76982. * @param speedRatio defines the speed ratio to apply to all animations
  76983. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  76984. * @param onAnimationLoop defines the callback to call when an animation loops
  76985. * @returns the list of animatables created for all nodes
  76986. */
  76987. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  76988. /**
  76989. * Gets the animatable associated with a specific target
  76990. * @param target defines the target of the animatable
  76991. * @returns the required animatable if found
  76992. */
  76993. getAnimatableByTarget(target: any): Nullable<Animatable>;
  76994. /**
  76995. * Gets all animatables associated with a given target
  76996. * @param target defines the target to look animatables for
  76997. * @returns an array of Animatables
  76998. */
  76999. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  77000. /**
  77001. * Will stop the animation of the given target
  77002. * @param target - the target
  77003. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  77004. * @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)
  77005. */
  77006. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  77007. /**
  77008. * Stops and removes all animations that have been applied to the scene
  77009. */
  77010. stopAllAnimations(): void;
  77011. }
  77012. interface Bone {
  77013. /**
  77014. * Copy an animation range from another bone
  77015. * @param source defines the source bone
  77016. * @param rangeName defines the range name to copy
  77017. * @param frameOffset defines the frame offset
  77018. * @param rescaleAsRequired defines if rescaling must be applied if required
  77019. * @param skelDimensionsRatio defines the scaling ratio
  77020. * @returns true if operation was successful
  77021. */
  77022. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  77023. }
  77024. }
  77025. declare module BABYLON {
  77026. /**
  77027. * Class used to handle skinning animations
  77028. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  77029. */
  77030. export class Skeleton implements IAnimatable {
  77031. /** defines the skeleton name */
  77032. name: string;
  77033. /** defines the skeleton Id */
  77034. id: string;
  77035. /**
  77036. * Defines the list of child bones
  77037. */
  77038. bones: Bone[];
  77039. /**
  77040. * Defines an estimate of the dimension of the skeleton at rest
  77041. */
  77042. dimensionsAtRest: Vector3;
  77043. /**
  77044. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  77045. */
  77046. needInitialSkinMatrix: boolean;
  77047. /**
  77048. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  77049. */
  77050. overrideMesh: Nullable<AbstractMesh>;
  77051. /**
  77052. * Gets the list of animations attached to this skeleton
  77053. */
  77054. animations: Array<Animation>;
  77055. private _scene;
  77056. private _isDirty;
  77057. private _transformMatrices;
  77058. private _transformMatrixTexture;
  77059. private _meshesWithPoseMatrix;
  77060. private _animatables;
  77061. private _identity;
  77062. private _synchronizedWithMesh;
  77063. private _ranges;
  77064. private _lastAbsoluteTransformsUpdateId;
  77065. private _canUseTextureForBones;
  77066. private _uniqueId;
  77067. /** @hidden */
  77068. _numBonesWithLinkedTransformNode: number;
  77069. /**
  77070. * Specifies if the skeleton should be serialized
  77071. */
  77072. doNotSerialize: boolean;
  77073. private _useTextureToStoreBoneMatrices;
  77074. /**
  77075. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  77076. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  77077. */
  77078. useTextureToStoreBoneMatrices: boolean;
  77079. private _animationPropertiesOverride;
  77080. /**
  77081. * Gets or sets the animation properties override
  77082. */
  77083. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  77084. /**
  77085. * List of inspectable custom properties (used by the Inspector)
  77086. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  77087. */
  77088. inspectableCustomProperties: IInspectable[];
  77089. /**
  77090. * An observable triggered before computing the skeleton's matrices
  77091. */
  77092. onBeforeComputeObservable: Observable<Skeleton>;
  77093. /**
  77094. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  77095. */
  77096. readonly isUsingTextureForMatrices: boolean;
  77097. /**
  77098. * Gets the unique ID of this skeleton
  77099. */
  77100. readonly uniqueId: number;
  77101. /**
  77102. * Creates a new skeleton
  77103. * @param name defines the skeleton name
  77104. * @param id defines the skeleton Id
  77105. * @param scene defines the hosting scene
  77106. */
  77107. constructor(
  77108. /** defines the skeleton name */
  77109. name: string,
  77110. /** defines the skeleton Id */
  77111. id: string, scene: Scene);
  77112. /**
  77113. * Gets the current object class name.
  77114. * @return the class name
  77115. */
  77116. getClassName(): string;
  77117. /**
  77118. * Returns an array containing the root bones
  77119. * @returns an array containing the root bones
  77120. */
  77121. getChildren(): Array<Bone>;
  77122. /**
  77123. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  77124. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  77125. * @returns a Float32Array containing matrices data
  77126. */
  77127. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  77128. /**
  77129. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  77130. * @returns a raw texture containing the data
  77131. */
  77132. getTransformMatrixTexture(): Nullable<RawTexture>;
  77133. /**
  77134. * Gets the current hosting scene
  77135. * @returns a scene object
  77136. */
  77137. getScene(): Scene;
  77138. /**
  77139. * Gets a string representing the current skeleton data
  77140. * @param fullDetails defines a boolean indicating if we want a verbose version
  77141. * @returns a string representing the current skeleton data
  77142. */
  77143. toString(fullDetails?: boolean): string;
  77144. /**
  77145. * Get bone's index searching by name
  77146. * @param name defines bone's name to search for
  77147. * @return the indice of the bone. Returns -1 if not found
  77148. */
  77149. getBoneIndexByName(name: string): number;
  77150. /**
  77151. * Creater a new animation range
  77152. * @param name defines the name of the range
  77153. * @param from defines the start key
  77154. * @param to defines the end key
  77155. */
  77156. createAnimationRange(name: string, from: number, to: number): void;
  77157. /**
  77158. * Delete a specific animation range
  77159. * @param name defines the name of the range
  77160. * @param deleteFrames defines if frames must be removed as well
  77161. */
  77162. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  77163. /**
  77164. * Gets a specific animation range
  77165. * @param name defines the name of the range to look for
  77166. * @returns the requested animation range or null if not found
  77167. */
  77168. getAnimationRange(name: string): Nullable<AnimationRange>;
  77169. /**
  77170. * Gets the list of all animation ranges defined on this skeleton
  77171. * @returns an array
  77172. */
  77173. getAnimationRanges(): Nullable<AnimationRange>[];
  77174. /**
  77175. * Copy animation range from a source skeleton.
  77176. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  77177. * @param source defines the source skeleton
  77178. * @param name defines the name of the range to copy
  77179. * @param rescaleAsRequired defines if rescaling must be applied if required
  77180. * @returns true if operation was successful
  77181. */
  77182. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  77183. /**
  77184. * Forces the skeleton to go to rest pose
  77185. */
  77186. returnToRest(): void;
  77187. private _getHighestAnimationFrame;
  77188. /**
  77189. * Begin a specific animation range
  77190. * @param name defines the name of the range to start
  77191. * @param loop defines if looping must be turned on (false by default)
  77192. * @param speedRatio defines the speed ratio to apply (1 by default)
  77193. * @param onAnimationEnd defines a callback which will be called when animation will end
  77194. * @returns a new animatable
  77195. */
  77196. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  77197. /** @hidden */
  77198. _markAsDirty(): void;
  77199. /** @hidden */
  77200. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  77201. /** @hidden */
  77202. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  77203. private _computeTransformMatrices;
  77204. /**
  77205. * Build all resources required to render a skeleton
  77206. */
  77207. prepare(): void;
  77208. /**
  77209. * Gets the list of animatables currently running for this skeleton
  77210. * @returns an array of animatables
  77211. */
  77212. getAnimatables(): IAnimatable[];
  77213. /**
  77214. * Clone the current skeleton
  77215. * @param name defines the name of the new skeleton
  77216. * @param id defines the id of the enw skeleton
  77217. * @returns the new skeleton
  77218. */
  77219. clone(name: string, id: string): Skeleton;
  77220. /**
  77221. * Enable animation blending for this skeleton
  77222. * @param blendingSpeed defines the blending speed to apply
  77223. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77224. */
  77225. enableBlending(blendingSpeed?: number): void;
  77226. /**
  77227. * Releases all resources associated with the current skeleton
  77228. */
  77229. dispose(): void;
  77230. /**
  77231. * Serialize the skeleton in a JSON object
  77232. * @returns a JSON object
  77233. */
  77234. serialize(): any;
  77235. /**
  77236. * Creates a new skeleton from serialized data
  77237. * @param parsedSkeleton defines the serialized data
  77238. * @param scene defines the hosting scene
  77239. * @returns a new skeleton
  77240. */
  77241. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  77242. /**
  77243. * Compute all node absolute transforms
  77244. * @param forceUpdate defines if computation must be done even if cache is up to date
  77245. */
  77246. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  77247. /**
  77248. * Gets the root pose matrix
  77249. * @returns a matrix
  77250. */
  77251. getPoseMatrix(): Nullable<Matrix>;
  77252. /**
  77253. * Sorts bones per internal index
  77254. */
  77255. sortBones(): void;
  77256. private _sortBones;
  77257. }
  77258. }
  77259. declare module BABYLON {
  77260. /**
  77261. * Defines a target to use with MorphTargetManager
  77262. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  77263. */
  77264. export class MorphTarget implements IAnimatable {
  77265. /** defines the name of the target */
  77266. name: string;
  77267. /**
  77268. * Gets or sets the list of animations
  77269. */
  77270. animations: Animation[];
  77271. private _scene;
  77272. private _positions;
  77273. private _normals;
  77274. private _tangents;
  77275. private _influence;
  77276. /**
  77277. * Observable raised when the influence changes
  77278. */
  77279. onInfluenceChanged: Observable<boolean>;
  77280. /** @hidden */
  77281. _onDataLayoutChanged: Observable<void>;
  77282. /**
  77283. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  77284. */
  77285. influence: number;
  77286. /**
  77287. * Gets or sets the id of the morph Target
  77288. */
  77289. id: string;
  77290. private _animationPropertiesOverride;
  77291. /**
  77292. * Gets or sets the animation properties override
  77293. */
  77294. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  77295. /**
  77296. * Creates a new MorphTarget
  77297. * @param name defines the name of the target
  77298. * @param influence defines the influence to use
  77299. * @param scene defines the scene the morphtarget belongs to
  77300. */
  77301. constructor(
  77302. /** defines the name of the target */
  77303. name: string, influence?: number, scene?: Nullable<Scene>);
  77304. /**
  77305. * Gets a boolean defining if the target contains position data
  77306. */
  77307. readonly hasPositions: boolean;
  77308. /**
  77309. * Gets a boolean defining if the target contains normal data
  77310. */
  77311. readonly hasNormals: boolean;
  77312. /**
  77313. * Gets a boolean defining if the target contains tangent data
  77314. */
  77315. readonly hasTangents: boolean;
  77316. /**
  77317. * Affects position data to this target
  77318. * @param data defines the position data to use
  77319. */
  77320. setPositions(data: Nullable<FloatArray>): void;
  77321. /**
  77322. * Gets the position data stored in this target
  77323. * @returns a FloatArray containing the position data (or null if not present)
  77324. */
  77325. getPositions(): Nullable<FloatArray>;
  77326. /**
  77327. * Affects normal data to this target
  77328. * @param data defines the normal data to use
  77329. */
  77330. setNormals(data: Nullable<FloatArray>): void;
  77331. /**
  77332. * Gets the normal data stored in this target
  77333. * @returns a FloatArray containing the normal data (or null if not present)
  77334. */
  77335. getNormals(): Nullable<FloatArray>;
  77336. /**
  77337. * Affects tangent data to this target
  77338. * @param data defines the tangent data to use
  77339. */
  77340. setTangents(data: Nullable<FloatArray>): void;
  77341. /**
  77342. * Gets the tangent data stored in this target
  77343. * @returns a FloatArray containing the tangent data (or null if not present)
  77344. */
  77345. getTangents(): Nullable<FloatArray>;
  77346. /**
  77347. * Serializes the current target into a Serialization object
  77348. * @returns the serialized object
  77349. */
  77350. serialize(): any;
  77351. /**
  77352. * Returns the string "MorphTarget"
  77353. * @returns "MorphTarget"
  77354. */
  77355. getClassName(): string;
  77356. /**
  77357. * Creates a new target from serialized data
  77358. * @param serializationObject defines the serialized data to use
  77359. * @returns a new MorphTarget
  77360. */
  77361. static Parse(serializationObject: any): MorphTarget;
  77362. /**
  77363. * Creates a MorphTarget from mesh data
  77364. * @param mesh defines the source mesh
  77365. * @param name defines the name to use for the new target
  77366. * @param influence defines the influence to attach to the target
  77367. * @returns a new MorphTarget
  77368. */
  77369. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  77370. }
  77371. }
  77372. declare module BABYLON {
  77373. /**
  77374. * This class is used to deform meshes using morphing between different targets
  77375. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  77376. */
  77377. export class MorphTargetManager {
  77378. private _targets;
  77379. private _targetInfluenceChangedObservers;
  77380. private _targetDataLayoutChangedObservers;
  77381. private _activeTargets;
  77382. private _scene;
  77383. private _influences;
  77384. private _supportsNormals;
  77385. private _supportsTangents;
  77386. private _vertexCount;
  77387. private _uniqueId;
  77388. private _tempInfluences;
  77389. /**
  77390. * Creates a new MorphTargetManager
  77391. * @param scene defines the current scene
  77392. */
  77393. constructor(scene?: Nullable<Scene>);
  77394. /**
  77395. * Gets the unique ID of this manager
  77396. */
  77397. readonly uniqueId: number;
  77398. /**
  77399. * Gets the number of vertices handled by this manager
  77400. */
  77401. readonly vertexCount: number;
  77402. /**
  77403. * Gets a boolean indicating if this manager supports morphing of normals
  77404. */
  77405. readonly supportsNormals: boolean;
  77406. /**
  77407. * Gets a boolean indicating if this manager supports morphing of tangents
  77408. */
  77409. readonly supportsTangents: boolean;
  77410. /**
  77411. * Gets the number of targets stored in this manager
  77412. */
  77413. readonly numTargets: number;
  77414. /**
  77415. * Gets the number of influencers (ie. the number of targets with influences > 0)
  77416. */
  77417. readonly numInfluencers: number;
  77418. /**
  77419. * Gets the list of influences (one per target)
  77420. */
  77421. readonly influences: Float32Array;
  77422. /**
  77423. * Gets the active target at specified index. An active target is a target with an influence > 0
  77424. * @param index defines the index to check
  77425. * @returns the requested target
  77426. */
  77427. getActiveTarget(index: number): MorphTarget;
  77428. /**
  77429. * Gets the target at specified index
  77430. * @param index defines the index to check
  77431. * @returns the requested target
  77432. */
  77433. getTarget(index: number): MorphTarget;
  77434. /**
  77435. * Add a new target to this manager
  77436. * @param target defines the target to add
  77437. */
  77438. addTarget(target: MorphTarget): void;
  77439. /**
  77440. * Removes a target from the manager
  77441. * @param target defines the target to remove
  77442. */
  77443. removeTarget(target: MorphTarget): void;
  77444. /**
  77445. * Serializes the current manager into a Serialization object
  77446. * @returns the serialized object
  77447. */
  77448. serialize(): any;
  77449. private _syncActiveTargets;
  77450. /**
  77451. * Syncrhonize the targets with all the meshes using this morph target manager
  77452. */
  77453. synchronize(): void;
  77454. /**
  77455. * Creates a new MorphTargetManager from serialized data
  77456. * @param serializationObject defines the serialized data
  77457. * @param scene defines the hosting scene
  77458. * @returns the new MorphTargetManager
  77459. */
  77460. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  77461. }
  77462. }
  77463. declare module BABYLON {
  77464. /**
  77465. * Mesh representing the gorund
  77466. */
  77467. export class GroundMesh extends Mesh {
  77468. /** If octree should be generated */
  77469. generateOctree: boolean;
  77470. private _heightQuads;
  77471. /** @hidden */
  77472. _subdivisionsX: number;
  77473. /** @hidden */
  77474. _subdivisionsY: number;
  77475. /** @hidden */
  77476. _width: number;
  77477. /** @hidden */
  77478. _height: number;
  77479. /** @hidden */
  77480. _minX: number;
  77481. /** @hidden */
  77482. _maxX: number;
  77483. /** @hidden */
  77484. _minZ: number;
  77485. /** @hidden */
  77486. _maxZ: number;
  77487. constructor(name: string, scene: Scene);
  77488. /**
  77489. * "GroundMesh"
  77490. * @returns "GroundMesh"
  77491. */
  77492. getClassName(): string;
  77493. /**
  77494. * The minimum of x and y subdivisions
  77495. */
  77496. readonly subdivisions: number;
  77497. /**
  77498. * X subdivisions
  77499. */
  77500. readonly subdivisionsX: number;
  77501. /**
  77502. * Y subdivisions
  77503. */
  77504. readonly subdivisionsY: number;
  77505. /**
  77506. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  77507. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  77508. * @param chunksCount the number of subdivisions for x and y
  77509. * @param octreeBlocksSize (Default: 32)
  77510. */
  77511. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  77512. /**
  77513. * Returns a height (y) value in the Worl system :
  77514. * the ground altitude at the coordinates (x, z) expressed in the World system.
  77515. * @param x x coordinate
  77516. * @param z z coordinate
  77517. * @returns the ground y position if (x, z) are outside the ground surface.
  77518. */
  77519. getHeightAtCoordinates(x: number, z: number): number;
  77520. /**
  77521. * Returns a normalized vector (Vector3) orthogonal to the ground
  77522. * at the ground coordinates (x, z) expressed in the World system.
  77523. * @param x x coordinate
  77524. * @param z z coordinate
  77525. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  77526. */
  77527. getNormalAtCoordinates(x: number, z: number): Vector3;
  77528. /**
  77529. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  77530. * at the ground coordinates (x, z) expressed in the World system.
  77531. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  77532. * @param x x coordinate
  77533. * @param z z coordinate
  77534. * @param ref vector to store the result
  77535. * @returns the GroundMesh.
  77536. */
  77537. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  77538. /**
  77539. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  77540. * if the ground has been updated.
  77541. * This can be used in the render loop.
  77542. * @returns the GroundMesh.
  77543. */
  77544. updateCoordinateHeights(): GroundMesh;
  77545. private _getFacetAt;
  77546. private _initHeightQuads;
  77547. private _computeHeightQuads;
  77548. /**
  77549. * Serializes this ground mesh
  77550. * @param serializationObject object to write serialization to
  77551. */
  77552. serialize(serializationObject: any): void;
  77553. /**
  77554. * Parses a serialized ground mesh
  77555. * @param parsedMesh the serialized mesh
  77556. * @param scene the scene to create the ground mesh in
  77557. * @returns the created ground mesh
  77558. */
  77559. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  77560. }
  77561. }
  77562. declare module BABYLON {
  77563. /**
  77564. * Interface for Physics-Joint data
  77565. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77566. */
  77567. export interface PhysicsJointData {
  77568. /**
  77569. * The main pivot of the joint
  77570. */
  77571. mainPivot?: Vector3;
  77572. /**
  77573. * The connected pivot of the joint
  77574. */
  77575. connectedPivot?: Vector3;
  77576. /**
  77577. * The main axis of the joint
  77578. */
  77579. mainAxis?: Vector3;
  77580. /**
  77581. * The connected axis of the joint
  77582. */
  77583. connectedAxis?: Vector3;
  77584. /**
  77585. * The collision of the joint
  77586. */
  77587. collision?: boolean;
  77588. /**
  77589. * Native Oimo/Cannon/Energy data
  77590. */
  77591. nativeParams?: any;
  77592. }
  77593. /**
  77594. * This is a holder class for the physics joint created by the physics plugin
  77595. * It holds a set of functions to control the underlying joint
  77596. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77597. */
  77598. export class PhysicsJoint {
  77599. /**
  77600. * The type of the physics joint
  77601. */
  77602. type: number;
  77603. /**
  77604. * The data for the physics joint
  77605. */
  77606. jointData: PhysicsJointData;
  77607. private _physicsJoint;
  77608. protected _physicsPlugin: IPhysicsEnginePlugin;
  77609. /**
  77610. * Initializes the physics joint
  77611. * @param type The type of the physics joint
  77612. * @param jointData The data for the physics joint
  77613. */
  77614. constructor(
  77615. /**
  77616. * The type of the physics joint
  77617. */
  77618. type: number,
  77619. /**
  77620. * The data for the physics joint
  77621. */
  77622. jointData: PhysicsJointData);
  77623. /**
  77624. * Gets the physics joint
  77625. */
  77626. /**
  77627. * Sets the physics joint
  77628. */
  77629. physicsJoint: any;
  77630. /**
  77631. * Sets the physics plugin
  77632. */
  77633. physicsPlugin: IPhysicsEnginePlugin;
  77634. /**
  77635. * Execute a function that is physics-plugin specific.
  77636. * @param {Function} func the function that will be executed.
  77637. * It accepts two parameters: the physics world and the physics joint
  77638. */
  77639. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  77640. /**
  77641. * Distance-Joint type
  77642. */
  77643. static DistanceJoint: number;
  77644. /**
  77645. * Hinge-Joint type
  77646. */
  77647. static HingeJoint: number;
  77648. /**
  77649. * Ball-and-Socket joint type
  77650. */
  77651. static BallAndSocketJoint: number;
  77652. /**
  77653. * Wheel-Joint type
  77654. */
  77655. static WheelJoint: number;
  77656. /**
  77657. * Slider-Joint type
  77658. */
  77659. static SliderJoint: number;
  77660. /**
  77661. * Prismatic-Joint type
  77662. */
  77663. static PrismaticJoint: number;
  77664. /**
  77665. * Universal-Joint type
  77666. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  77667. */
  77668. static UniversalJoint: number;
  77669. /**
  77670. * Hinge-Joint 2 type
  77671. */
  77672. static Hinge2Joint: number;
  77673. /**
  77674. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  77675. */
  77676. static PointToPointJoint: number;
  77677. /**
  77678. * Spring-Joint type
  77679. */
  77680. static SpringJoint: number;
  77681. /**
  77682. * Lock-Joint type
  77683. */
  77684. static LockJoint: number;
  77685. }
  77686. /**
  77687. * A class representing a physics distance joint
  77688. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77689. */
  77690. export class DistanceJoint extends PhysicsJoint {
  77691. /**
  77692. *
  77693. * @param jointData The data for the Distance-Joint
  77694. */
  77695. constructor(jointData: DistanceJointData);
  77696. /**
  77697. * Update the predefined distance.
  77698. * @param maxDistance The maximum preferred distance
  77699. * @param minDistance The minimum preferred distance
  77700. */
  77701. updateDistance(maxDistance: number, minDistance?: number): void;
  77702. }
  77703. /**
  77704. * Represents a Motor-Enabled Joint
  77705. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77706. */
  77707. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  77708. /**
  77709. * Initializes the Motor-Enabled Joint
  77710. * @param type The type of the joint
  77711. * @param jointData The physica joint data for the joint
  77712. */
  77713. constructor(type: number, jointData: PhysicsJointData);
  77714. /**
  77715. * Set the motor values.
  77716. * Attention, this function is plugin specific. Engines won't react 100% the same.
  77717. * @param force the force to apply
  77718. * @param maxForce max force for this motor.
  77719. */
  77720. setMotor(force?: number, maxForce?: number): void;
  77721. /**
  77722. * Set the motor's limits.
  77723. * Attention, this function is plugin specific. Engines won't react 100% the same.
  77724. * @param upperLimit The upper limit of the motor
  77725. * @param lowerLimit The lower limit of the motor
  77726. */
  77727. setLimit(upperLimit: number, lowerLimit?: number): void;
  77728. }
  77729. /**
  77730. * This class represents a single physics Hinge-Joint
  77731. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77732. */
  77733. export class HingeJoint extends MotorEnabledJoint {
  77734. /**
  77735. * Initializes the Hinge-Joint
  77736. * @param jointData The joint data for the Hinge-Joint
  77737. */
  77738. constructor(jointData: PhysicsJointData);
  77739. /**
  77740. * Set the motor values.
  77741. * Attention, this function is plugin specific. Engines won't react 100% the same.
  77742. * @param {number} force the force to apply
  77743. * @param {number} maxForce max force for this motor.
  77744. */
  77745. setMotor(force?: number, maxForce?: number): void;
  77746. /**
  77747. * Set the motor's limits.
  77748. * Attention, this function is plugin specific. Engines won't react 100% the same.
  77749. * @param upperLimit The upper limit of the motor
  77750. * @param lowerLimit The lower limit of the motor
  77751. */
  77752. setLimit(upperLimit: number, lowerLimit?: number): void;
  77753. }
  77754. /**
  77755. * This class represents a dual hinge physics joint (same as wheel joint)
  77756. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77757. */
  77758. export class Hinge2Joint extends MotorEnabledJoint {
  77759. /**
  77760. * Initializes the Hinge2-Joint
  77761. * @param jointData The joint data for the Hinge2-Joint
  77762. */
  77763. constructor(jointData: PhysicsJointData);
  77764. /**
  77765. * Set the motor values.
  77766. * Attention, this function is plugin specific. Engines won't react 100% the same.
  77767. * @param {number} targetSpeed the speed the motor is to reach
  77768. * @param {number} maxForce max force for this motor.
  77769. * @param {motorIndex} the motor's index, 0 or 1.
  77770. */
  77771. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  77772. /**
  77773. * Set the motor limits.
  77774. * Attention, this function is plugin specific. Engines won't react 100% the same.
  77775. * @param {number} upperLimit the upper limit
  77776. * @param {number} lowerLimit lower limit
  77777. * @param {motorIndex} the motor's index, 0 or 1.
  77778. */
  77779. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  77780. }
  77781. /**
  77782. * Interface for a motor enabled joint
  77783. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77784. */
  77785. export interface IMotorEnabledJoint {
  77786. /**
  77787. * Physics joint
  77788. */
  77789. physicsJoint: any;
  77790. /**
  77791. * Sets the motor of the motor-enabled joint
  77792. * @param force The force of the motor
  77793. * @param maxForce The maximum force of the motor
  77794. * @param motorIndex The index of the motor
  77795. */
  77796. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  77797. /**
  77798. * Sets the limit of the motor
  77799. * @param upperLimit The upper limit of the motor
  77800. * @param lowerLimit The lower limit of the motor
  77801. * @param motorIndex The index of the motor
  77802. */
  77803. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  77804. }
  77805. /**
  77806. * Joint data for a Distance-Joint
  77807. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77808. */
  77809. export interface DistanceJointData extends PhysicsJointData {
  77810. /**
  77811. * Max distance the 2 joint objects can be apart
  77812. */
  77813. maxDistance: number;
  77814. }
  77815. /**
  77816. * Joint data from a spring joint
  77817. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77818. */
  77819. export interface SpringJointData extends PhysicsJointData {
  77820. /**
  77821. * Length of the spring
  77822. */
  77823. length: number;
  77824. /**
  77825. * Stiffness of the spring
  77826. */
  77827. stiffness: number;
  77828. /**
  77829. * Damping of the spring
  77830. */
  77831. damping: number;
  77832. /** this callback will be called when applying the force to the impostors. */
  77833. forceApplicationCallback: () => void;
  77834. }
  77835. }
  77836. declare module BABYLON {
  77837. /**
  77838. * Holds the data for the raycast result
  77839. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77840. */
  77841. export class PhysicsRaycastResult {
  77842. private _hasHit;
  77843. private _hitDistance;
  77844. private _hitNormalWorld;
  77845. private _hitPointWorld;
  77846. private _rayFromWorld;
  77847. private _rayToWorld;
  77848. /**
  77849. * Gets if there was a hit
  77850. */
  77851. readonly hasHit: boolean;
  77852. /**
  77853. * Gets the distance from the hit
  77854. */
  77855. readonly hitDistance: number;
  77856. /**
  77857. * Gets the hit normal/direction in the world
  77858. */
  77859. readonly hitNormalWorld: Vector3;
  77860. /**
  77861. * Gets the hit point in the world
  77862. */
  77863. readonly hitPointWorld: Vector3;
  77864. /**
  77865. * Gets the ray "start point" of the ray in the world
  77866. */
  77867. readonly rayFromWorld: Vector3;
  77868. /**
  77869. * Gets the ray "end point" of the ray in the world
  77870. */
  77871. readonly rayToWorld: Vector3;
  77872. /**
  77873. * Sets the hit data (normal & point in world space)
  77874. * @param hitNormalWorld defines the normal in world space
  77875. * @param hitPointWorld defines the point in world space
  77876. */
  77877. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  77878. /**
  77879. * Sets the distance from the start point to the hit point
  77880. * @param distance
  77881. */
  77882. setHitDistance(distance: number): void;
  77883. /**
  77884. * Calculates the distance manually
  77885. */
  77886. calculateHitDistance(): void;
  77887. /**
  77888. * Resets all the values to default
  77889. * @param from The from point on world space
  77890. * @param to The to point on world space
  77891. */
  77892. reset(from?: Vector3, to?: Vector3): void;
  77893. }
  77894. /**
  77895. * Interface for the size containing width and height
  77896. */
  77897. interface IXYZ {
  77898. /**
  77899. * X
  77900. */
  77901. x: number;
  77902. /**
  77903. * Y
  77904. */
  77905. y: number;
  77906. /**
  77907. * Z
  77908. */
  77909. z: number;
  77910. }
  77911. }
  77912. declare module BABYLON {
  77913. /**
  77914. * Interface used to describe a physics joint
  77915. */
  77916. export interface PhysicsImpostorJoint {
  77917. /** Defines the main impostor to which the joint is linked */
  77918. mainImpostor: PhysicsImpostor;
  77919. /** Defines the impostor that is connected to the main impostor using this joint */
  77920. connectedImpostor: PhysicsImpostor;
  77921. /** Defines the joint itself */
  77922. joint: PhysicsJoint;
  77923. }
  77924. /** @hidden */
  77925. export interface IPhysicsEnginePlugin {
  77926. world: any;
  77927. name: string;
  77928. setGravity(gravity: Vector3): void;
  77929. setTimeStep(timeStep: number): void;
  77930. getTimeStep(): number;
  77931. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  77932. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  77933. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  77934. generatePhysicsBody(impostor: PhysicsImpostor): void;
  77935. removePhysicsBody(impostor: PhysicsImpostor): void;
  77936. generateJoint(joint: PhysicsImpostorJoint): void;
  77937. removeJoint(joint: PhysicsImpostorJoint): void;
  77938. isSupported(): boolean;
  77939. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  77940. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  77941. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  77942. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  77943. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  77944. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  77945. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  77946. getBodyMass(impostor: PhysicsImpostor): number;
  77947. getBodyFriction(impostor: PhysicsImpostor): number;
  77948. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  77949. getBodyRestitution(impostor: PhysicsImpostor): number;
  77950. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  77951. getBodyPressure?(impostor: PhysicsImpostor): number;
  77952. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  77953. getBodyStiffness?(impostor: PhysicsImpostor): number;
  77954. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  77955. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  77956. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  77957. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  77958. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  77959. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  77960. sleepBody(impostor: PhysicsImpostor): void;
  77961. wakeUpBody(impostor: PhysicsImpostor): void;
  77962. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  77963. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  77964. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  77965. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  77966. getRadius(impostor: PhysicsImpostor): number;
  77967. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  77968. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  77969. dispose(): void;
  77970. }
  77971. /**
  77972. * Interface used to define a physics engine
  77973. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  77974. */
  77975. export interface IPhysicsEngine {
  77976. /**
  77977. * Gets the gravity vector used by the simulation
  77978. */
  77979. gravity: Vector3;
  77980. /**
  77981. * Sets the gravity vector used by the simulation
  77982. * @param gravity defines the gravity vector to use
  77983. */
  77984. setGravity(gravity: Vector3): void;
  77985. /**
  77986. * Set the time step of the physics engine.
  77987. * Default is 1/60.
  77988. * To slow it down, enter 1/600 for example.
  77989. * To speed it up, 1/30
  77990. * @param newTimeStep the new timestep to apply to this world.
  77991. */
  77992. setTimeStep(newTimeStep: number): void;
  77993. /**
  77994. * Get the time step of the physics engine.
  77995. * @returns the current time step
  77996. */
  77997. getTimeStep(): number;
  77998. /**
  77999. * Release all resources
  78000. */
  78001. dispose(): void;
  78002. /**
  78003. * Gets the name of the current physics plugin
  78004. * @returns the name of the plugin
  78005. */
  78006. getPhysicsPluginName(): string;
  78007. /**
  78008. * Adding a new impostor for the impostor tracking.
  78009. * This will be done by the impostor itself.
  78010. * @param impostor the impostor to add
  78011. */
  78012. addImpostor(impostor: PhysicsImpostor): void;
  78013. /**
  78014. * Remove an impostor from the engine.
  78015. * This impostor and its mesh will not longer be updated by the physics engine.
  78016. * @param impostor the impostor to remove
  78017. */
  78018. removeImpostor(impostor: PhysicsImpostor): void;
  78019. /**
  78020. * Add a joint to the physics engine
  78021. * @param mainImpostor defines the main impostor to which the joint is added.
  78022. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  78023. * @param joint defines the joint that will connect both impostors.
  78024. */
  78025. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  78026. /**
  78027. * Removes a joint from the simulation
  78028. * @param mainImpostor defines the impostor used with the joint
  78029. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  78030. * @param joint defines the joint to remove
  78031. */
  78032. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  78033. /**
  78034. * Gets the current plugin used to run the simulation
  78035. * @returns current plugin
  78036. */
  78037. getPhysicsPlugin(): IPhysicsEnginePlugin;
  78038. /**
  78039. * Gets the list of physic impostors
  78040. * @returns an array of PhysicsImpostor
  78041. */
  78042. getImpostors(): Array<PhysicsImpostor>;
  78043. /**
  78044. * Gets the impostor for a physics enabled object
  78045. * @param object defines the object impersonated by the impostor
  78046. * @returns the PhysicsImpostor or null if not found
  78047. */
  78048. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  78049. /**
  78050. * Gets the impostor for a physics body object
  78051. * @param body defines physics body used by the impostor
  78052. * @returns the PhysicsImpostor or null if not found
  78053. */
  78054. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  78055. /**
  78056. * Does a raycast in the physics world
  78057. * @param from when should the ray start?
  78058. * @param to when should the ray end?
  78059. * @returns PhysicsRaycastResult
  78060. */
  78061. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  78062. /**
  78063. * Called by the scene. No need to call it.
  78064. * @param delta defines the timespam between frames
  78065. */
  78066. _step(delta: number): void;
  78067. }
  78068. }
  78069. declare module BABYLON {
  78070. /**
  78071. * The interface for the physics imposter parameters
  78072. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78073. */
  78074. export interface PhysicsImpostorParameters {
  78075. /**
  78076. * The mass of the physics imposter
  78077. */
  78078. mass: number;
  78079. /**
  78080. * The friction of the physics imposter
  78081. */
  78082. friction?: number;
  78083. /**
  78084. * The coefficient of restitution of the physics imposter
  78085. */
  78086. restitution?: number;
  78087. /**
  78088. * The native options of the physics imposter
  78089. */
  78090. nativeOptions?: any;
  78091. /**
  78092. * Specifies if the parent should be ignored
  78093. */
  78094. ignoreParent?: boolean;
  78095. /**
  78096. * Specifies if bi-directional transformations should be disabled
  78097. */
  78098. disableBidirectionalTransformation?: boolean;
  78099. /**
  78100. * The pressure inside the physics imposter, soft object only
  78101. */
  78102. pressure?: number;
  78103. /**
  78104. * The stiffness the physics imposter, soft object only
  78105. */
  78106. stiffness?: number;
  78107. /**
  78108. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  78109. */
  78110. velocityIterations?: number;
  78111. /**
  78112. * The number of iterations used in maintaining consistent vertex positions, soft object only
  78113. */
  78114. positionIterations?: number;
  78115. /**
  78116. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  78117. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  78118. * Add to fix multiple points
  78119. */
  78120. fixedPoints?: number;
  78121. /**
  78122. * The collision margin around a soft object
  78123. */
  78124. margin?: number;
  78125. /**
  78126. * The collision margin around a soft object
  78127. */
  78128. damping?: number;
  78129. }
  78130. /**
  78131. * Interface for a physics-enabled object
  78132. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78133. */
  78134. export interface IPhysicsEnabledObject {
  78135. /**
  78136. * The position of the physics-enabled object
  78137. */
  78138. position: Vector3;
  78139. /**
  78140. * The rotation of the physics-enabled object
  78141. */
  78142. rotationQuaternion: Nullable<Quaternion>;
  78143. /**
  78144. * The scale of the physics-enabled object
  78145. */
  78146. scaling: Vector3;
  78147. /**
  78148. * The rotation of the physics-enabled object
  78149. */
  78150. rotation?: Vector3;
  78151. /**
  78152. * The parent of the physics-enabled object
  78153. */
  78154. parent?: any;
  78155. /**
  78156. * The bounding info of the physics-enabled object
  78157. * @returns The bounding info of the physics-enabled object
  78158. */
  78159. getBoundingInfo(): BoundingInfo;
  78160. /**
  78161. * Computes the world matrix
  78162. * @param force Specifies if the world matrix should be computed by force
  78163. * @returns A world matrix
  78164. */
  78165. computeWorldMatrix(force: boolean): Matrix;
  78166. /**
  78167. * Gets the world matrix
  78168. * @returns A world matrix
  78169. */
  78170. getWorldMatrix?(): Matrix;
  78171. /**
  78172. * Gets the child meshes
  78173. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  78174. * @returns An array of abstract meshes
  78175. */
  78176. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  78177. /**
  78178. * Gets the vertex data
  78179. * @param kind The type of vertex data
  78180. * @returns A nullable array of numbers, or a float32 array
  78181. */
  78182. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  78183. /**
  78184. * Gets the indices from the mesh
  78185. * @returns A nullable array of index arrays
  78186. */
  78187. getIndices?(): Nullable<IndicesArray>;
  78188. /**
  78189. * Gets the scene from the mesh
  78190. * @returns the indices array or null
  78191. */
  78192. getScene?(): Scene;
  78193. /**
  78194. * Gets the absolute position from the mesh
  78195. * @returns the absolute position
  78196. */
  78197. getAbsolutePosition(): Vector3;
  78198. /**
  78199. * Gets the absolute pivot point from the mesh
  78200. * @returns the absolute pivot point
  78201. */
  78202. getAbsolutePivotPoint(): Vector3;
  78203. /**
  78204. * Rotates the mesh
  78205. * @param axis The axis of rotation
  78206. * @param amount The amount of rotation
  78207. * @param space The space of the rotation
  78208. * @returns The rotation transform node
  78209. */
  78210. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  78211. /**
  78212. * Translates the mesh
  78213. * @param axis The axis of translation
  78214. * @param distance The distance of translation
  78215. * @param space The space of the translation
  78216. * @returns The transform node
  78217. */
  78218. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  78219. /**
  78220. * Sets the absolute position of the mesh
  78221. * @param absolutePosition The absolute position of the mesh
  78222. * @returns The transform node
  78223. */
  78224. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  78225. /**
  78226. * Gets the class name of the mesh
  78227. * @returns The class name
  78228. */
  78229. getClassName(): string;
  78230. }
  78231. /**
  78232. * Represents a physics imposter
  78233. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78234. */
  78235. export class PhysicsImpostor {
  78236. /**
  78237. * The physics-enabled object used as the physics imposter
  78238. */
  78239. object: IPhysicsEnabledObject;
  78240. /**
  78241. * The type of the physics imposter
  78242. */
  78243. type: number;
  78244. private _options;
  78245. private _scene?;
  78246. /**
  78247. * The default object size of the imposter
  78248. */
  78249. static DEFAULT_OBJECT_SIZE: Vector3;
  78250. /**
  78251. * The identity quaternion of the imposter
  78252. */
  78253. static IDENTITY_QUATERNION: Quaternion;
  78254. /** @hidden */
  78255. _pluginData: any;
  78256. private _physicsEngine;
  78257. private _physicsBody;
  78258. private _bodyUpdateRequired;
  78259. private _onBeforePhysicsStepCallbacks;
  78260. private _onAfterPhysicsStepCallbacks;
  78261. /** @hidden */
  78262. _onPhysicsCollideCallbacks: Array<{
  78263. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  78264. otherImpostors: Array<PhysicsImpostor>;
  78265. }>;
  78266. private _deltaPosition;
  78267. private _deltaRotation;
  78268. private _deltaRotationConjugated;
  78269. private _parent;
  78270. private _isDisposed;
  78271. private static _tmpVecs;
  78272. private static _tmpQuat;
  78273. /**
  78274. * Specifies if the physics imposter is disposed
  78275. */
  78276. readonly isDisposed: boolean;
  78277. /**
  78278. * Gets the mass of the physics imposter
  78279. */
  78280. mass: number;
  78281. /**
  78282. * Gets the coefficient of friction
  78283. */
  78284. /**
  78285. * Sets the coefficient of friction
  78286. */
  78287. friction: number;
  78288. /**
  78289. * Gets the coefficient of restitution
  78290. */
  78291. /**
  78292. * Sets the coefficient of restitution
  78293. */
  78294. restitution: number;
  78295. /**
  78296. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  78297. */
  78298. /**
  78299. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  78300. */
  78301. pressure: number;
  78302. /**
  78303. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  78304. */
  78305. /**
  78306. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  78307. */
  78308. stiffness: number;
  78309. /**
  78310. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  78311. */
  78312. /**
  78313. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  78314. */
  78315. velocityIterations: number;
  78316. /**
  78317. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  78318. */
  78319. /**
  78320. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  78321. */
  78322. positionIterations: number;
  78323. /**
  78324. * The unique id of the physics imposter
  78325. * set by the physics engine when adding this impostor to the array
  78326. */
  78327. uniqueId: number;
  78328. /**
  78329. * @hidden
  78330. */
  78331. soft: boolean;
  78332. /**
  78333. * @hidden
  78334. */
  78335. segments: number;
  78336. private _joints;
  78337. /**
  78338. * Initializes the physics imposter
  78339. * @param object The physics-enabled object used as the physics imposter
  78340. * @param type The type of the physics imposter
  78341. * @param _options The options for the physics imposter
  78342. * @param _scene The Babylon scene
  78343. */
  78344. constructor(
  78345. /**
  78346. * The physics-enabled object used as the physics imposter
  78347. */
  78348. object: IPhysicsEnabledObject,
  78349. /**
  78350. * The type of the physics imposter
  78351. */
  78352. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  78353. /**
  78354. * This function will completly initialize this impostor.
  78355. * It will create a new body - but only if this mesh has no parent.
  78356. * If it has, this impostor will not be used other than to define the impostor
  78357. * of the child mesh.
  78358. * @hidden
  78359. */
  78360. _init(): void;
  78361. private _getPhysicsParent;
  78362. /**
  78363. * Should a new body be generated.
  78364. * @returns boolean specifying if body initialization is required
  78365. */
  78366. isBodyInitRequired(): boolean;
  78367. /**
  78368. * Sets the updated scaling
  78369. * @param updated Specifies if the scaling is updated
  78370. */
  78371. setScalingUpdated(): void;
  78372. /**
  78373. * Force a regeneration of this or the parent's impostor's body.
  78374. * Use under cautious - This will remove all joints already implemented.
  78375. */
  78376. forceUpdate(): void;
  78377. /**
  78378. * Gets the body that holds this impostor. Either its own, or its parent.
  78379. */
  78380. /**
  78381. * Set the physics body. Used mainly by the physics engine/plugin
  78382. */
  78383. physicsBody: any;
  78384. /**
  78385. * Get the parent of the physics imposter
  78386. * @returns Physics imposter or null
  78387. */
  78388. /**
  78389. * Sets the parent of the physics imposter
  78390. */
  78391. parent: Nullable<PhysicsImpostor>;
  78392. /**
  78393. * Resets the update flags
  78394. */
  78395. resetUpdateFlags(): void;
  78396. /**
  78397. * Gets the object extend size
  78398. * @returns the object extend size
  78399. */
  78400. getObjectExtendSize(): Vector3;
  78401. /**
  78402. * Gets the object center
  78403. * @returns The object center
  78404. */
  78405. getObjectCenter(): Vector3;
  78406. /**
  78407. * Get a specific parametes from the options parameter
  78408. * @param paramName The object parameter name
  78409. * @returns The object parameter
  78410. */
  78411. getParam(paramName: string): any;
  78412. /**
  78413. * Sets a specific parameter in the options given to the physics plugin
  78414. * @param paramName The parameter name
  78415. * @param value The value of the parameter
  78416. */
  78417. setParam(paramName: string, value: number): void;
  78418. /**
  78419. * Specifically change the body's mass option. Won't recreate the physics body object
  78420. * @param mass The mass of the physics imposter
  78421. */
  78422. setMass(mass: number): void;
  78423. /**
  78424. * Gets the linear velocity
  78425. * @returns linear velocity or null
  78426. */
  78427. getLinearVelocity(): Nullable<Vector3>;
  78428. /**
  78429. * Sets the linear velocity
  78430. * @param velocity linear velocity or null
  78431. */
  78432. setLinearVelocity(velocity: Nullable<Vector3>): void;
  78433. /**
  78434. * Gets the angular velocity
  78435. * @returns angular velocity or null
  78436. */
  78437. getAngularVelocity(): Nullable<Vector3>;
  78438. /**
  78439. * Sets the angular velocity
  78440. * @param velocity The velocity or null
  78441. */
  78442. setAngularVelocity(velocity: Nullable<Vector3>): void;
  78443. /**
  78444. * Execute a function with the physics plugin native code
  78445. * Provide a function the will have two variables - the world object and the physics body object
  78446. * @param func The function to execute with the physics plugin native code
  78447. */
  78448. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  78449. /**
  78450. * Register a function that will be executed before the physics world is stepping forward
  78451. * @param func The function to execute before the physics world is stepped forward
  78452. */
  78453. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  78454. /**
  78455. * Unregister a function that will be executed before the physics world is stepping forward
  78456. * @param func The function to execute before the physics world is stepped forward
  78457. */
  78458. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  78459. /**
  78460. * Register a function that will be executed after the physics step
  78461. * @param func The function to execute after physics step
  78462. */
  78463. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  78464. /**
  78465. * Unregisters a function that will be executed after the physics step
  78466. * @param func The function to execute after physics step
  78467. */
  78468. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  78469. /**
  78470. * register a function that will be executed when this impostor collides against a different body
  78471. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  78472. * @param func Callback that is executed on collision
  78473. */
  78474. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  78475. /**
  78476. * Unregisters the physics imposter on contact
  78477. * @param collideAgainst The physics object to collide against
  78478. * @param func Callback to execute on collision
  78479. */
  78480. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  78481. private _tmpQuat;
  78482. private _tmpQuat2;
  78483. /**
  78484. * Get the parent rotation
  78485. * @returns The parent rotation
  78486. */
  78487. getParentsRotation(): Quaternion;
  78488. /**
  78489. * this function is executed by the physics engine.
  78490. */
  78491. beforeStep: () => void;
  78492. /**
  78493. * this function is executed by the physics engine
  78494. */
  78495. afterStep: () => void;
  78496. /**
  78497. * Legacy collision detection event support
  78498. */
  78499. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  78500. /**
  78501. * event and body object due to cannon's event-based architecture.
  78502. */
  78503. onCollide: (e: {
  78504. body: any;
  78505. }) => void;
  78506. /**
  78507. * Apply a force
  78508. * @param force The force to apply
  78509. * @param contactPoint The contact point for the force
  78510. * @returns The physics imposter
  78511. */
  78512. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  78513. /**
  78514. * Apply an impulse
  78515. * @param force The impulse force
  78516. * @param contactPoint The contact point for the impulse force
  78517. * @returns The physics imposter
  78518. */
  78519. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  78520. /**
  78521. * A help function to create a joint
  78522. * @param otherImpostor A physics imposter used to create a joint
  78523. * @param jointType The type of joint
  78524. * @param jointData The data for the joint
  78525. * @returns The physics imposter
  78526. */
  78527. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  78528. /**
  78529. * Add a joint to this impostor with a different impostor
  78530. * @param otherImpostor A physics imposter used to add a joint
  78531. * @param joint The joint to add
  78532. * @returns The physics imposter
  78533. */
  78534. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  78535. /**
  78536. * Add an anchor to a soft impostor
  78537. * @param otherImpostor rigid impostor as the anchor
  78538. * @param width ratio across width from 0 to 1
  78539. * @param height ratio up height from 0 to 1
  78540. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, no strech
  78541. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  78542. * @returns impostor the soft imposter
  78543. */
  78544. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  78545. /**
  78546. * Will keep this body still, in a sleep mode.
  78547. * @returns the physics imposter
  78548. */
  78549. sleep(): PhysicsImpostor;
  78550. /**
  78551. * Wake the body up.
  78552. * @returns The physics imposter
  78553. */
  78554. wakeUp(): PhysicsImpostor;
  78555. /**
  78556. * Clones the physics imposter
  78557. * @param newObject The physics imposter clones to this physics-enabled object
  78558. * @returns A nullable physics imposter
  78559. */
  78560. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  78561. /**
  78562. * Disposes the physics imposter
  78563. */
  78564. dispose(): void;
  78565. /**
  78566. * Sets the delta position
  78567. * @param position The delta position amount
  78568. */
  78569. setDeltaPosition(position: Vector3): void;
  78570. /**
  78571. * Sets the delta rotation
  78572. * @param rotation The delta rotation amount
  78573. */
  78574. setDeltaRotation(rotation: Quaternion): void;
  78575. /**
  78576. * Gets the box size of the physics imposter and stores the result in the input parameter
  78577. * @param result Stores the box size
  78578. * @returns The physics imposter
  78579. */
  78580. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  78581. /**
  78582. * Gets the radius of the physics imposter
  78583. * @returns Radius of the physics imposter
  78584. */
  78585. getRadius(): number;
  78586. /**
  78587. * Sync a bone with this impostor
  78588. * @param bone The bone to sync to the impostor.
  78589. * @param boneMesh The mesh that the bone is influencing.
  78590. * @param jointPivot The pivot of the joint / bone in local space.
  78591. * @param distToJoint Optional distance from the impostor to the joint.
  78592. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  78593. */
  78594. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  78595. /**
  78596. * Sync impostor to a bone
  78597. * @param bone The bone that the impostor will be synced to.
  78598. * @param boneMesh The mesh that the bone is influencing.
  78599. * @param jointPivot The pivot of the joint / bone in local space.
  78600. * @param distToJoint Optional distance from the impostor to the joint.
  78601. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  78602. * @param boneAxis Optional vector3 axis the bone is aligned with
  78603. */
  78604. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  78605. /**
  78606. * No-Imposter type
  78607. */
  78608. static NoImpostor: number;
  78609. /**
  78610. * Sphere-Imposter type
  78611. */
  78612. static SphereImpostor: number;
  78613. /**
  78614. * Box-Imposter type
  78615. */
  78616. static BoxImpostor: number;
  78617. /**
  78618. * Plane-Imposter type
  78619. */
  78620. static PlaneImpostor: number;
  78621. /**
  78622. * Mesh-imposter type
  78623. */
  78624. static MeshImpostor: number;
  78625. /**
  78626. * Cylinder-Imposter type
  78627. */
  78628. static CylinderImpostor: number;
  78629. /**
  78630. * Particle-Imposter type
  78631. */
  78632. static ParticleImpostor: number;
  78633. /**
  78634. * Heightmap-Imposter type
  78635. */
  78636. static HeightmapImpostor: number;
  78637. /**
  78638. * ConvexHull-Impostor type (Ammo.js plugin only)
  78639. */
  78640. static ConvexHullImpostor: number;
  78641. /**
  78642. * Rope-Imposter type
  78643. */
  78644. static RopeImpostor: number;
  78645. /**
  78646. * Cloth-Imposter type
  78647. */
  78648. static ClothImpostor: number;
  78649. /**
  78650. * Softbody-Imposter type
  78651. */
  78652. static SoftbodyImpostor: number;
  78653. }
  78654. }
  78655. declare module BABYLON {
  78656. /**
  78657. * Class used to represent a specific level of detail of a mesh
  78658. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  78659. */
  78660. export class MeshLODLevel {
  78661. /** Defines the distance where this level should star being displayed */
  78662. distance: number;
  78663. /** Defines the mesh to use to render this level */
  78664. mesh: Nullable<Mesh>;
  78665. /**
  78666. * Creates a new LOD level
  78667. * @param distance defines the distance where this level should star being displayed
  78668. * @param mesh defines the mesh to use to render this level
  78669. */
  78670. constructor(
  78671. /** Defines the distance where this level should star being displayed */
  78672. distance: number,
  78673. /** Defines the mesh to use to render this level */
  78674. mesh: Nullable<Mesh>);
  78675. }
  78676. /**
  78677. * @hidden
  78678. **/
  78679. export class _CreationDataStorage {
  78680. closePath?: boolean;
  78681. closeArray?: boolean;
  78682. idx: number[];
  78683. dashSize: number;
  78684. gapSize: number;
  78685. path3D: Path3D;
  78686. pathArray: Vector3[][];
  78687. arc: number;
  78688. radius: number;
  78689. cap: number;
  78690. tessellation: number;
  78691. }
  78692. /**
  78693. * @hidden
  78694. **/
  78695. class _InstanceDataStorage {
  78696. visibleInstances: any;
  78697. renderIdForInstances: number[];
  78698. batchCache: _InstancesBatch;
  78699. instancesBufferSize: number;
  78700. instancesBuffer: Nullable<Buffer>;
  78701. instancesData: Float32Array;
  78702. overridenInstanceCount: number;
  78703. }
  78704. /**
  78705. * @hidden
  78706. **/
  78707. export class _InstancesBatch {
  78708. mustReturn: boolean;
  78709. visibleInstances: Nullable<InstancedMesh[]>[];
  78710. renderSelf: boolean[];
  78711. }
  78712. /**
  78713. * Class used to represent renderable models
  78714. */
  78715. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  78716. /**
  78717. * Mesh side orientation : usually the external or front surface
  78718. */
  78719. static readonly FRONTSIDE: number;
  78720. /**
  78721. * Mesh side orientation : usually the internal or back surface
  78722. */
  78723. static readonly BACKSIDE: number;
  78724. /**
  78725. * Mesh side orientation : both internal and external or front and back surfaces
  78726. */
  78727. static readonly DOUBLESIDE: number;
  78728. /**
  78729. * Mesh side orientation : by default, `FRONTSIDE`
  78730. */
  78731. static readonly DEFAULTSIDE: number;
  78732. /**
  78733. * Mesh cap setting : no cap
  78734. */
  78735. static readonly NO_CAP: number;
  78736. /**
  78737. * Mesh cap setting : one cap at the beginning of the mesh
  78738. */
  78739. static readonly CAP_START: number;
  78740. /**
  78741. * Mesh cap setting : one cap at the end of the mesh
  78742. */
  78743. static readonly CAP_END: number;
  78744. /**
  78745. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  78746. */
  78747. static readonly CAP_ALL: number;
  78748. /**
  78749. * Gets the default side orientation.
  78750. * @param orientation the orientation to value to attempt to get
  78751. * @returns the default orientation
  78752. * @hidden
  78753. */
  78754. static _GetDefaultSideOrientation(orientation?: number): number;
  78755. private _onBeforeRenderObservable;
  78756. private _onBeforeBindObservable;
  78757. private _onAfterRenderObservable;
  78758. private _onBeforeDrawObservable;
  78759. /**
  78760. * An event triggered before rendering the mesh
  78761. */
  78762. readonly onBeforeRenderObservable: Observable<Mesh>;
  78763. /**
  78764. * An event triggered before binding the mesh
  78765. */
  78766. readonly onBeforeBindObservable: Observable<Mesh>;
  78767. /**
  78768. * An event triggered after rendering the mesh
  78769. */
  78770. readonly onAfterRenderObservable: Observable<Mesh>;
  78771. /**
  78772. * An event triggered before drawing the mesh
  78773. */
  78774. readonly onBeforeDrawObservable: Observable<Mesh>;
  78775. private _onBeforeDrawObserver;
  78776. /**
  78777. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  78778. */
  78779. onBeforeDraw: () => void;
  78780. /**
  78781. * Gets the delay loading state of the mesh (when delay loading is turned on)
  78782. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  78783. */
  78784. delayLoadState: number;
  78785. /**
  78786. * Gets the list of instances created from this mesh
  78787. * it is not supposed to be modified manually.
  78788. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  78789. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  78790. */
  78791. instances: InstancedMesh[];
  78792. /**
  78793. * Gets the file containing delay loading data for this mesh
  78794. */
  78795. delayLoadingFile: string;
  78796. /** @hidden */
  78797. _binaryInfo: any;
  78798. private _LODLevels;
  78799. /**
  78800. * User defined function used to change how LOD level selection is done
  78801. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  78802. */
  78803. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  78804. private _morphTargetManager;
  78805. /**
  78806. * Gets or sets the morph target manager
  78807. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  78808. */
  78809. morphTargetManager: Nullable<MorphTargetManager>;
  78810. /** @hidden */
  78811. _creationDataStorage: Nullable<_CreationDataStorage>;
  78812. /** @hidden */
  78813. _geometry: Nullable<Geometry>;
  78814. /** @hidden */
  78815. _delayInfo: Array<string>;
  78816. /** @hidden */
  78817. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  78818. /** @hidden */
  78819. _instanceDataStorage: _InstanceDataStorage;
  78820. private _effectiveMaterial;
  78821. /** @hidden */
  78822. _shouldGenerateFlatShading: boolean;
  78823. private _preActivateId;
  78824. /** @hidden */
  78825. _originalBuilderSideOrientation: number;
  78826. /**
  78827. * Use this property to change the original side orientation defined at construction time
  78828. */
  78829. overrideMaterialSideOrientation: Nullable<number>;
  78830. private _areNormalsFrozen;
  78831. private _sourcePositions;
  78832. private _sourceNormals;
  78833. private _source;
  78834. private meshMap;
  78835. /**
  78836. * Gets the source mesh (the one used to clone this one from)
  78837. */
  78838. readonly source: Nullable<Mesh>;
  78839. /**
  78840. * Gets or sets a boolean indicating that this mesh does not use index buffer
  78841. */
  78842. isUnIndexed: boolean;
  78843. /**
  78844. * @constructor
  78845. * @param name The value used by scene.getMeshByName() to do a lookup.
  78846. * @param scene The scene to add this mesh to.
  78847. * @param parent The parent of this mesh, if it has one
  78848. * @param source An optional Mesh from which geometry is shared, cloned.
  78849. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  78850. * When false, achieved by calling a clone(), also passing False.
  78851. * This will make creation of children, recursive.
  78852. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  78853. */
  78854. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  78855. /**
  78856. * Gets the class name
  78857. * @returns the string "Mesh".
  78858. */
  78859. getClassName(): string;
  78860. /** @hidden */
  78861. readonly _isMesh: boolean;
  78862. /**
  78863. * Returns a description of this mesh
  78864. * @param fullDetails define if full details about this mesh must be used
  78865. * @returns a descriptive string representing this mesh
  78866. */
  78867. toString(fullDetails?: boolean): string;
  78868. /** @hidden */
  78869. _unBindEffect(): void;
  78870. /**
  78871. * Gets a boolean indicating if this mesh has LOD
  78872. */
  78873. readonly hasLODLevels: boolean;
  78874. /**
  78875. * Gets the list of MeshLODLevel associated with the current mesh
  78876. * @returns an array of MeshLODLevel
  78877. */
  78878. getLODLevels(): MeshLODLevel[];
  78879. private _sortLODLevels;
  78880. /**
  78881. * Add a mesh as LOD level triggered at the given distance.
  78882. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  78883. * @param distance The distance from the center of the object to show this level
  78884. * @param mesh The mesh to be added as LOD level (can be null)
  78885. * @return This mesh (for chaining)
  78886. */
  78887. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  78888. /**
  78889. * Returns the LOD level mesh at the passed distance or null if not found.
  78890. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  78891. * @param distance The distance from the center of the object to show this level
  78892. * @returns a Mesh or `null`
  78893. */
  78894. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  78895. /**
  78896. * Remove a mesh from the LOD array
  78897. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  78898. * @param mesh defines the mesh to be removed
  78899. * @return This mesh (for chaining)
  78900. */
  78901. removeLODLevel(mesh: Mesh): Mesh;
  78902. /**
  78903. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  78904. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  78905. * @param camera defines the camera to use to compute distance
  78906. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  78907. * @return This mesh (for chaining)
  78908. */
  78909. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  78910. /**
  78911. * Gets the mesh internal Geometry object
  78912. */
  78913. readonly geometry: Nullable<Geometry>;
  78914. /**
  78915. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  78916. * @returns the total number of vertices
  78917. */
  78918. getTotalVertices(): number;
  78919. /**
  78920. * Returns the content of an associated vertex buffer
  78921. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  78922. * - VertexBuffer.PositionKind
  78923. * - VertexBuffer.UVKind
  78924. * - VertexBuffer.UV2Kind
  78925. * - VertexBuffer.UV3Kind
  78926. * - VertexBuffer.UV4Kind
  78927. * - VertexBuffer.UV5Kind
  78928. * - VertexBuffer.UV6Kind
  78929. * - VertexBuffer.ColorKind
  78930. * - VertexBuffer.MatricesIndicesKind
  78931. * - VertexBuffer.MatricesIndicesExtraKind
  78932. * - VertexBuffer.MatricesWeightsKind
  78933. * - VertexBuffer.MatricesWeightsExtraKind
  78934. * @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
  78935. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  78936. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  78937. */
  78938. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  78939. /**
  78940. * Returns the mesh VertexBuffer object from the requested `kind`
  78941. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  78942. * - VertexBuffer.PositionKind
  78943. * - VertexBuffer.UVKind
  78944. * - VertexBuffer.UV2Kind
  78945. * - VertexBuffer.UV3Kind
  78946. * - VertexBuffer.UV4Kind
  78947. * - VertexBuffer.UV5Kind
  78948. * - VertexBuffer.UV6Kind
  78949. * - VertexBuffer.ColorKind
  78950. * - VertexBuffer.MatricesIndicesKind
  78951. * - VertexBuffer.MatricesIndicesExtraKind
  78952. * - VertexBuffer.MatricesWeightsKind
  78953. * - VertexBuffer.MatricesWeightsExtraKind
  78954. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  78955. */
  78956. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  78957. /**
  78958. * Tests if a specific vertex buffer is associated with this mesh
  78959. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  78960. * - VertexBuffer.PositionKind
  78961. * - VertexBuffer.UVKind
  78962. * - VertexBuffer.UV2Kind
  78963. * - VertexBuffer.UV3Kind
  78964. * - VertexBuffer.UV4Kind
  78965. * - VertexBuffer.UV5Kind
  78966. * - VertexBuffer.UV6Kind
  78967. * - VertexBuffer.ColorKind
  78968. * - VertexBuffer.MatricesIndicesKind
  78969. * - VertexBuffer.MatricesIndicesExtraKind
  78970. * - VertexBuffer.MatricesWeightsKind
  78971. * - VertexBuffer.MatricesWeightsExtraKind
  78972. * @returns a boolean
  78973. */
  78974. isVerticesDataPresent(kind: string): boolean;
  78975. /**
  78976. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  78977. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  78978. * - VertexBuffer.PositionKind
  78979. * - VertexBuffer.UVKind
  78980. * - VertexBuffer.UV2Kind
  78981. * - VertexBuffer.UV3Kind
  78982. * - VertexBuffer.UV4Kind
  78983. * - VertexBuffer.UV5Kind
  78984. * - VertexBuffer.UV6Kind
  78985. * - VertexBuffer.ColorKind
  78986. * - VertexBuffer.MatricesIndicesKind
  78987. * - VertexBuffer.MatricesIndicesExtraKind
  78988. * - VertexBuffer.MatricesWeightsKind
  78989. * - VertexBuffer.MatricesWeightsExtraKind
  78990. * @returns a boolean
  78991. */
  78992. isVertexBufferUpdatable(kind: string): boolean;
  78993. /**
  78994. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  78995. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  78996. * - VertexBuffer.PositionKind
  78997. * - VertexBuffer.UVKind
  78998. * - VertexBuffer.UV2Kind
  78999. * - VertexBuffer.UV3Kind
  79000. * - VertexBuffer.UV4Kind
  79001. * - VertexBuffer.UV5Kind
  79002. * - VertexBuffer.UV6Kind
  79003. * - VertexBuffer.ColorKind
  79004. * - VertexBuffer.MatricesIndicesKind
  79005. * - VertexBuffer.MatricesIndicesExtraKind
  79006. * - VertexBuffer.MatricesWeightsKind
  79007. * - VertexBuffer.MatricesWeightsExtraKind
  79008. * @returns an array of strings
  79009. */
  79010. getVerticesDataKinds(): string[];
  79011. /**
  79012. * Returns a positive integer : the total number of indices in this mesh geometry.
  79013. * @returns the numner of indices or zero if the mesh has no geometry.
  79014. */
  79015. getTotalIndices(): number;
  79016. /**
  79017. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  79018. * @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.
  79019. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  79020. * @returns the indices array or an empty array if the mesh has no geometry
  79021. */
  79022. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  79023. readonly isBlocked: boolean;
  79024. /**
  79025. * Determine if the current mesh is ready to be rendered
  79026. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  79027. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  79028. * @returns true if all associated assets are ready (material, textures, shaders)
  79029. */
  79030. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  79031. /**
  79032. * 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.
  79033. */
  79034. readonly areNormalsFrozen: boolean;
  79035. /**
  79036. * 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.
  79037. * @returns the current mesh
  79038. */
  79039. freezeNormals(): Mesh;
  79040. /**
  79041. * 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
  79042. * @returns the current mesh
  79043. */
  79044. unfreezeNormals(): Mesh;
  79045. /**
  79046. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  79047. */
  79048. overridenInstanceCount: number;
  79049. /** @hidden */
  79050. _preActivate(): Mesh;
  79051. /** @hidden */
  79052. _preActivateForIntermediateRendering(renderId: number): Mesh;
  79053. /** @hidden */
  79054. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  79055. /**
  79056. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  79057. * This means the mesh underlying bounding box and sphere are recomputed.
  79058. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  79059. * @returns the current mesh
  79060. */
  79061. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  79062. /** @hidden */
  79063. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  79064. /**
  79065. * This function will subdivide the mesh into multiple submeshes
  79066. * @param count defines the expected number of submeshes
  79067. */
  79068. subdivide(count: number): void;
  79069. /**
  79070. * Copy a FloatArray into a specific associated vertex buffer
  79071. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  79072. * - VertexBuffer.PositionKind
  79073. * - VertexBuffer.UVKind
  79074. * - VertexBuffer.UV2Kind
  79075. * - VertexBuffer.UV3Kind
  79076. * - VertexBuffer.UV4Kind
  79077. * - VertexBuffer.UV5Kind
  79078. * - VertexBuffer.UV6Kind
  79079. * - VertexBuffer.ColorKind
  79080. * - VertexBuffer.MatricesIndicesKind
  79081. * - VertexBuffer.MatricesIndicesExtraKind
  79082. * - VertexBuffer.MatricesWeightsKind
  79083. * - VertexBuffer.MatricesWeightsExtraKind
  79084. * @param data defines the data source
  79085. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  79086. * @param stride defines the data stride size (can be null)
  79087. * @returns the current mesh
  79088. */
  79089. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  79090. /**
  79091. * Flags an associated vertex buffer as updatable
  79092. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  79093. * - VertexBuffer.PositionKind
  79094. * - VertexBuffer.UVKind
  79095. * - VertexBuffer.UV2Kind
  79096. * - VertexBuffer.UV3Kind
  79097. * - VertexBuffer.UV4Kind
  79098. * - VertexBuffer.UV5Kind
  79099. * - VertexBuffer.UV6Kind
  79100. * - VertexBuffer.ColorKind
  79101. * - VertexBuffer.MatricesIndicesKind
  79102. * - VertexBuffer.MatricesIndicesExtraKind
  79103. * - VertexBuffer.MatricesWeightsKind
  79104. * - VertexBuffer.MatricesWeightsExtraKind
  79105. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  79106. */
  79107. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  79108. /**
  79109. * Sets the mesh global Vertex Buffer
  79110. * @param buffer defines the buffer to use
  79111. * @returns the current mesh
  79112. */
  79113. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  79114. /**
  79115. * Update a specific associated vertex buffer
  79116. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  79117. * - VertexBuffer.PositionKind
  79118. * - VertexBuffer.UVKind
  79119. * - VertexBuffer.UV2Kind
  79120. * - VertexBuffer.UV3Kind
  79121. * - VertexBuffer.UV4Kind
  79122. * - VertexBuffer.UV5Kind
  79123. * - VertexBuffer.UV6Kind
  79124. * - VertexBuffer.ColorKind
  79125. * - VertexBuffer.MatricesIndicesKind
  79126. * - VertexBuffer.MatricesIndicesExtraKind
  79127. * - VertexBuffer.MatricesWeightsKind
  79128. * - VertexBuffer.MatricesWeightsExtraKind
  79129. * @param data defines the data source
  79130. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  79131. * @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)
  79132. * @returns the current mesh
  79133. */
  79134. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  79135. /**
  79136. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  79137. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  79138. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  79139. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  79140. * @returns the current mesh
  79141. */
  79142. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  79143. /**
  79144. * Creates a un-shared specific occurence of the geometry for the mesh.
  79145. * @returns the current mesh
  79146. */
  79147. makeGeometryUnique(): Mesh;
  79148. /**
  79149. * Set the index buffer of this mesh
  79150. * @param indices defines the source data
  79151. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  79152. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  79153. * @returns the current mesh
  79154. */
  79155. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  79156. /**
  79157. * Update the current index buffer
  79158. * @param indices defines the source data
  79159. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  79160. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  79161. * @returns the current mesh
  79162. */
  79163. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  79164. /**
  79165. * Invert the geometry to move from a right handed system to a left handed one.
  79166. * @returns the current mesh
  79167. */
  79168. toLeftHanded(): Mesh;
  79169. /** @hidden */
  79170. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  79171. /** @hidden */
  79172. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  79173. /**
  79174. * Registers for this mesh a javascript function called just before the rendering process
  79175. * @param func defines the function to call before rendering this mesh
  79176. * @returns the current mesh
  79177. */
  79178. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  79179. /**
  79180. * Disposes a previously registered javascript function called before the rendering
  79181. * @param func defines the function to remove
  79182. * @returns the current mesh
  79183. */
  79184. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  79185. /**
  79186. * Registers for this mesh a javascript function called just after the rendering is complete
  79187. * @param func defines the function to call after rendering this mesh
  79188. * @returns the current mesh
  79189. */
  79190. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  79191. /**
  79192. * Disposes a previously registered javascript function called after the rendering.
  79193. * @param func defines the function to remove
  79194. * @returns the current mesh
  79195. */
  79196. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  79197. /** @hidden */
  79198. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  79199. /** @hidden */
  79200. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  79201. /** @hidden */
  79202. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  79203. /**
  79204. * 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
  79205. * @param subMesh defines the subMesh to render
  79206. * @param enableAlphaMode defines if alpha mode can be changed
  79207. * @returns the current mesh
  79208. */
  79209. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  79210. private _onBeforeDraw;
  79211. /**
  79212. * Renormalize the mesh and patch it up if there are no weights
  79213. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  79214. * However in the case of zero weights then we set just a single influence to 1.
  79215. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  79216. */
  79217. cleanMatrixWeights(): void;
  79218. private normalizeSkinFourWeights;
  79219. private normalizeSkinWeightsAndExtra;
  79220. /**
  79221. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  79222. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  79223. * the user know there was an issue with importing the mesh
  79224. * @returns a validation object with skinned, valid and report string
  79225. */
  79226. validateSkinning(): {
  79227. skinned: boolean;
  79228. valid: boolean;
  79229. report: string;
  79230. };
  79231. /** @hidden */
  79232. _checkDelayState(): Mesh;
  79233. private _queueLoad;
  79234. /**
  79235. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  79236. * A mesh is in the frustum if its bounding box intersects the frustum
  79237. * @param frustumPlanes defines the frustum to test
  79238. * @returns true if the mesh is in the frustum planes
  79239. */
  79240. isInFrustum(frustumPlanes: Plane[]): boolean;
  79241. /**
  79242. * Sets the mesh material by the material or multiMaterial `id` property
  79243. * @param id is a string identifying the material or the multiMaterial
  79244. * @returns the current mesh
  79245. */
  79246. setMaterialByID(id: string): Mesh;
  79247. /**
  79248. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  79249. * @returns an array of IAnimatable
  79250. */
  79251. getAnimatables(): IAnimatable[];
  79252. /**
  79253. * Modifies the mesh geometry according to the passed transformation matrix.
  79254. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  79255. * The mesh normals are modified using the same transformation.
  79256. * Note that, under the hood, this method sets a new VertexBuffer each call.
  79257. * @param transform defines the transform matrix to use
  79258. * @see http://doc.babylonjs.com/resources/baking_transformations
  79259. * @returns the current mesh
  79260. */
  79261. bakeTransformIntoVertices(transform: Matrix): Mesh;
  79262. /**
  79263. * Modifies the mesh geometry according to its own current World Matrix.
  79264. * The mesh World Matrix is then reset.
  79265. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  79266. * Note that, under the hood, this method sets a new VertexBuffer each call.
  79267. * @see http://doc.babylonjs.com/resources/baking_transformations
  79268. * @returns the current mesh
  79269. */
  79270. bakeCurrentTransformIntoVertices(): Mesh;
  79271. /** @hidden */
  79272. readonly _positions: Nullable<Vector3[]>;
  79273. /** @hidden */
  79274. _resetPointsArrayCache(): Mesh;
  79275. /** @hidden */
  79276. _generatePointsArray(): boolean;
  79277. /**
  79278. * Returns a new Mesh object generated from the current mesh properties.
  79279. * This method must not get confused with createInstance()
  79280. * @param name is a string, the name given to the new mesh
  79281. * @param newParent can be any Node object (default `null`)
  79282. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  79283. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  79284. * @returns a new mesh
  79285. */
  79286. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  79287. /**
  79288. * Releases resources associated with this mesh.
  79289. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  79290. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  79291. */
  79292. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  79293. /**
  79294. * Modifies the mesh geometry according to a displacement map.
  79295. * 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.
  79296. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  79297. * @param url is a string, the URL from the image file is to be downloaded.
  79298. * @param minHeight is the lower limit of the displacement.
  79299. * @param maxHeight is the upper limit of the displacement.
  79300. * @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.
  79301. * @param uvOffset is an optional vector2 used to offset UV.
  79302. * @param uvScale is an optional vector2 used to scale UV.
  79303. * @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.
  79304. * @returns the Mesh.
  79305. */
  79306. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  79307. /**
  79308. * Modifies the mesh geometry according to a displacementMap buffer.
  79309. * 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.
  79310. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  79311. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  79312. * @param heightMapWidth is the width of the buffer image.
  79313. * @param heightMapHeight is the height of the buffer image.
  79314. * @param minHeight is the lower limit of the displacement.
  79315. * @param maxHeight is the upper limit of the displacement.
  79316. * @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.
  79317. * @param uvOffset is an optional vector2 used to offset UV.
  79318. * @param uvScale is an optional vector2 used to scale UV.
  79319. * @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.
  79320. * @returns the Mesh.
  79321. */
  79322. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  79323. /**
  79324. * Modify the mesh to get a flat shading rendering.
  79325. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  79326. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  79327. * @returns current mesh
  79328. */
  79329. convertToFlatShadedMesh(): Mesh;
  79330. /**
  79331. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  79332. * In other words, more vertices, no more indices and a single bigger VBO.
  79333. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  79334. * @returns current mesh
  79335. */
  79336. convertToUnIndexedMesh(): Mesh;
  79337. /**
  79338. * Inverses facet orientations.
  79339. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  79340. * @param flipNormals will also inverts the normals
  79341. * @returns current mesh
  79342. */
  79343. flipFaces(flipNormals?: boolean): Mesh;
  79344. /**
  79345. * Increase the number of facets and hence vertices in a mesh
  79346. * Vertex normals are interpolated from existing vertex normals
  79347. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  79348. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  79349. */
  79350. increaseVertices(numberPerEdge: number): void;
  79351. /**
  79352. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  79353. * This will undo any application of covertToFlatShadedMesh
  79354. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  79355. */
  79356. forceSharedVertices(): void;
  79357. /** @hidden */
  79358. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  79359. /** @hidden */
  79360. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  79361. /**
  79362. * Creates a new InstancedMesh object from the mesh model.
  79363. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  79364. * @param name defines the name of the new instance
  79365. * @returns a new InstancedMesh
  79366. */
  79367. createInstance(name: string): InstancedMesh;
  79368. /**
  79369. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  79370. * After this call, all the mesh instances have the same submeshes than the current mesh.
  79371. * @returns the current mesh
  79372. */
  79373. synchronizeInstances(): Mesh;
  79374. /**
  79375. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  79376. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  79377. * This should be used together with the simplification to avoid disappearing triangles.
  79378. * @param successCallback an optional success callback to be called after the optimization finished.
  79379. * @returns the current mesh
  79380. */
  79381. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  79382. /**
  79383. * Serialize current mesh
  79384. * @param serializationObject defines the object which will receive the serialization data
  79385. */
  79386. serialize(serializationObject: any): void;
  79387. /** @hidden */
  79388. _syncGeometryWithMorphTargetManager(): void;
  79389. /** @hidden */
  79390. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  79391. /**
  79392. * Returns a new Mesh object parsed from the source provided.
  79393. * @param parsedMesh is the source
  79394. * @param scene defines the hosting scene
  79395. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  79396. * @returns a new Mesh
  79397. */
  79398. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  79399. /**
  79400. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  79401. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  79402. * @param name defines the name of the mesh to create
  79403. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  79404. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  79405. * @param closePath creates a seam between the first and the last points of each path of the path array
  79406. * @param offset is taken in account only if the `pathArray` is containing a single path
  79407. * @param scene defines the hosting scene
  79408. * @param updatable defines if the mesh must be flagged as updatable
  79409. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79410. * @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)
  79411. * @returns a new Mesh
  79412. */
  79413. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  79414. /**
  79415. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  79416. * @param name defines the name of the mesh to create
  79417. * @param radius sets the radius size (float) of the polygon (default 0.5)
  79418. * @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
  79419. * @param scene defines the hosting scene
  79420. * @param updatable defines if the mesh must be flagged as updatable
  79421. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79422. * @returns a new Mesh
  79423. */
  79424. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  79425. /**
  79426. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  79427. * @param name defines the name of the mesh to create
  79428. * @param size sets the size (float) of each box side (default 1)
  79429. * @param scene defines the hosting scene
  79430. * @param updatable defines if the mesh must be flagged as updatable
  79431. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79432. * @returns a new Mesh
  79433. */
  79434. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  79435. /**
  79436. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  79437. * @param name defines the name of the mesh to create
  79438. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  79439. * @param diameter sets the diameter size (float) of the sphere (default 1)
  79440. * @param scene defines the hosting scene
  79441. * @param updatable defines if the mesh must be flagged as updatable
  79442. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79443. * @returns a new Mesh
  79444. */
  79445. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  79446. /**
  79447. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  79448. * @param name defines the name of the mesh to create
  79449. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  79450. * @param diameterTop set the top cap diameter (floats, default 1)
  79451. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  79452. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  79453. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  79454. * @param scene defines the hosting scene
  79455. * @param updatable defines if the mesh must be flagged as updatable
  79456. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79457. * @returns a new Mesh
  79458. */
  79459. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  79460. /**
  79461. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  79462. * @param name defines the name of the mesh to create
  79463. * @param diameter sets the diameter size (float) of the torus (default 1)
  79464. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  79465. * @param tessellation sets the number of torus sides (postive integer, default 16)
  79466. * @param scene defines the hosting scene
  79467. * @param updatable defines if the mesh must be flagged as updatable
  79468. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79469. * @returns a new Mesh
  79470. */
  79471. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  79472. /**
  79473. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  79474. * @param name defines the name of the mesh to create
  79475. * @param radius sets the global radius size (float) of the torus knot (default 2)
  79476. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  79477. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  79478. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  79479. * @param p the number of windings on X axis (positive integers, default 2)
  79480. * @param q the number of windings on Y axis (positive integers, default 3)
  79481. * @param scene defines the hosting scene
  79482. * @param updatable defines if the mesh must be flagged as updatable
  79483. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79484. * @returns a new Mesh
  79485. */
  79486. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  79487. /**
  79488. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  79489. * @param name defines the name of the mesh to create
  79490. * @param points is an array successive Vector3
  79491. * @param scene defines the hosting scene
  79492. * @param updatable defines if the mesh must be flagged as updatable
  79493. * @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).
  79494. * @returns a new Mesh
  79495. */
  79496. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  79497. /**
  79498. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  79499. * @param name defines the name of the mesh to create
  79500. * @param points is an array successive Vector3
  79501. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  79502. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  79503. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  79504. * @param scene defines the hosting scene
  79505. * @param updatable defines if the mesh must be flagged as updatable
  79506. * @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)
  79507. * @returns a new Mesh
  79508. */
  79509. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  79510. /**
  79511. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  79512. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  79513. * 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.
  79514. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79515. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  79516. * Remember you can only change the shape positions, not their number when updating a polygon.
  79517. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  79518. * @param name defines the name of the mesh to create
  79519. * @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
  79520. * @param scene defines the hosting scene
  79521. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  79522. * @param updatable defines if the mesh must be flagged as updatable
  79523. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79524. * @param earcutInjection can be used to inject your own earcut reference
  79525. * @returns a new Mesh
  79526. */
  79527. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  79528. /**
  79529. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  79530. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  79531. * @param name defines the name of the mesh to create
  79532. * @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
  79533. * @param depth defines the height of extrusion
  79534. * @param scene defines the hosting scene
  79535. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  79536. * @param updatable defines if the mesh must be flagged as updatable
  79537. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79538. * @param earcutInjection can be used to inject your own earcut reference
  79539. * @returns a new Mesh
  79540. */
  79541. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  79542. /**
  79543. * Creates an extruded shape mesh.
  79544. * 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
  79545. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  79546. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  79547. * @param name defines the name of the mesh to create
  79548. * @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
  79549. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  79550. * @param scale is the value to scale the shape
  79551. * @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
  79552. * @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
  79553. * @param scene defines the hosting scene
  79554. * @param updatable defines if the mesh must be flagged as updatable
  79555. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79556. * @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)
  79557. * @returns a new Mesh
  79558. */
  79559. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  79560. /**
  79561. * Creates an custom extruded shape mesh.
  79562. * The custom extrusion is a parametric shape.
  79563. * It has no predefined shape. Its final shape will depend on the input parameters.
  79564. * Please consider using the same method from the MeshBuilder class instead
  79565. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  79566. * @param name defines the name of the mesh to create
  79567. * @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
  79568. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  79569. * @param scaleFunction is a custom Javascript function called on each path point
  79570. * @param rotationFunction is a custom Javascript function called on each path point
  79571. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  79572. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  79573. * @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
  79574. * @param scene defines the hosting scene
  79575. * @param updatable defines if the mesh must be flagged as updatable
  79576. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79577. * @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)
  79578. * @returns a new Mesh
  79579. */
  79580. 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;
  79581. /**
  79582. * Creates lathe mesh.
  79583. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  79584. * Please consider using the same method from the MeshBuilder class instead
  79585. * @param name defines the name of the mesh to create
  79586. * @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
  79587. * @param radius is the radius value of the lathe
  79588. * @param tessellation is the side number of the lathe.
  79589. * @param scene defines the hosting scene
  79590. * @param updatable defines if the mesh must be flagged as updatable
  79591. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79592. * @returns a new Mesh
  79593. */
  79594. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  79595. /**
  79596. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  79597. * @param name defines the name of the mesh to create
  79598. * @param size sets the size (float) of both sides of the plane at once (default 1)
  79599. * @param scene defines the hosting scene
  79600. * @param updatable defines if the mesh must be flagged as updatable
  79601. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79602. * @returns a new Mesh
  79603. */
  79604. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  79605. /**
  79606. * Creates a ground mesh.
  79607. * Please consider using the same method from the MeshBuilder class instead
  79608. * @param name defines the name of the mesh to create
  79609. * @param width set the width of the ground
  79610. * @param height set the height of the ground
  79611. * @param subdivisions sets the number of subdivisions per side
  79612. * @param scene defines the hosting scene
  79613. * @param updatable defines if the mesh must be flagged as updatable
  79614. * @returns a new Mesh
  79615. */
  79616. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  79617. /**
  79618. * Creates a tiled ground mesh.
  79619. * Please consider using the same method from the MeshBuilder class instead
  79620. * @param name defines the name of the mesh to create
  79621. * @param xmin set the ground minimum X coordinate
  79622. * @param zmin set the ground minimum Y coordinate
  79623. * @param xmax set the ground maximum X coordinate
  79624. * @param zmax set the ground maximum Z coordinate
  79625. * @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
  79626. * @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
  79627. * @param scene defines the hosting scene
  79628. * @param updatable defines if the mesh must be flagged as updatable
  79629. * @returns a new Mesh
  79630. */
  79631. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  79632. w: number;
  79633. h: number;
  79634. }, precision: {
  79635. w: number;
  79636. h: number;
  79637. }, scene: Scene, updatable?: boolean): Mesh;
  79638. /**
  79639. * Creates a ground mesh from a height map.
  79640. * Please consider using the same method from the MeshBuilder class instead
  79641. * @see http://doc.babylonjs.com/babylon101/height_map
  79642. * @param name defines the name of the mesh to create
  79643. * @param url sets the URL of the height map image resource
  79644. * @param width set the ground width size
  79645. * @param height set the ground height size
  79646. * @param subdivisions sets the number of subdivision per side
  79647. * @param minHeight is the minimum altitude on the ground
  79648. * @param maxHeight is the maximum altitude on the ground
  79649. * @param scene defines the hosting scene
  79650. * @param updatable defines if the mesh must be flagged as updatable
  79651. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  79652. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  79653. * @returns a new Mesh
  79654. */
  79655. 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;
  79656. /**
  79657. * Creates a tube mesh.
  79658. * The tube is a parametric shape.
  79659. * It has no predefined shape. Its final shape will depend on the input parameters.
  79660. * Please consider using the same method from the MeshBuilder class instead
  79661. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  79662. * @param name defines the name of the mesh to create
  79663. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  79664. * @param radius sets the tube radius size
  79665. * @param tessellation is the number of sides on the tubular surface
  79666. * @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
  79667. * @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
  79668. * @param scene defines the hosting scene
  79669. * @param updatable defines if the mesh must be flagged as updatable
  79670. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79671. * @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)
  79672. * @returns a new Mesh
  79673. */
  79674. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  79675. (i: number, distance: number): number;
  79676. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  79677. /**
  79678. * Creates a polyhedron mesh.
  79679. * Please consider using the same method from the MeshBuilder class instead.
  79680. * * 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
  79681. * * The parameter `size` (positive float, default 1) sets the polygon size
  79682. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  79683. * * 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`
  79684. * * 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
  79685. * * 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)`)
  79686. * * 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
  79687. * * 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
  79688. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79689. * * If you create a double-sided mesh, you can choose what parts of 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
  79690. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79691. * @param name defines the name of the mesh to create
  79692. * @param options defines the options used to create the mesh
  79693. * @param scene defines the hosting scene
  79694. * @returns a new Mesh
  79695. */
  79696. static CreatePolyhedron(name: string, options: {
  79697. type?: number;
  79698. size?: number;
  79699. sizeX?: number;
  79700. sizeY?: number;
  79701. sizeZ?: number;
  79702. custom?: any;
  79703. faceUV?: Vector4[];
  79704. faceColors?: Color4[];
  79705. updatable?: boolean;
  79706. sideOrientation?: number;
  79707. }, scene: Scene): Mesh;
  79708. /**
  79709. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  79710. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  79711. * * 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`)
  79712. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  79713. * * 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
  79714. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79715. * * If you create a double-sided mesh, you can choose what parts of 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
  79716. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79717. * @param name defines the name of the mesh
  79718. * @param options defines the options used to create the mesh
  79719. * @param scene defines the hosting scene
  79720. * @returns a new Mesh
  79721. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  79722. */
  79723. static CreateIcoSphere(name: string, options: {
  79724. radius?: number;
  79725. flat?: boolean;
  79726. subdivisions?: number;
  79727. sideOrientation?: number;
  79728. updatable?: boolean;
  79729. }, scene: Scene): Mesh;
  79730. /**
  79731. * Creates a decal mesh.
  79732. * Please consider using the same method from the MeshBuilder class instead.
  79733. * A decal is a mesh usually applied as a model onto the surface of another mesh
  79734. * @param name defines the name of the mesh
  79735. * @param sourceMesh defines the mesh receiving the decal
  79736. * @param position sets the position of the decal in world coordinates
  79737. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  79738. * @param size sets the decal scaling
  79739. * @param angle sets the angle to rotate the decal
  79740. * @returns a new Mesh
  79741. */
  79742. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  79743. /**
  79744. * Prepare internal position array for software CPU skinning
  79745. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  79746. */
  79747. setPositionsForCPUSkinning(): Float32Array;
  79748. /**
  79749. * Prepare internal normal array for software CPU skinning
  79750. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  79751. */
  79752. setNormalsForCPUSkinning(): Float32Array;
  79753. /**
  79754. * Updates the vertex buffer by applying transformation from the bones
  79755. * @param skeleton defines the skeleton to apply to current mesh
  79756. * @returns the current mesh
  79757. */
  79758. applySkeleton(skeleton: Skeleton): Mesh;
  79759. /**
  79760. * 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
  79761. * @param meshes defines the list of meshes to scan
  79762. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  79763. */
  79764. static MinMax(meshes: AbstractMesh[]): {
  79765. min: Vector3;
  79766. max: Vector3;
  79767. };
  79768. /**
  79769. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  79770. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  79771. * @returns a vector3
  79772. */
  79773. static Center(meshesOrMinMaxVector: {
  79774. min: Vector3;
  79775. max: Vector3;
  79776. } | AbstractMesh[]): Vector3;
  79777. /**
  79778. * Merge the array of meshes into a single mesh for performance reasons.
  79779. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  79780. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  79781. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  79782. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  79783. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  79784. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  79785. * @returns a new mesh
  79786. */
  79787. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  79788. /** @hidden */
  79789. addInstance(instance: InstancedMesh): void;
  79790. /** @hidden */
  79791. removeInstance(instance: InstancedMesh): void;
  79792. }
  79793. }
  79794. declare module BABYLON {
  79795. /**
  79796. * Base class for the main features of a material in Babylon.js
  79797. */
  79798. export class Material implements IAnimatable {
  79799. /**
  79800. * Returns the triangle fill mode
  79801. */
  79802. static readonly TriangleFillMode: number;
  79803. /**
  79804. * Returns the wireframe mode
  79805. */
  79806. static readonly WireFrameFillMode: number;
  79807. /**
  79808. * Returns the point fill mode
  79809. */
  79810. static readonly PointFillMode: number;
  79811. /**
  79812. * Returns the point list draw mode
  79813. */
  79814. static readonly PointListDrawMode: number;
  79815. /**
  79816. * Returns the line list draw mode
  79817. */
  79818. static readonly LineListDrawMode: number;
  79819. /**
  79820. * Returns the line loop draw mode
  79821. */
  79822. static readonly LineLoopDrawMode: number;
  79823. /**
  79824. * Returns the line strip draw mode
  79825. */
  79826. static readonly LineStripDrawMode: number;
  79827. /**
  79828. * Returns the triangle strip draw mode
  79829. */
  79830. static readonly TriangleStripDrawMode: number;
  79831. /**
  79832. * Returns the triangle fan draw mode
  79833. */
  79834. static readonly TriangleFanDrawMode: number;
  79835. /**
  79836. * Stores the clock-wise side orientation
  79837. */
  79838. static readonly ClockWiseSideOrientation: number;
  79839. /**
  79840. * Stores the counter clock-wise side orientation
  79841. */
  79842. static readonly CounterClockWiseSideOrientation: number;
  79843. /**
  79844. * The dirty texture flag value
  79845. */
  79846. static readonly TextureDirtyFlag: number;
  79847. /**
  79848. * The dirty light flag value
  79849. */
  79850. static readonly LightDirtyFlag: number;
  79851. /**
  79852. * The dirty fresnel flag value
  79853. */
  79854. static readonly FresnelDirtyFlag: number;
  79855. /**
  79856. * The dirty attribute flag value
  79857. */
  79858. static readonly AttributesDirtyFlag: number;
  79859. /**
  79860. * The dirty misc flag value
  79861. */
  79862. static readonly MiscDirtyFlag: number;
  79863. /**
  79864. * The all dirty flag value
  79865. */
  79866. static readonly AllDirtyFlag: number;
  79867. /**
  79868. * The ID of the material
  79869. */
  79870. id: string;
  79871. /**
  79872. * Gets or sets the unique id of the material
  79873. */
  79874. uniqueId: number;
  79875. /**
  79876. * The name of the material
  79877. */
  79878. name: string;
  79879. /**
  79880. * Gets or sets user defined metadata
  79881. */
  79882. metadata: any;
  79883. /**
  79884. * For internal use only. Please do not use.
  79885. */
  79886. reservedDataStore: any;
  79887. /**
  79888. * Specifies if the ready state should be checked on each call
  79889. */
  79890. checkReadyOnEveryCall: boolean;
  79891. /**
  79892. * Specifies if the ready state should be checked once
  79893. */
  79894. checkReadyOnlyOnce: boolean;
  79895. /**
  79896. * The state of the material
  79897. */
  79898. state: string;
  79899. /**
  79900. * The alpha value of the material
  79901. */
  79902. protected _alpha: number;
  79903. /**
  79904. * List of inspectable custom properties (used by the Inspector)
  79905. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79906. */
  79907. inspectableCustomProperties: IInspectable[];
  79908. /**
  79909. * Sets the alpha value of the material
  79910. */
  79911. /**
  79912. * Gets the alpha value of the material
  79913. */
  79914. alpha: number;
  79915. /**
  79916. * Specifies if back face culling is enabled
  79917. */
  79918. protected _backFaceCulling: boolean;
  79919. /**
  79920. * Sets the back-face culling state
  79921. */
  79922. /**
  79923. * Gets the back-face culling state
  79924. */
  79925. backFaceCulling: boolean;
  79926. /**
  79927. * Stores the value for side orientation
  79928. */
  79929. sideOrientation: number;
  79930. /**
  79931. * Callback triggered when the material is compiled
  79932. */
  79933. onCompiled: (effect: Effect) => void;
  79934. /**
  79935. * Callback triggered when an error occurs
  79936. */
  79937. onError: (effect: Effect, errors: string) => void;
  79938. /**
  79939. * Callback triggered to get the render target textures
  79940. */
  79941. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  79942. /**
  79943. * Gets a boolean indicating that current material needs to register RTT
  79944. */
  79945. readonly hasRenderTargetTextures: boolean;
  79946. /**
  79947. * Specifies if the material should be serialized
  79948. */
  79949. doNotSerialize: boolean;
  79950. /**
  79951. * @hidden
  79952. */
  79953. _storeEffectOnSubMeshes: boolean;
  79954. /**
  79955. * Stores the animations for the material
  79956. */
  79957. animations: Array<Animation>;
  79958. /**
  79959. * An event triggered when the material is disposed
  79960. */
  79961. onDisposeObservable: Observable<Material>;
  79962. /**
  79963. * An observer which watches for dispose events
  79964. */
  79965. private _onDisposeObserver;
  79966. private _onUnBindObservable;
  79967. /**
  79968. * Called during a dispose event
  79969. */
  79970. onDispose: () => void;
  79971. private _onBindObservable;
  79972. /**
  79973. * An event triggered when the material is bound
  79974. */
  79975. readonly onBindObservable: Observable<AbstractMesh>;
  79976. /**
  79977. * An observer which watches for bind events
  79978. */
  79979. private _onBindObserver;
  79980. /**
  79981. * Called during a bind event
  79982. */
  79983. onBind: (Mesh: AbstractMesh) => void;
  79984. /**
  79985. * An event triggered when the material is unbound
  79986. */
  79987. readonly onUnBindObservable: Observable<Material>;
  79988. /**
  79989. * Stores the value of the alpha mode
  79990. */
  79991. private _alphaMode;
  79992. /**
  79993. * Sets the value of the alpha mode.
  79994. *
  79995. * | Value | Type | Description |
  79996. * | --- | --- | --- |
  79997. * | 0 | ALPHA_DISABLE | |
  79998. * | 1 | ALPHA_ADD | |
  79999. * | 2 | ALPHA_COMBINE | |
  80000. * | 3 | ALPHA_SUBTRACT | |
  80001. * | 4 | ALPHA_MULTIPLY | |
  80002. * | 5 | ALPHA_MAXIMIZED | |
  80003. * | 6 | ALPHA_ONEONE | |
  80004. * | 7 | ALPHA_PREMULTIPLIED | |
  80005. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  80006. * | 9 | ALPHA_INTERPOLATE | |
  80007. * | 10 | ALPHA_SCREENMODE | |
  80008. *
  80009. */
  80010. /**
  80011. * Gets the value of the alpha mode
  80012. */
  80013. alphaMode: number;
  80014. /**
  80015. * Stores the state of the need depth pre-pass value
  80016. */
  80017. private _needDepthPrePass;
  80018. /**
  80019. * Sets the need depth pre-pass value
  80020. */
  80021. /**
  80022. * Gets the depth pre-pass value
  80023. */
  80024. needDepthPrePass: boolean;
  80025. /**
  80026. * Specifies if depth writing should be disabled
  80027. */
  80028. disableDepthWrite: boolean;
  80029. /**
  80030. * Specifies if depth writing should be forced
  80031. */
  80032. forceDepthWrite: boolean;
  80033. /**
  80034. * Specifies if there should be a separate pass for culling
  80035. */
  80036. separateCullingPass: boolean;
  80037. /**
  80038. * Stores the state specifing if fog should be enabled
  80039. */
  80040. private _fogEnabled;
  80041. /**
  80042. * Sets the state for enabling fog
  80043. */
  80044. /**
  80045. * Gets the value of the fog enabled state
  80046. */
  80047. fogEnabled: boolean;
  80048. /**
  80049. * Stores the size of points
  80050. */
  80051. pointSize: number;
  80052. /**
  80053. * Stores the z offset value
  80054. */
  80055. zOffset: number;
  80056. /**
  80057. * Gets a value specifying if wireframe mode is enabled
  80058. */
  80059. /**
  80060. * Sets the state of wireframe mode
  80061. */
  80062. wireframe: boolean;
  80063. /**
  80064. * Gets the value specifying if point clouds are enabled
  80065. */
  80066. /**
  80067. * Sets the state of point cloud mode
  80068. */
  80069. pointsCloud: boolean;
  80070. /**
  80071. * Gets the material fill mode
  80072. */
  80073. /**
  80074. * Sets the material fill mode
  80075. */
  80076. fillMode: number;
  80077. /**
  80078. * @hidden
  80079. * Stores the effects for the material
  80080. */
  80081. _effect: Nullable<Effect>;
  80082. /**
  80083. * @hidden
  80084. * Specifies if the material was previously ready
  80085. */
  80086. _wasPreviouslyReady: boolean;
  80087. /**
  80088. * Specifies if uniform buffers should be used
  80089. */
  80090. private _useUBO;
  80091. /**
  80092. * Stores a reference to the scene
  80093. */
  80094. private _scene;
  80095. /**
  80096. * Stores the fill mode state
  80097. */
  80098. private _fillMode;
  80099. /**
  80100. * Specifies if the depth write state should be cached
  80101. */
  80102. private _cachedDepthWriteState;
  80103. /**
  80104. * Stores the uniform buffer
  80105. */
  80106. protected _uniformBuffer: UniformBuffer;
  80107. /** @hidden */
  80108. _indexInSceneMaterialArray: number;
  80109. /** @hidden */
  80110. meshMap: Nullable<{
  80111. [id: string]: AbstractMesh | undefined;
  80112. }>;
  80113. /**
  80114. * Creates a material instance
  80115. * @param name defines the name of the material
  80116. * @param scene defines the scene to reference
  80117. * @param doNotAdd specifies if the material should be added to the scene
  80118. */
  80119. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  80120. /**
  80121. * Returns a string representation of the current material
  80122. * @param fullDetails defines a boolean indicating which levels of logging is desired
  80123. * @returns a string with material information
  80124. */
  80125. toString(fullDetails?: boolean): string;
  80126. /**
  80127. * Gets the class name of the material
  80128. * @returns a string with the class name of the material
  80129. */
  80130. getClassName(): string;
  80131. /**
  80132. * Specifies if updates for the material been locked
  80133. */
  80134. readonly isFrozen: boolean;
  80135. /**
  80136. * Locks updates for the material
  80137. */
  80138. freeze(): void;
  80139. /**
  80140. * Unlocks updates for the material
  80141. */
  80142. unfreeze(): void;
  80143. /**
  80144. * Specifies if the material is ready to be used
  80145. * @param mesh defines the mesh to check
  80146. * @param useInstances specifies if instances should be used
  80147. * @returns a boolean indicating if the material is ready to be used
  80148. */
  80149. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  80150. /**
  80151. * Specifies that the submesh is ready to be used
  80152. * @param mesh defines the mesh to check
  80153. * @param subMesh defines which submesh to check
  80154. * @param useInstances specifies that instances should be used
  80155. * @returns a boolean indicating that the submesh is ready or not
  80156. */
  80157. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  80158. /**
  80159. * Returns the material effect
  80160. * @returns the effect associated with the material
  80161. */
  80162. getEffect(): Nullable<Effect>;
  80163. /**
  80164. * Returns the current scene
  80165. * @returns a Scene
  80166. */
  80167. getScene(): Scene;
  80168. /**
  80169. * Specifies if the material will require alpha blending
  80170. * @returns a boolean specifying if alpha blending is needed
  80171. */
  80172. needAlphaBlending(): boolean;
  80173. /**
  80174. * Specifies if the mesh will require alpha blending
  80175. * @param mesh defines the mesh to check
  80176. * @returns a boolean specifying if alpha blending is needed for the mesh
  80177. */
  80178. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  80179. /**
  80180. * Specifies if this material should be rendered in alpha test mode
  80181. * @returns a boolean specifying if an alpha test is needed.
  80182. */
  80183. needAlphaTesting(): boolean;
  80184. /**
  80185. * Gets the texture used for the alpha test
  80186. * @returns the texture to use for alpha testing
  80187. */
  80188. getAlphaTestTexture(): Nullable<BaseTexture>;
  80189. /**
  80190. * Marks the material to indicate that it needs to be re-calculated
  80191. */
  80192. markDirty(): void;
  80193. /** @hidden */
  80194. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  80195. /**
  80196. * Binds the material to the mesh
  80197. * @param world defines the world transformation matrix
  80198. * @param mesh defines the mesh to bind the material to
  80199. */
  80200. bind(world: Matrix, mesh?: Mesh): void;
  80201. /**
  80202. * Binds the submesh to the material
  80203. * @param world defines the world transformation matrix
  80204. * @param mesh defines the mesh containing the submesh
  80205. * @param subMesh defines the submesh to bind the material to
  80206. */
  80207. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  80208. /**
  80209. * Binds the world matrix to the material
  80210. * @param world defines the world transformation matrix
  80211. */
  80212. bindOnlyWorldMatrix(world: Matrix): void;
  80213. /**
  80214. * Binds the scene's uniform buffer to the effect.
  80215. * @param effect defines the effect to bind to the scene uniform buffer
  80216. * @param sceneUbo defines the uniform buffer storing scene data
  80217. */
  80218. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  80219. /**
  80220. * Binds the view matrix to the effect
  80221. * @param effect defines the effect to bind the view matrix to
  80222. */
  80223. bindView(effect: Effect): void;
  80224. /**
  80225. * Binds the view projection matrix to the effect
  80226. * @param effect defines the effect to bind the view projection matrix to
  80227. */
  80228. bindViewProjection(effect: Effect): void;
  80229. /**
  80230. * Specifies if material alpha testing should be turned on for the mesh
  80231. * @param mesh defines the mesh to check
  80232. */
  80233. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  80234. /**
  80235. * Processes to execute after binding the material to a mesh
  80236. * @param mesh defines the rendered mesh
  80237. */
  80238. protected _afterBind(mesh?: Mesh): void;
  80239. /**
  80240. * Unbinds the material from the mesh
  80241. */
  80242. unbind(): void;
  80243. /**
  80244. * Gets the active textures from the material
  80245. * @returns an array of textures
  80246. */
  80247. getActiveTextures(): BaseTexture[];
  80248. /**
  80249. * Specifies if the material uses a texture
  80250. * @param texture defines the texture to check against the material
  80251. * @returns a boolean specifying if the material uses the texture
  80252. */
  80253. hasTexture(texture: BaseTexture): boolean;
  80254. /**
  80255. * Makes a duplicate of the material, and gives it a new name
  80256. * @param name defines the new name for the duplicated material
  80257. * @returns the cloned material
  80258. */
  80259. clone(name: string): Nullable<Material>;
  80260. /**
  80261. * Gets the meshes bound to the material
  80262. * @returns an array of meshes bound to the material
  80263. */
  80264. getBindedMeshes(): AbstractMesh[];
  80265. /**
  80266. * Force shader compilation
  80267. * @param mesh defines the mesh associated with this material
  80268. * @param onCompiled defines a function to execute once the material is compiled
  80269. * @param options defines the options to configure the compilation
  80270. */
  80271. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  80272. clipPlane: boolean;
  80273. }>): void;
  80274. /**
  80275. * Force shader compilation
  80276. * @param mesh defines the mesh that will use this material
  80277. * @param options defines additional options for compiling the shaders
  80278. * @returns a promise that resolves when the compilation completes
  80279. */
  80280. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  80281. clipPlane: boolean;
  80282. }>): Promise<void>;
  80283. private static readonly _ImageProcessingDirtyCallBack;
  80284. private static readonly _TextureDirtyCallBack;
  80285. private static readonly _FresnelDirtyCallBack;
  80286. private static readonly _MiscDirtyCallBack;
  80287. private static readonly _LightsDirtyCallBack;
  80288. private static readonly _AttributeDirtyCallBack;
  80289. private static _FresnelAndMiscDirtyCallBack;
  80290. private static _TextureAndMiscDirtyCallBack;
  80291. private static readonly _DirtyCallbackArray;
  80292. private static readonly _RunDirtyCallBacks;
  80293. /**
  80294. * Marks a define in the material to indicate that it needs to be re-computed
  80295. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  80296. */
  80297. markAsDirty(flag: number): void;
  80298. /**
  80299. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  80300. * @param func defines a function which checks material defines against the submeshes
  80301. */
  80302. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  80303. /**
  80304. * Indicates that image processing needs to be re-calculated for all submeshes
  80305. */
  80306. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  80307. /**
  80308. * Indicates that textures need to be re-calculated for all submeshes
  80309. */
  80310. protected _markAllSubMeshesAsTexturesDirty(): void;
  80311. /**
  80312. * Indicates that fresnel needs to be re-calculated for all submeshes
  80313. */
  80314. protected _markAllSubMeshesAsFresnelDirty(): void;
  80315. /**
  80316. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  80317. */
  80318. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  80319. /**
  80320. * Indicates that lights need to be re-calculated for all submeshes
  80321. */
  80322. protected _markAllSubMeshesAsLightsDirty(): void;
  80323. /**
  80324. * Indicates that attributes need to be re-calculated for all submeshes
  80325. */
  80326. protected _markAllSubMeshesAsAttributesDirty(): void;
  80327. /**
  80328. * Indicates that misc needs to be re-calculated for all submeshes
  80329. */
  80330. protected _markAllSubMeshesAsMiscDirty(): void;
  80331. /**
  80332. * Indicates that textures and misc need to be re-calculated for all submeshes
  80333. */
  80334. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  80335. /**
  80336. * Disposes the material
  80337. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  80338. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  80339. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  80340. */
  80341. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  80342. /** @hidden */
  80343. private releaseVertexArrayObject;
  80344. /**
  80345. * Serializes this material
  80346. * @returns the serialized material object
  80347. */
  80348. serialize(): any;
  80349. /**
  80350. * Creates a material from parsed material data
  80351. * @param parsedMaterial defines parsed material data
  80352. * @param scene defines the hosting scene
  80353. * @param rootUrl defines the root URL to use to load textures
  80354. * @returns a new material
  80355. */
  80356. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  80357. }
  80358. }
  80359. declare module BABYLON {
  80360. /**
  80361. * Base class for submeshes
  80362. */
  80363. export class BaseSubMesh {
  80364. /** @hidden */
  80365. _materialDefines: Nullable<MaterialDefines>;
  80366. /** @hidden */
  80367. _materialEffect: Nullable<Effect>;
  80368. /**
  80369. * Gets associated effect
  80370. */
  80371. readonly effect: Nullable<Effect>;
  80372. /**
  80373. * Sets associated effect (effect used to render this submesh)
  80374. * @param effect defines the effect to associate with
  80375. * @param defines defines the set of defines used to compile this effect
  80376. */
  80377. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  80378. }
  80379. /**
  80380. * Defines a subdivision inside a mesh
  80381. */
  80382. export class SubMesh extends BaseSubMesh implements ICullable {
  80383. /** the material index to use */
  80384. materialIndex: number;
  80385. /** vertex index start */
  80386. verticesStart: number;
  80387. /** vertices count */
  80388. verticesCount: number;
  80389. /** index start */
  80390. indexStart: number;
  80391. /** indices count */
  80392. indexCount: number;
  80393. /** @hidden */
  80394. _linesIndexCount: number;
  80395. private _mesh;
  80396. private _renderingMesh;
  80397. private _boundingInfo;
  80398. private _linesIndexBuffer;
  80399. /** @hidden */
  80400. _lastColliderWorldVertices: Nullable<Vector3[]>;
  80401. /** @hidden */
  80402. _trianglePlanes: Plane[];
  80403. /** @hidden */
  80404. _lastColliderTransformMatrix: Matrix;
  80405. /** @hidden */
  80406. _renderId: number;
  80407. /** @hidden */
  80408. _alphaIndex: number;
  80409. /** @hidden */
  80410. _distanceToCamera: number;
  80411. /** @hidden */
  80412. _id: number;
  80413. private _currentMaterial;
  80414. /**
  80415. * Add a new submesh to a mesh
  80416. * @param materialIndex defines the material index to use
  80417. * @param verticesStart defines vertex index start
  80418. * @param verticesCount defines vertices count
  80419. * @param indexStart defines index start
  80420. * @param indexCount defines indices count
  80421. * @param mesh defines the parent mesh
  80422. * @param renderingMesh defines an optional rendering mesh
  80423. * @param createBoundingBox defines if bounding box should be created for this submesh
  80424. * @returns the new submesh
  80425. */
  80426. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  80427. /**
  80428. * Creates a new submesh
  80429. * @param materialIndex defines the material index to use
  80430. * @param verticesStart defines vertex index start
  80431. * @param verticesCount defines vertices count
  80432. * @param indexStart defines index start
  80433. * @param indexCount defines indices count
  80434. * @param mesh defines the parent mesh
  80435. * @param renderingMesh defines an optional rendering mesh
  80436. * @param createBoundingBox defines if bounding box should be created for this submesh
  80437. */
  80438. constructor(
  80439. /** the material index to use */
  80440. materialIndex: number,
  80441. /** vertex index start */
  80442. verticesStart: number,
  80443. /** vertices count */
  80444. verticesCount: number,
  80445. /** index start */
  80446. indexStart: number,
  80447. /** indices count */
  80448. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  80449. /**
  80450. * Returns true if this submesh covers the entire parent mesh
  80451. * @ignorenaming
  80452. */
  80453. readonly IsGlobal: boolean;
  80454. /**
  80455. * Returns the submesh BoudingInfo object
  80456. * @returns current bounding info (or mesh's one if the submesh is global)
  80457. */
  80458. getBoundingInfo(): BoundingInfo;
  80459. /**
  80460. * Sets the submesh BoundingInfo
  80461. * @param boundingInfo defines the new bounding info to use
  80462. * @returns the SubMesh
  80463. */
  80464. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  80465. /**
  80466. * Returns the mesh of the current submesh
  80467. * @return the parent mesh
  80468. */
  80469. getMesh(): AbstractMesh;
  80470. /**
  80471. * Returns the rendering mesh of the submesh
  80472. * @returns the rendering mesh (could be different from parent mesh)
  80473. */
  80474. getRenderingMesh(): Mesh;
  80475. /**
  80476. * Returns the submesh material
  80477. * @returns null or the current material
  80478. */
  80479. getMaterial(): Nullable<Material>;
  80480. /**
  80481. * Sets a new updated BoundingInfo object to the submesh
  80482. * @returns the SubMesh
  80483. */
  80484. refreshBoundingInfo(): SubMesh;
  80485. /** @hidden */
  80486. _checkCollision(collider: Collider): boolean;
  80487. /**
  80488. * Updates the submesh BoundingInfo
  80489. * @param world defines the world matrix to use to update the bounding info
  80490. * @returns the submesh
  80491. */
  80492. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  80493. /**
  80494. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  80495. * @param frustumPlanes defines the frustum planes
  80496. * @returns true if the submesh is intersecting with the frustum
  80497. */
  80498. isInFrustum(frustumPlanes: Plane[]): boolean;
  80499. /**
  80500. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  80501. * @param frustumPlanes defines the frustum planes
  80502. * @returns true if the submesh is inside the frustum
  80503. */
  80504. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  80505. /**
  80506. * Renders the submesh
  80507. * @param enableAlphaMode defines if alpha needs to be used
  80508. * @returns the submesh
  80509. */
  80510. render(enableAlphaMode: boolean): SubMesh;
  80511. /**
  80512. * @hidden
  80513. */
  80514. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  80515. /**
  80516. * Checks if the submesh intersects with a ray
  80517. * @param ray defines the ray to test
  80518. * @returns true is the passed ray intersects the submesh bounding box
  80519. */
  80520. canIntersects(ray: Ray): boolean;
  80521. /**
  80522. * Intersects current submesh with a ray
  80523. * @param ray defines the ray to test
  80524. * @param positions defines mesh's positions array
  80525. * @param indices defines mesh's indices array
  80526. * @param fastCheck defines if only bounding info should be used
  80527. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  80528. * @returns intersection info or null if no intersection
  80529. */
  80530. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  80531. /** @hidden */
  80532. private _intersectLines;
  80533. /** @hidden */
  80534. private _intersectTriangles;
  80535. /** @hidden */
  80536. _rebuild(): void;
  80537. /**
  80538. * Creates a new submesh from the passed mesh
  80539. * @param newMesh defines the new hosting mesh
  80540. * @param newRenderingMesh defines an optional rendering mesh
  80541. * @returns the new submesh
  80542. */
  80543. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  80544. /**
  80545. * Release associated resources
  80546. */
  80547. dispose(): void;
  80548. /**
  80549. * Gets the class name
  80550. * @returns the string "SubMesh".
  80551. */
  80552. getClassName(): string;
  80553. /**
  80554. * Creates a new submesh from indices data
  80555. * @param materialIndex the index of the main mesh material
  80556. * @param startIndex the index where to start the copy in the mesh indices array
  80557. * @param indexCount the number of indices to copy then from the startIndex
  80558. * @param mesh the main mesh to create the submesh from
  80559. * @param renderingMesh the optional rendering mesh
  80560. * @returns a new submesh
  80561. */
  80562. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  80563. }
  80564. }
  80565. declare module BABYLON {
  80566. /**
  80567. * Class used to store geometry data (vertex buffers + index buffer)
  80568. */
  80569. export class Geometry implements IGetSetVerticesData {
  80570. /**
  80571. * Gets or sets the ID of the geometry
  80572. */
  80573. id: string;
  80574. /**
  80575. * Gets or sets the unique ID of the geometry
  80576. */
  80577. uniqueId: number;
  80578. /**
  80579. * Gets the delay loading state of the geometry (none by default which means not delayed)
  80580. */
  80581. delayLoadState: number;
  80582. /**
  80583. * Gets the file containing the data to load when running in delay load state
  80584. */
  80585. delayLoadingFile: Nullable<string>;
  80586. /**
  80587. * Callback called when the geometry is updated
  80588. */
  80589. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  80590. private _scene;
  80591. private _engine;
  80592. private _meshes;
  80593. private _totalVertices;
  80594. /** @hidden */
  80595. _indices: IndicesArray;
  80596. /** @hidden */
  80597. _vertexBuffers: {
  80598. [key: string]: VertexBuffer;
  80599. };
  80600. private _isDisposed;
  80601. private _extend;
  80602. private _boundingBias;
  80603. /** @hidden */
  80604. _delayInfo: Array<string>;
  80605. private _indexBuffer;
  80606. private _indexBufferIsUpdatable;
  80607. /** @hidden */
  80608. _boundingInfo: Nullable<BoundingInfo>;
  80609. /** @hidden */
  80610. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  80611. /** @hidden */
  80612. _softwareSkinningFrameId: number;
  80613. private _vertexArrayObjects;
  80614. private _updatable;
  80615. /** @hidden */
  80616. _positions: Nullable<Vector3[]>;
  80617. /**
  80618. * 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
  80619. */
  80620. /**
  80621. * 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
  80622. */
  80623. boundingBias: Vector2;
  80624. /**
  80625. * Static function used to attach a new empty geometry to a mesh
  80626. * @param mesh defines the mesh to attach the geometry to
  80627. * @returns the new Geometry
  80628. */
  80629. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  80630. /**
  80631. * Creates a new geometry
  80632. * @param id defines the unique ID
  80633. * @param scene defines the hosting scene
  80634. * @param vertexData defines the VertexData used to get geometry data
  80635. * @param updatable defines if geometry must be updatable (false by default)
  80636. * @param mesh defines the mesh that will be associated with the geometry
  80637. */
  80638. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  80639. /**
  80640. * Gets the current extend of the geometry
  80641. */
  80642. readonly extend: {
  80643. minimum: Vector3;
  80644. maximum: Vector3;
  80645. };
  80646. /**
  80647. * Gets the hosting scene
  80648. * @returns the hosting Scene
  80649. */
  80650. getScene(): Scene;
  80651. /**
  80652. * Gets the hosting engine
  80653. * @returns the hosting Engine
  80654. */
  80655. getEngine(): Engine;
  80656. /**
  80657. * Defines if the geometry is ready to use
  80658. * @returns true if the geometry is ready to be used
  80659. */
  80660. isReady(): boolean;
  80661. /**
  80662. * Gets a value indicating that the geometry should not be serialized
  80663. */
  80664. readonly doNotSerialize: boolean;
  80665. /** @hidden */
  80666. _rebuild(): void;
  80667. /**
  80668. * Affects all geometry data in one call
  80669. * @param vertexData defines the geometry data
  80670. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  80671. */
  80672. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  80673. /**
  80674. * Set specific vertex data
  80675. * @param kind defines the data kind (Position, normal, etc...)
  80676. * @param data defines the vertex data to use
  80677. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  80678. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  80679. */
  80680. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  80681. /**
  80682. * Removes a specific vertex data
  80683. * @param kind defines the data kind (Position, normal, etc...)
  80684. */
  80685. removeVerticesData(kind: string): void;
  80686. /**
  80687. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  80688. * @param buffer defines the vertex buffer to use
  80689. * @param totalVertices defines the total number of vertices for position kind (could be null)
  80690. */
  80691. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  80692. /**
  80693. * Update a specific vertex buffer
  80694. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  80695. * It will do nothing if the buffer is not updatable
  80696. * @param kind defines the data kind (Position, normal, etc...)
  80697. * @param data defines the data to use
  80698. * @param offset defines the offset in the target buffer where to store the data
  80699. * @param useBytes set to true if the offset is in bytes
  80700. */
  80701. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  80702. /**
  80703. * Update a specific vertex buffer
  80704. * This function will create a new buffer if the current one is not updatable
  80705. * @param kind defines the data kind (Position, normal, etc...)
  80706. * @param data defines the data to use
  80707. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  80708. */
  80709. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  80710. private _updateBoundingInfo;
  80711. /** @hidden */
  80712. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  80713. /**
  80714. * Gets total number of vertices
  80715. * @returns the total number of vertices
  80716. */
  80717. getTotalVertices(): number;
  80718. /**
  80719. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  80720. * @param kind defines the data kind (Position, normal, etc...)
  80721. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  80722. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  80723. * @returns a float array containing vertex data
  80724. */
  80725. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  80726. /**
  80727. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  80728. * @param kind defines the data kind (Position, normal, etc...)
  80729. * @returns true if the vertex buffer with the specified kind is updatable
  80730. */
  80731. isVertexBufferUpdatable(kind: string): boolean;
  80732. /**
  80733. * Gets a specific vertex buffer
  80734. * @param kind defines the data kind (Position, normal, etc...)
  80735. * @returns a VertexBuffer
  80736. */
  80737. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  80738. /**
  80739. * Returns all vertex buffers
  80740. * @return an object holding all vertex buffers indexed by kind
  80741. */
  80742. getVertexBuffers(): Nullable<{
  80743. [key: string]: VertexBuffer;
  80744. }>;
  80745. /**
  80746. * Gets a boolean indicating if specific vertex buffer is present
  80747. * @param kind defines the data kind (Position, normal, etc...)
  80748. * @returns true if data is present
  80749. */
  80750. isVerticesDataPresent(kind: string): boolean;
  80751. /**
  80752. * Gets a list of all attached data kinds (Position, normal, etc...)
  80753. * @returns a list of string containing all kinds
  80754. */
  80755. getVerticesDataKinds(): string[];
  80756. /**
  80757. * Update index buffer
  80758. * @param indices defines the indices to store in the index buffer
  80759. * @param offset defines the offset in the target buffer where to store the data
  80760. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  80761. */
  80762. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  80763. /**
  80764. * Creates a new index buffer
  80765. * @param indices defines the indices to store in the index buffer
  80766. * @param totalVertices defines the total number of vertices (could be null)
  80767. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  80768. */
  80769. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  80770. /**
  80771. * Return the total number of indices
  80772. * @returns the total number of indices
  80773. */
  80774. getTotalIndices(): number;
  80775. /**
  80776. * Gets the index buffer array
  80777. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  80778. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  80779. * @returns the index buffer array
  80780. */
  80781. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  80782. /**
  80783. * Gets the index buffer
  80784. * @return the index buffer
  80785. */
  80786. getIndexBuffer(): Nullable<WebGLBuffer>;
  80787. /** @hidden */
  80788. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  80789. /**
  80790. * Release the associated resources for a specific mesh
  80791. * @param mesh defines the source mesh
  80792. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  80793. */
  80794. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  80795. /**
  80796. * Apply current geometry to a given mesh
  80797. * @param mesh defines the mesh to apply geometry to
  80798. */
  80799. applyToMesh(mesh: Mesh): void;
  80800. private _updateExtend;
  80801. private _applyToMesh;
  80802. private notifyUpdate;
  80803. /**
  80804. * Load the geometry if it was flagged as delay loaded
  80805. * @param scene defines the hosting scene
  80806. * @param onLoaded defines a callback called when the geometry is loaded
  80807. */
  80808. load(scene: Scene, onLoaded?: () => void): void;
  80809. private _queueLoad;
  80810. /**
  80811. * Invert the geometry to move from a right handed system to a left handed one.
  80812. */
  80813. toLeftHanded(): void;
  80814. /** @hidden */
  80815. _resetPointsArrayCache(): void;
  80816. /** @hidden */
  80817. _generatePointsArray(): boolean;
  80818. /**
  80819. * Gets a value indicating if the geometry is disposed
  80820. * @returns true if the geometry was disposed
  80821. */
  80822. isDisposed(): boolean;
  80823. private _disposeVertexArrayObjects;
  80824. /**
  80825. * Free all associated resources
  80826. */
  80827. dispose(): void;
  80828. /**
  80829. * Clone the current geometry into a new geometry
  80830. * @param id defines the unique ID of the new geometry
  80831. * @returns a new geometry object
  80832. */
  80833. copy(id: string): Geometry;
  80834. /**
  80835. * Serialize the current geometry info (and not the vertices data) into a JSON object
  80836. * @return a JSON representation of the current geometry data (without the vertices data)
  80837. */
  80838. serialize(): any;
  80839. private toNumberArray;
  80840. /**
  80841. * Serialize all vertices data into a JSON oject
  80842. * @returns a JSON representation of the current geometry data
  80843. */
  80844. serializeVerticeData(): any;
  80845. /**
  80846. * Extracts a clone of a mesh geometry
  80847. * @param mesh defines the source mesh
  80848. * @param id defines the unique ID of the new geometry object
  80849. * @returns the new geometry object
  80850. */
  80851. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  80852. /**
  80853. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  80854. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  80855. * Be aware Math.random() could cause collisions, but:
  80856. * "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"
  80857. * @returns a string containing a new GUID
  80858. */
  80859. static RandomId(): string;
  80860. /** @hidden */
  80861. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  80862. private static _CleanMatricesWeights;
  80863. /**
  80864. * Create a new geometry from persisted data (Using .babylon file format)
  80865. * @param parsedVertexData defines the persisted data
  80866. * @param scene defines the hosting scene
  80867. * @param rootUrl defines the root url to use to load assets (like delayed data)
  80868. * @returns the new geometry object
  80869. */
  80870. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  80871. }
  80872. }
  80873. declare module BABYLON {
  80874. /**
  80875. * Define an interface for all classes that will get and set the data on vertices
  80876. */
  80877. export interface IGetSetVerticesData {
  80878. /**
  80879. * Gets a boolean indicating if specific vertex data is present
  80880. * @param kind defines the vertex data kind to use
  80881. * @returns true is data kind is present
  80882. */
  80883. isVerticesDataPresent(kind: string): boolean;
  80884. /**
  80885. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  80886. * @param kind defines the data kind (Position, normal, etc...)
  80887. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  80888. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  80889. * @returns a float array containing vertex data
  80890. */
  80891. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  80892. /**
  80893. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  80894. * @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.
  80895. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  80896. * @returns the indices array or an empty array if the mesh has no geometry
  80897. */
  80898. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  80899. /**
  80900. * Set specific vertex data
  80901. * @param kind defines the data kind (Position, normal, etc...)
  80902. * @param data defines the vertex data to use
  80903. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  80904. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  80905. */
  80906. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  80907. /**
  80908. * Update a specific associated vertex buffer
  80909. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  80910. * - VertexBuffer.PositionKind
  80911. * - VertexBuffer.UVKind
  80912. * - VertexBuffer.UV2Kind
  80913. * - VertexBuffer.UV3Kind
  80914. * - VertexBuffer.UV4Kind
  80915. * - VertexBuffer.UV5Kind
  80916. * - VertexBuffer.UV6Kind
  80917. * - VertexBuffer.ColorKind
  80918. * - VertexBuffer.MatricesIndicesKind
  80919. * - VertexBuffer.MatricesIndicesExtraKind
  80920. * - VertexBuffer.MatricesWeightsKind
  80921. * - VertexBuffer.MatricesWeightsExtraKind
  80922. * @param data defines the data source
  80923. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  80924. * @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)
  80925. */
  80926. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  80927. /**
  80928. * Creates a new index buffer
  80929. * @param indices defines the indices to store in the index buffer
  80930. * @param totalVertices defines the total number of vertices (could be null)
  80931. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  80932. */
  80933. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  80934. }
  80935. /**
  80936. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  80937. */
  80938. export class VertexData {
  80939. /**
  80940. * Mesh side orientation : usually the external or front surface
  80941. */
  80942. static readonly FRONTSIDE: number;
  80943. /**
  80944. * Mesh side orientation : usually the internal or back surface
  80945. */
  80946. static readonly BACKSIDE: number;
  80947. /**
  80948. * Mesh side orientation : both internal and external or front and back surfaces
  80949. */
  80950. static readonly DOUBLESIDE: number;
  80951. /**
  80952. * Mesh side orientation : by default, `FRONTSIDE`
  80953. */
  80954. static readonly DEFAULTSIDE: number;
  80955. /**
  80956. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  80957. */
  80958. positions: Nullable<FloatArray>;
  80959. /**
  80960. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  80961. */
  80962. normals: Nullable<FloatArray>;
  80963. /**
  80964. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  80965. */
  80966. tangents: Nullable<FloatArray>;
  80967. /**
  80968. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  80969. */
  80970. uvs: Nullable<FloatArray>;
  80971. /**
  80972. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  80973. */
  80974. uvs2: Nullable<FloatArray>;
  80975. /**
  80976. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  80977. */
  80978. uvs3: Nullable<FloatArray>;
  80979. /**
  80980. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  80981. */
  80982. uvs4: Nullable<FloatArray>;
  80983. /**
  80984. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  80985. */
  80986. uvs5: Nullable<FloatArray>;
  80987. /**
  80988. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  80989. */
  80990. uvs6: Nullable<FloatArray>;
  80991. /**
  80992. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  80993. */
  80994. colors: Nullable<FloatArray>;
  80995. /**
  80996. * 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).
  80997. */
  80998. matricesIndices: Nullable<FloatArray>;
  80999. /**
  81000. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  81001. */
  81002. matricesWeights: Nullable<FloatArray>;
  81003. /**
  81004. * An array extending the number of possible indices
  81005. */
  81006. matricesIndicesExtra: Nullable<FloatArray>;
  81007. /**
  81008. * An array extending the number of possible weights when the number of indices is extended
  81009. */
  81010. matricesWeightsExtra: Nullable<FloatArray>;
  81011. /**
  81012. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  81013. */
  81014. indices: Nullable<IndicesArray>;
  81015. /**
  81016. * Uses the passed data array to set the set the values for the specified kind of data
  81017. * @param data a linear array of floating numbers
  81018. * @param kind the type of data that is being set, eg positions, colors etc
  81019. */
  81020. set(data: FloatArray, kind: string): void;
  81021. /**
  81022. * Associates the vertexData to the passed Mesh.
  81023. * Sets it as updatable or not (default `false`)
  81024. * @param mesh the mesh the vertexData is applied to
  81025. * @param updatable when used and having the value true allows new data to update the vertexData
  81026. * @returns the VertexData
  81027. */
  81028. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  81029. /**
  81030. * Associates the vertexData to the passed Geometry.
  81031. * Sets it as updatable or not (default `false`)
  81032. * @param geometry the geometry the vertexData is applied to
  81033. * @param updatable when used and having the value true allows new data to update the vertexData
  81034. * @returns VertexData
  81035. */
  81036. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  81037. /**
  81038. * Updates the associated mesh
  81039. * @param mesh the mesh to be updated
  81040. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  81041. * @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
  81042. * @returns VertexData
  81043. */
  81044. updateMesh(mesh: Mesh): VertexData;
  81045. /**
  81046. * Updates the associated geometry
  81047. * @param geometry the geometry to be updated
  81048. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  81049. * @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
  81050. * @returns VertexData.
  81051. */
  81052. updateGeometry(geometry: Geometry): VertexData;
  81053. private _applyTo;
  81054. private _update;
  81055. /**
  81056. * Transforms each position and each normal of the vertexData according to the passed Matrix
  81057. * @param matrix the transforming matrix
  81058. * @returns the VertexData
  81059. */
  81060. transform(matrix: Matrix): VertexData;
  81061. /**
  81062. * Merges the passed VertexData into the current one
  81063. * @param other the VertexData to be merged into the current one
  81064. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  81065. * @returns the modified VertexData
  81066. */
  81067. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  81068. private _mergeElement;
  81069. private _validate;
  81070. /**
  81071. * Serializes the VertexData
  81072. * @returns a serialized object
  81073. */
  81074. serialize(): any;
  81075. /**
  81076. * Extracts the vertexData from a mesh
  81077. * @param mesh the mesh from which to extract the VertexData
  81078. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  81079. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  81080. * @returns the object VertexData associated to the passed mesh
  81081. */
  81082. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  81083. /**
  81084. * Extracts the vertexData from the geometry
  81085. * @param geometry the geometry from which to extract the VertexData
  81086. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  81087. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  81088. * @returns the object VertexData associated to the passed mesh
  81089. */
  81090. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  81091. private static _ExtractFrom;
  81092. /**
  81093. * Creates the VertexData for a Ribbon
  81094. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  81095. * * pathArray array of paths, each of which an array of successive Vector3
  81096. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  81097. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  81098. * * 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
  81099. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81100. * * 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)
  81101. * * 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)
  81102. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  81103. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  81104. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  81105. * @returns the VertexData of the ribbon
  81106. */
  81107. static CreateRibbon(options: {
  81108. pathArray: Vector3[][];
  81109. closeArray?: boolean;
  81110. closePath?: boolean;
  81111. offset?: number;
  81112. sideOrientation?: number;
  81113. frontUVs?: Vector4;
  81114. backUVs?: Vector4;
  81115. invertUV?: boolean;
  81116. uvs?: Vector2[];
  81117. colors?: Color4[];
  81118. }): VertexData;
  81119. /**
  81120. * Creates the VertexData for a box
  81121. * @param options an object used to set the following optional parameters for the box, required but can be empty
  81122. * * size sets the width, height and depth of the box to the value of size, optional default 1
  81123. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  81124. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  81125. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  81126. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  81127. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  81128. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81129. * * 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)
  81130. * * 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)
  81131. * @returns the VertexData of the box
  81132. */
  81133. static CreateBox(options: {
  81134. size?: number;
  81135. width?: number;
  81136. height?: number;
  81137. depth?: number;
  81138. faceUV?: Vector4[];
  81139. faceColors?: Color4[];
  81140. sideOrientation?: number;
  81141. frontUVs?: Vector4;
  81142. backUVs?: Vector4;
  81143. }): VertexData;
  81144. /**
  81145. * Creates the VertexData for an ellipsoid, defaults to a sphere
  81146. * @param options an object used to set the following optional parameters for the box, required but can be empty
  81147. * * segments sets the number of horizontal strips optional, default 32
  81148. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  81149. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  81150. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  81151. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  81152. * * 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
  81153. * * 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
  81154. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81155. * * 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)
  81156. * * 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)
  81157. * @returns the VertexData of the ellipsoid
  81158. */
  81159. static CreateSphere(options: {
  81160. segments?: number;
  81161. diameter?: number;
  81162. diameterX?: number;
  81163. diameterY?: number;
  81164. diameterZ?: number;
  81165. arc?: number;
  81166. slice?: number;
  81167. sideOrientation?: number;
  81168. frontUVs?: Vector4;
  81169. backUVs?: Vector4;
  81170. }): VertexData;
  81171. /**
  81172. * Creates the VertexData for a cylinder, cone or prism
  81173. * @param options an object used to set the following optional parameters for the box, required but can be empty
  81174. * * height sets the height (y direction) of the cylinder, optional, default 2
  81175. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  81176. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  81177. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  81178. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  81179. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  81180. * * 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
  81181. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  81182. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  81183. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  81184. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  81185. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81186. * * 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)
  81187. * * 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)
  81188. * @returns the VertexData of the cylinder, cone or prism
  81189. */
  81190. static CreateCylinder(options: {
  81191. height?: number;
  81192. diameterTop?: number;
  81193. diameterBottom?: number;
  81194. diameter?: number;
  81195. tessellation?: number;
  81196. subdivisions?: number;
  81197. arc?: number;
  81198. faceColors?: Color4[];
  81199. faceUV?: Vector4[];
  81200. hasRings?: boolean;
  81201. enclose?: boolean;
  81202. sideOrientation?: number;
  81203. frontUVs?: Vector4;
  81204. backUVs?: Vector4;
  81205. }): VertexData;
  81206. /**
  81207. * Creates the VertexData for a torus
  81208. * @param options an object used to set the following optional parameters for the box, required but can be empty
  81209. * * diameter the diameter of the torus, optional default 1
  81210. * * thickness the diameter of the tube forming the torus, optional default 0.5
  81211. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  81212. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81213. * * 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)
  81214. * * 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)
  81215. * @returns the VertexData of the torus
  81216. */
  81217. static CreateTorus(options: {
  81218. diameter?: number;
  81219. thickness?: number;
  81220. tessellation?: number;
  81221. sideOrientation?: number;
  81222. frontUVs?: Vector4;
  81223. backUVs?: Vector4;
  81224. }): VertexData;
  81225. /**
  81226. * Creates the VertexData of the LineSystem
  81227. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  81228. * - lines an array of lines, each line being an array of successive Vector3
  81229. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  81230. * @returns the VertexData of the LineSystem
  81231. */
  81232. static CreateLineSystem(options: {
  81233. lines: Vector3[][];
  81234. colors?: Nullable<Color4[][]>;
  81235. }): VertexData;
  81236. /**
  81237. * Create the VertexData for a DashedLines
  81238. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  81239. * - points an array successive Vector3
  81240. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  81241. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  81242. * - dashNb the intended total number of dashes, optional, default 200
  81243. * @returns the VertexData for the DashedLines
  81244. */
  81245. static CreateDashedLines(options: {
  81246. points: Vector3[];
  81247. dashSize?: number;
  81248. gapSize?: number;
  81249. dashNb?: number;
  81250. }): VertexData;
  81251. /**
  81252. * Creates the VertexData for a Ground
  81253. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  81254. * - width the width (x direction) of the ground, optional, default 1
  81255. * - height the height (z direction) of the ground, optional, default 1
  81256. * - subdivisions the number of subdivisions per side, optional, default 1
  81257. * @returns the VertexData of the Ground
  81258. */
  81259. static CreateGround(options: {
  81260. width?: number;
  81261. height?: number;
  81262. subdivisions?: number;
  81263. subdivisionsX?: number;
  81264. subdivisionsY?: number;
  81265. }): VertexData;
  81266. /**
  81267. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  81268. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  81269. * * xmin the ground minimum X coordinate, optional, default -1
  81270. * * zmin the ground minimum Z coordinate, optional, default -1
  81271. * * xmax the ground maximum X coordinate, optional, default 1
  81272. * * zmax the ground maximum Z coordinate, optional, default 1
  81273. * * 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}
  81274. * * 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}
  81275. * @returns the VertexData of the TiledGround
  81276. */
  81277. static CreateTiledGround(options: {
  81278. xmin: number;
  81279. zmin: number;
  81280. xmax: number;
  81281. zmax: number;
  81282. subdivisions?: {
  81283. w: number;
  81284. h: number;
  81285. };
  81286. precision?: {
  81287. w: number;
  81288. h: number;
  81289. };
  81290. }): VertexData;
  81291. /**
  81292. * Creates the VertexData of the Ground designed from a heightmap
  81293. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  81294. * * width the width (x direction) of the ground
  81295. * * height the height (z direction) of the ground
  81296. * * subdivisions the number of subdivisions per side
  81297. * * minHeight the minimum altitude on the ground, optional, default 0
  81298. * * maxHeight the maximum altitude on the ground, optional default 1
  81299. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  81300. * * buffer the array holding the image color data
  81301. * * bufferWidth the width of image
  81302. * * bufferHeight the height of image
  81303. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  81304. * @returns the VertexData of the Ground designed from a heightmap
  81305. */
  81306. static CreateGroundFromHeightMap(options: {
  81307. width: number;
  81308. height: number;
  81309. subdivisions: number;
  81310. minHeight: number;
  81311. maxHeight: number;
  81312. colorFilter: Color3;
  81313. buffer: Uint8Array;
  81314. bufferWidth: number;
  81315. bufferHeight: number;
  81316. alphaFilter: number;
  81317. }): VertexData;
  81318. /**
  81319. * Creates the VertexData for a Plane
  81320. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  81321. * * size sets the width and height of the plane to the value of size, optional default 1
  81322. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  81323. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  81324. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81325. * * 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)
  81326. * * 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)
  81327. * @returns the VertexData of the box
  81328. */
  81329. static CreatePlane(options: {
  81330. size?: number;
  81331. width?: number;
  81332. height?: number;
  81333. sideOrientation?: number;
  81334. frontUVs?: Vector4;
  81335. backUVs?: Vector4;
  81336. }): VertexData;
  81337. /**
  81338. * Creates the VertexData of the Disc or regular Polygon
  81339. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  81340. * * radius the radius of the disc, optional default 0.5
  81341. * * tessellation the number of polygon sides, optional, default 64
  81342. * * 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
  81343. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81344. * * 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)
  81345. * * 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)
  81346. * @returns the VertexData of the box
  81347. */
  81348. static CreateDisc(options: {
  81349. radius?: number;
  81350. tessellation?: number;
  81351. arc?: number;
  81352. sideOrientation?: number;
  81353. frontUVs?: Vector4;
  81354. backUVs?: Vector4;
  81355. }): VertexData;
  81356. /**
  81357. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  81358. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  81359. * @param polygon a mesh built from polygonTriangulation.build()
  81360. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81361. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  81362. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  81363. * @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)
  81364. * @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)
  81365. * @returns the VertexData of the Polygon
  81366. */
  81367. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  81368. /**
  81369. * Creates the VertexData of the IcoSphere
  81370. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  81371. * * radius the radius of the IcoSphere, optional default 1
  81372. * * radiusX allows stretching in the x direction, optional, default radius
  81373. * * radiusY allows stretching in the y direction, optional, default radius
  81374. * * radiusZ allows stretching in the z direction, optional, default radius
  81375. * * flat when true creates a flat shaded mesh, optional, default true
  81376. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  81377. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81378. * * 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)
  81379. * * 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)
  81380. * @returns the VertexData of the IcoSphere
  81381. */
  81382. static CreateIcoSphere(options: {
  81383. radius?: number;
  81384. radiusX?: number;
  81385. radiusY?: number;
  81386. radiusZ?: number;
  81387. flat?: boolean;
  81388. subdivisions?: number;
  81389. sideOrientation?: number;
  81390. frontUVs?: Vector4;
  81391. backUVs?: Vector4;
  81392. }): VertexData;
  81393. /**
  81394. * Creates the VertexData for a Polyhedron
  81395. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  81396. * * type provided types are:
  81397. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  81398. * * 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)
  81399. * * size the size of the IcoSphere, optional default 1
  81400. * * sizeX allows stretching in the x direction, optional, default size
  81401. * * sizeY allows stretching in the y direction, optional, default size
  81402. * * sizeZ allows stretching in the z direction, optional, default size
  81403. * * 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
  81404. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  81405. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  81406. * * flat when true creates a flat shaded mesh, optional, default true
  81407. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  81408. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81409. * * 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)
  81410. * * 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)
  81411. * @returns the VertexData of the Polyhedron
  81412. */
  81413. static CreatePolyhedron(options: {
  81414. type?: number;
  81415. size?: number;
  81416. sizeX?: number;
  81417. sizeY?: number;
  81418. sizeZ?: number;
  81419. custom?: any;
  81420. faceUV?: Vector4[];
  81421. faceColors?: Color4[];
  81422. flat?: boolean;
  81423. sideOrientation?: number;
  81424. frontUVs?: Vector4;
  81425. backUVs?: Vector4;
  81426. }): VertexData;
  81427. /**
  81428. * Creates the VertexData for a TorusKnot
  81429. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  81430. * * radius the radius of the torus knot, optional, default 2
  81431. * * tube the thickness of the tube, optional, default 0.5
  81432. * * radialSegments the number of sides on each tube segments, optional, default 32
  81433. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  81434. * * p the number of windings around the z axis, optional, default 2
  81435. * * q the number of windings around the x axis, optional, default 3
  81436. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81437. * * 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)
  81438. * * 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)
  81439. * @returns the VertexData of the Torus Knot
  81440. */
  81441. static CreateTorusKnot(options: {
  81442. radius?: number;
  81443. tube?: number;
  81444. radialSegments?: number;
  81445. tubularSegments?: number;
  81446. p?: number;
  81447. q?: number;
  81448. sideOrientation?: number;
  81449. frontUVs?: Vector4;
  81450. backUVs?: Vector4;
  81451. }): VertexData;
  81452. /**
  81453. * Compute normals for given positions and indices
  81454. * @param positions an array of vertex positions, [...., x, y, z, ......]
  81455. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  81456. * @param normals an array of vertex normals, [...., x, y, z, ......]
  81457. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  81458. * * facetNormals : optional array of facet normals (vector3)
  81459. * * facetPositions : optional array of facet positions (vector3)
  81460. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  81461. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  81462. * * bInfo : optional bounding info, required for facetPartitioning computation
  81463. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  81464. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  81465. * * useRightHandedSystem: optional boolean to for right handed system computation
  81466. * * depthSort : optional boolean to enable the facet depth sort computation
  81467. * * distanceTo : optional Vector3 to compute the facet depth from this location
  81468. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  81469. */
  81470. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  81471. facetNormals?: any;
  81472. facetPositions?: any;
  81473. facetPartitioning?: any;
  81474. ratio?: number;
  81475. bInfo?: any;
  81476. bbSize?: Vector3;
  81477. subDiv?: any;
  81478. useRightHandedSystem?: boolean;
  81479. depthSort?: boolean;
  81480. distanceTo?: Vector3;
  81481. depthSortedFacets?: any;
  81482. }): void;
  81483. /** @hidden */
  81484. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  81485. /**
  81486. * Applies VertexData created from the imported parameters to the geometry
  81487. * @param parsedVertexData the parsed data from an imported file
  81488. * @param geometry the geometry to apply the VertexData to
  81489. */
  81490. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  81491. }
  81492. }
  81493. declare module BABYLON {
  81494. /**
  81495. * Class containing static functions to help procedurally build meshes
  81496. */
  81497. export class DiscBuilder {
  81498. /**
  81499. * Creates a plane polygonal mesh. By default, this is a disc
  81500. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  81501. * * 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
  81502. * * 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
  81503. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  81504. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  81505. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81506. * @param name defines the name of the mesh
  81507. * @param options defines the options used to create the mesh
  81508. * @param scene defines the hosting scene
  81509. * @returns the plane polygonal mesh
  81510. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  81511. */
  81512. static CreateDisc(name: string, options: {
  81513. radius?: number;
  81514. tessellation?: number;
  81515. arc?: number;
  81516. updatable?: boolean;
  81517. sideOrientation?: number;
  81518. frontUVs?: Vector4;
  81519. backUVs?: Vector4;
  81520. }, scene?: Nullable<Scene>): Mesh;
  81521. }
  81522. }
  81523. declare module BABYLON {
  81524. /**
  81525. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  81526. *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.
  81527. * The SPS is also a particle system. It provides some methods to manage the particles.
  81528. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  81529. *
  81530. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  81531. */
  81532. export class SolidParticleSystem implements IDisposable {
  81533. /**
  81534. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  81535. * Example : var p = SPS.particles[i];
  81536. */
  81537. particles: SolidParticle[];
  81538. /**
  81539. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  81540. */
  81541. nbParticles: number;
  81542. /**
  81543. * If the particles must ever face the camera (default false). Useful for planar particles.
  81544. */
  81545. billboard: boolean;
  81546. /**
  81547. * Recompute normals when adding a shape
  81548. */
  81549. recomputeNormals: boolean;
  81550. /**
  81551. * This a counter ofr your own usage. It's not set by any SPS functions.
  81552. */
  81553. counter: number;
  81554. /**
  81555. * The SPS name. This name is also given to the underlying mesh.
  81556. */
  81557. name: string;
  81558. /**
  81559. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  81560. */
  81561. mesh: Mesh;
  81562. /**
  81563. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  81564. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  81565. */
  81566. vars: any;
  81567. /**
  81568. * This array is populated when the SPS is set as 'pickable'.
  81569. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  81570. * Each element of this array is an object `{idx: int, faceId: int}`.
  81571. * `idx` is the picked particle index in the `SPS.particles` array
  81572. * `faceId` is the picked face index counted within this particle.
  81573. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  81574. */
  81575. pickedParticles: {
  81576. idx: number;
  81577. faceId: number;
  81578. }[];
  81579. /**
  81580. * This array is populated when `enableDepthSort` is set to true.
  81581. * Each element of this array is an instance of the class DepthSortedParticle.
  81582. */
  81583. depthSortedParticles: DepthSortedParticle[];
  81584. /**
  81585. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  81586. * @hidden
  81587. */
  81588. _bSphereOnly: boolean;
  81589. /**
  81590. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  81591. * @hidden
  81592. */
  81593. _bSphereRadiusFactor: number;
  81594. private _scene;
  81595. private _positions;
  81596. private _indices;
  81597. private _normals;
  81598. private _colors;
  81599. private _uvs;
  81600. private _indices32;
  81601. private _positions32;
  81602. private _normals32;
  81603. private _fixedNormal32;
  81604. private _colors32;
  81605. private _uvs32;
  81606. private _index;
  81607. private _updatable;
  81608. private _pickable;
  81609. private _isVisibilityBoxLocked;
  81610. private _alwaysVisible;
  81611. private _depthSort;
  81612. private _shapeCounter;
  81613. private _copy;
  81614. private _color;
  81615. private _computeParticleColor;
  81616. private _computeParticleTexture;
  81617. private _computeParticleRotation;
  81618. private _computeParticleVertex;
  81619. private _computeBoundingBox;
  81620. private _depthSortParticles;
  81621. private _camera;
  81622. private _mustUnrotateFixedNormals;
  81623. private _particlesIntersect;
  81624. private _needs32Bits;
  81625. /**
  81626. * Creates a SPS (Solid Particle System) object.
  81627. * @param name (String) is the SPS name, this will be the underlying mesh name.
  81628. * @param scene (Scene) is the scene in which the SPS is added.
  81629. * @param options defines the options of the sps e.g.
  81630. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  81631. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  81632. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  81633. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  81634. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  81635. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  81636. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  81637. */
  81638. constructor(name: string, scene: Scene, options?: {
  81639. updatable?: boolean;
  81640. isPickable?: boolean;
  81641. enableDepthSort?: boolean;
  81642. particleIntersection?: boolean;
  81643. boundingSphereOnly?: boolean;
  81644. bSphereRadiusFactor?: number;
  81645. });
  81646. /**
  81647. * Builds the SPS underlying mesh. Returns a standard Mesh.
  81648. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  81649. * @returns the created mesh
  81650. */
  81651. buildMesh(): Mesh;
  81652. /**
  81653. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  81654. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  81655. * Thus the particles generated from `digest()` have their property `position` set yet.
  81656. * @param mesh ( Mesh ) is the mesh to be digested
  81657. * @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
  81658. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  81659. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  81660. * @returns the current SPS
  81661. */
  81662. digest(mesh: Mesh, options?: {
  81663. facetNb?: number;
  81664. number?: number;
  81665. delta?: number;
  81666. }): SolidParticleSystem;
  81667. private _unrotateFixedNormals;
  81668. private _resetCopy;
  81669. private _meshBuilder;
  81670. private _posToShape;
  81671. private _uvsToShapeUV;
  81672. private _addParticle;
  81673. /**
  81674. * Adds some particles to the SPS from the model shape. Returns the shape id.
  81675. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  81676. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  81677. * @param nb (positive integer) the number of particles to be created from this model
  81678. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  81679. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  81680. * @returns the number of shapes in the system
  81681. */
  81682. addShape(mesh: Mesh, nb: number, options?: {
  81683. positionFunction?: any;
  81684. vertexFunction?: any;
  81685. }): number;
  81686. private _rebuildParticle;
  81687. /**
  81688. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  81689. * @returns the SPS.
  81690. */
  81691. rebuildMesh(): SolidParticleSystem;
  81692. /**
  81693. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  81694. * This method calls `updateParticle()` for each particle of the SPS.
  81695. * For an animated SPS, it is usually called within the render loop.
  81696. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  81697. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  81698. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  81699. * @returns the SPS.
  81700. */
  81701. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  81702. /**
  81703. * Disposes the SPS.
  81704. */
  81705. dispose(): void;
  81706. /**
  81707. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  81708. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  81709. * @returns the SPS.
  81710. */
  81711. refreshVisibleSize(): SolidParticleSystem;
  81712. /**
  81713. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  81714. * @param size the size (float) of the visibility box
  81715. * note : this doesn't lock the SPS mesh bounding box.
  81716. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  81717. */
  81718. setVisibilityBox(size: number): void;
  81719. /**
  81720. * Gets whether the SPS as always visible or not
  81721. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  81722. */
  81723. /**
  81724. * Sets the SPS as always visible or not
  81725. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  81726. */
  81727. isAlwaysVisible: boolean;
  81728. /**
  81729. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  81730. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  81731. */
  81732. /**
  81733. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  81734. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  81735. */
  81736. isVisibilityBoxLocked: boolean;
  81737. /**
  81738. * Tells to `setParticles()` to compute the particle rotations or not.
  81739. * Default value : true. The SPS is faster when it's set to false.
  81740. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  81741. */
  81742. /**
  81743. * Gets if `setParticles()` computes the particle rotations or not.
  81744. * Default value : true. The SPS is faster when it's set to false.
  81745. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  81746. */
  81747. computeParticleRotation: boolean;
  81748. /**
  81749. * Tells to `setParticles()` to compute the particle colors or not.
  81750. * Default value : true. The SPS is faster when it's set to false.
  81751. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  81752. */
  81753. /**
  81754. * Gets if `setParticles()` computes the particle colors or not.
  81755. * Default value : true. The SPS is faster when it's set to false.
  81756. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  81757. */
  81758. computeParticleColor: boolean;
  81759. /**
  81760. * Gets if `setParticles()` computes the particle textures or not.
  81761. * Default value : true. The SPS is faster when it's set to false.
  81762. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  81763. */
  81764. computeParticleTexture: boolean;
  81765. /**
  81766. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  81767. * Default value : false. The SPS is faster when it's set to false.
  81768. * Note : the particle custom vertex positions aren't stored values.
  81769. */
  81770. /**
  81771. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  81772. * Default value : false. The SPS is faster when it's set to false.
  81773. * Note : the particle custom vertex positions aren't stored values.
  81774. */
  81775. computeParticleVertex: boolean;
  81776. /**
  81777. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  81778. */
  81779. /**
  81780. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  81781. */
  81782. computeBoundingBox: boolean;
  81783. /**
  81784. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  81785. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  81786. * Default : `true`
  81787. */
  81788. /**
  81789. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  81790. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  81791. * Default : `true`
  81792. */
  81793. depthSortParticles: boolean;
  81794. /**
  81795. * This function does nothing. It may be overwritten to set all the particle first values.
  81796. * The SPS doesn't call this function, you may have to call it by your own.
  81797. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  81798. */
  81799. initParticles(): void;
  81800. /**
  81801. * This function does nothing. It may be overwritten to recycle a particle.
  81802. * The SPS doesn't call this function, you may have to call it by your own.
  81803. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  81804. * @param particle The particle to recycle
  81805. * @returns the recycled particle
  81806. */
  81807. recycleParticle(particle: SolidParticle): SolidParticle;
  81808. /**
  81809. * Updates a particle : this function should be overwritten by the user.
  81810. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  81811. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  81812. * @example : just set a particle position or velocity and recycle conditions
  81813. * @param particle The particle to update
  81814. * @returns the updated particle
  81815. */
  81816. updateParticle(particle: SolidParticle): SolidParticle;
  81817. /**
  81818. * Updates a vertex of a particle : it can be overwritten by the user.
  81819. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  81820. * @param particle the current particle
  81821. * @param vertex the current index of the current particle
  81822. * @param pt the index of the current vertex in the particle shape
  81823. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  81824. * @example : just set a vertex particle position
  81825. * @returns the updated vertex
  81826. */
  81827. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  81828. /**
  81829. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  81830. * This does nothing and may be overwritten by the user.
  81831. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  81832. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  81833. * @param update the boolean update value actually passed to setParticles()
  81834. */
  81835. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  81836. /**
  81837. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  81838. * This will be passed three parameters.
  81839. * This does nothing and may be overwritten by the user.
  81840. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  81841. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  81842. * @param update the boolean update value actually passed to setParticles()
  81843. */
  81844. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  81845. }
  81846. }
  81847. declare module BABYLON {
  81848. /**
  81849. * Represents one particle of a solid particle system.
  81850. */
  81851. export class SolidParticle {
  81852. /**
  81853. * particle global index
  81854. */
  81855. idx: number;
  81856. /**
  81857. * The color of the particle
  81858. */
  81859. color: Nullable<Color4>;
  81860. /**
  81861. * The world space position of the particle.
  81862. */
  81863. position: Vector3;
  81864. /**
  81865. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  81866. */
  81867. rotation: Vector3;
  81868. /**
  81869. * The world space rotation quaternion of the particle.
  81870. */
  81871. rotationQuaternion: Nullable<Quaternion>;
  81872. /**
  81873. * The scaling of the particle.
  81874. */
  81875. scaling: Vector3;
  81876. /**
  81877. * The uvs of the particle.
  81878. */
  81879. uvs: Vector4;
  81880. /**
  81881. * The current speed of the particle.
  81882. */
  81883. velocity: Vector3;
  81884. /**
  81885. * The pivot point in the particle local space.
  81886. */
  81887. pivot: Vector3;
  81888. /**
  81889. * Must the particle be translated from its pivot point in its local space ?
  81890. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  81891. * Default : false
  81892. */
  81893. translateFromPivot: boolean;
  81894. /**
  81895. * Is the particle active or not ?
  81896. */
  81897. alive: boolean;
  81898. /**
  81899. * Is the particle visible or not ?
  81900. */
  81901. isVisible: boolean;
  81902. /**
  81903. * Index of this particle in the global "positions" array (Internal use)
  81904. * @hidden
  81905. */
  81906. _pos: number;
  81907. /**
  81908. * @hidden Index of this particle in the global "indices" array (Internal use)
  81909. */
  81910. _ind: number;
  81911. /**
  81912. * @hidden ModelShape of this particle (Internal use)
  81913. */
  81914. _model: ModelShape;
  81915. /**
  81916. * ModelShape id of this particle
  81917. */
  81918. shapeId: number;
  81919. /**
  81920. * Index of the particle in its shape id (Internal use)
  81921. */
  81922. idxInShape: number;
  81923. /**
  81924. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  81925. */
  81926. _modelBoundingInfo: BoundingInfo;
  81927. /**
  81928. * @hidden Particle BoundingInfo object (Internal use)
  81929. */
  81930. _boundingInfo: BoundingInfo;
  81931. /**
  81932. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  81933. */
  81934. _sps: SolidParticleSystem;
  81935. /**
  81936. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  81937. */
  81938. _stillInvisible: boolean;
  81939. /**
  81940. * @hidden Last computed particle rotation matrix
  81941. */
  81942. _rotationMatrix: number[];
  81943. /**
  81944. * Parent particle Id, if any.
  81945. * Default null.
  81946. */
  81947. parentId: Nullable<number>;
  81948. /**
  81949. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  81950. * The possible values are :
  81951. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  81952. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  81953. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  81954. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  81955. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  81956. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  81957. * */
  81958. cullingStrategy: number;
  81959. /**
  81960. * @hidden Internal global position in the SPS.
  81961. */
  81962. _globalPosition: Vector3;
  81963. /**
  81964. * Creates a Solid Particle object.
  81965. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  81966. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  81967. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  81968. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  81969. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  81970. * @param shapeId (integer) is the model shape identifier in the SPS.
  81971. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  81972. * @param sps defines the sps it is associated to
  81973. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  81974. */
  81975. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  81976. /**
  81977. * Legacy support, changed scale to scaling
  81978. */
  81979. /**
  81980. * Legacy support, changed scale to scaling
  81981. */
  81982. scale: Vector3;
  81983. /**
  81984. * Legacy support, changed quaternion to rotationQuaternion
  81985. */
  81986. /**
  81987. * Legacy support, changed quaternion to rotationQuaternion
  81988. */
  81989. quaternion: Nullable<Quaternion>;
  81990. /**
  81991. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  81992. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  81993. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  81994. * @returns true if it intersects
  81995. */
  81996. intersectsMesh(target: Mesh | SolidParticle): boolean;
  81997. /**
  81998. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  81999. * A particle is in the frustum if its bounding box intersects the frustum
  82000. * @param frustumPlanes defines the frustum to test
  82001. * @returns true if the particle is in the frustum planes
  82002. */
  82003. isInFrustum(frustumPlanes: Plane[]): boolean;
  82004. /**
  82005. * get the rotation matrix of the particle
  82006. * @hidden
  82007. */
  82008. getRotationMatrix(m: Matrix): void;
  82009. }
  82010. /**
  82011. * Represents the shape of the model used by one particle of a solid particle system.
  82012. * SPS internal tool, don't use it manually.
  82013. */
  82014. export class ModelShape {
  82015. /**
  82016. * The shape id
  82017. * @hidden
  82018. */
  82019. shapeID: number;
  82020. /**
  82021. * flat array of model positions (internal use)
  82022. * @hidden
  82023. */
  82024. _shape: Vector3[];
  82025. /**
  82026. * flat array of model UVs (internal use)
  82027. * @hidden
  82028. */
  82029. _shapeUV: number[];
  82030. /**
  82031. * length of the shape in the model indices array (internal use)
  82032. * @hidden
  82033. */
  82034. _indicesLength: number;
  82035. /**
  82036. * Custom position function (internal use)
  82037. * @hidden
  82038. */
  82039. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  82040. /**
  82041. * Custom vertex function (internal use)
  82042. * @hidden
  82043. */
  82044. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  82045. /**
  82046. * 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.
  82047. * SPS internal tool, don't use it manually.
  82048. * @hidden
  82049. */
  82050. 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>);
  82051. }
  82052. /**
  82053. * Represents a Depth Sorted Particle in the solid particle system.
  82054. */
  82055. export class DepthSortedParticle {
  82056. /**
  82057. * Index of the particle in the "indices" array
  82058. */
  82059. ind: number;
  82060. /**
  82061. * Length of the particle shape in the "indices" array
  82062. */
  82063. indicesLength: number;
  82064. /**
  82065. * Squared distance from the particle to the camera
  82066. */
  82067. sqDistance: number;
  82068. }
  82069. }
  82070. declare module BABYLON {
  82071. /**
  82072. * Class used to store all common mesh properties
  82073. */
  82074. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  82075. /** No occlusion */
  82076. static OCCLUSION_TYPE_NONE: number;
  82077. /** Occlusion set to optimisitic */
  82078. static OCCLUSION_TYPE_OPTIMISTIC: number;
  82079. /** Occlusion set to strict */
  82080. static OCCLUSION_TYPE_STRICT: number;
  82081. /** Use an accurante occlusion algorithm */
  82082. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  82083. /** Use a conservative occlusion algorithm */
  82084. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  82085. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  82086. * Test order :
  82087. * Is the bounding sphere outside the frustum ?
  82088. * If not, are the bounding box vertices outside the frustum ?
  82089. * It not, then the cullable object is in the frustum.
  82090. */
  82091. static readonly CULLINGSTRATEGY_STANDARD: number;
  82092. /** Culling strategy : Bounding Sphere Only.
  82093. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  82094. * It's also less accurate than the standard because some not visible objects can still be selected.
  82095. * Test : is the bounding sphere outside the frustum ?
  82096. * If not, then the cullable object is in the frustum.
  82097. */
  82098. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  82099. /** Culling strategy : Optimistic Inclusion.
  82100. * This in an inclusion test first, then the standard exclusion test.
  82101. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  82102. * 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.
  82103. * Anyway, it's as accurate as the standard strategy.
  82104. * Test :
  82105. * Is the cullable object bounding sphere center in the frustum ?
  82106. * If not, apply the default culling strategy.
  82107. */
  82108. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  82109. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  82110. * This in an inclusion test first, then the bounding sphere only exclusion test.
  82111. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  82112. * 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.
  82113. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  82114. * Test :
  82115. * Is the cullable object bounding sphere center in the frustum ?
  82116. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  82117. */
  82118. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  82119. /**
  82120. * No billboard
  82121. */
  82122. static readonly BILLBOARDMODE_NONE: number;
  82123. /** Billboard on X axis */
  82124. static readonly BILLBOARDMODE_X: number;
  82125. /** Billboard on Y axis */
  82126. static readonly BILLBOARDMODE_Y: number;
  82127. /** Billboard on Z axis */
  82128. static readonly BILLBOARDMODE_Z: number;
  82129. /** Billboard on all axes */
  82130. static readonly BILLBOARDMODE_ALL: number;
  82131. private _facetData;
  82132. /**
  82133. * The culling strategy to use to check whether the mesh must be rendered or not.
  82134. * This value can be changed at any time and will be used on the next render mesh selection.
  82135. * The possible values are :
  82136. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  82137. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  82138. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  82139. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  82140. * Please read each static variable documentation to get details about the culling process.
  82141. * */
  82142. cullingStrategy: number;
  82143. /**
  82144. * Gets the number of facets in the mesh
  82145. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  82146. */
  82147. readonly facetNb: number;
  82148. /**
  82149. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  82150. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  82151. */
  82152. partitioningSubdivisions: number;
  82153. /**
  82154. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  82155. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  82156. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  82157. */
  82158. partitioningBBoxRatio: number;
  82159. /**
  82160. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  82161. * Works only for updatable meshes.
  82162. * Doesn't work with multi-materials
  82163. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  82164. */
  82165. mustDepthSortFacets: boolean;
  82166. /**
  82167. * The location (Vector3) where the facet depth sort must be computed from.
  82168. * By default, the active camera position.
  82169. * Used only when facet depth sort is enabled
  82170. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  82171. */
  82172. facetDepthSortFrom: Vector3;
  82173. /**
  82174. * gets a boolean indicating if facetData is enabled
  82175. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  82176. */
  82177. readonly isFacetDataEnabled: boolean;
  82178. /** @hidden */
  82179. _updateNonUniformScalingState(value: boolean): boolean;
  82180. /**
  82181. * An event triggered when this mesh collides with another one
  82182. */
  82183. onCollideObservable: Observable<AbstractMesh>;
  82184. private _onCollideObserver;
  82185. /** Set a function to call when this mesh collides with another one */
  82186. onCollide: () => void;
  82187. /**
  82188. * An event triggered when the collision's position changes
  82189. */
  82190. onCollisionPositionChangeObservable: Observable<Vector3>;
  82191. private _onCollisionPositionChangeObserver;
  82192. /** Set a function to call when the collision's position changes */
  82193. onCollisionPositionChange: () => void;
  82194. /**
  82195. * An event triggered when material is changed
  82196. */
  82197. onMaterialChangedObservable: Observable<AbstractMesh>;
  82198. /**
  82199. * Gets or sets the orientation for POV movement & rotation
  82200. */
  82201. definedFacingForward: boolean;
  82202. /** @hidden */
  82203. _occlusionQuery: Nullable<WebGLQuery>;
  82204. private _visibility;
  82205. /**
  82206. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  82207. */
  82208. /**
  82209. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  82210. */
  82211. visibility: number;
  82212. /** Gets or sets the alpha index used to sort transparent meshes
  82213. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  82214. */
  82215. alphaIndex: number;
  82216. /**
  82217. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  82218. */
  82219. isVisible: boolean;
  82220. /**
  82221. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  82222. */
  82223. isPickable: boolean;
  82224. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  82225. showSubMeshesBoundingBox: boolean;
  82226. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  82227. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  82228. */
  82229. isBlocker: boolean;
  82230. /**
  82231. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  82232. */
  82233. enablePointerMoveEvents: boolean;
  82234. /**
  82235. * Specifies the rendering group id for this mesh (0 by default)
  82236. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  82237. */
  82238. renderingGroupId: number;
  82239. private _material;
  82240. /** Gets or sets current material */
  82241. material: Nullable<Material>;
  82242. private _receiveShadows;
  82243. /**
  82244. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  82245. * @see http://doc.babylonjs.com/babylon101/shadows
  82246. */
  82247. receiveShadows: boolean;
  82248. /** Defines color to use when rendering outline */
  82249. outlineColor: Color3;
  82250. /** Define width to use when rendering outline */
  82251. outlineWidth: number;
  82252. /** Defines color to use when rendering overlay */
  82253. overlayColor: Color3;
  82254. /** Defines alpha to use when rendering overlay */
  82255. overlayAlpha: number;
  82256. private _hasVertexAlpha;
  82257. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  82258. hasVertexAlpha: boolean;
  82259. private _useVertexColors;
  82260. /** 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) */
  82261. useVertexColors: boolean;
  82262. private _computeBonesUsingShaders;
  82263. /**
  82264. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  82265. */
  82266. computeBonesUsingShaders: boolean;
  82267. private _numBoneInfluencers;
  82268. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  82269. numBoneInfluencers: number;
  82270. private _applyFog;
  82271. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  82272. applyFog: boolean;
  82273. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  82274. useOctreeForRenderingSelection: boolean;
  82275. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  82276. useOctreeForPicking: boolean;
  82277. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  82278. useOctreeForCollisions: boolean;
  82279. private _layerMask;
  82280. /**
  82281. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  82282. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  82283. */
  82284. layerMask: number;
  82285. /**
  82286. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  82287. */
  82288. alwaysSelectAsActiveMesh: boolean;
  82289. /**
  82290. * Gets or sets the current action manager
  82291. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82292. */
  82293. actionManager: Nullable<AbstractActionManager>;
  82294. private _checkCollisions;
  82295. private _collisionMask;
  82296. private _collisionGroup;
  82297. /**
  82298. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  82299. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  82300. */
  82301. ellipsoid: Vector3;
  82302. /**
  82303. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  82304. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  82305. */
  82306. ellipsoidOffset: Vector3;
  82307. private _collider;
  82308. private _oldPositionForCollisions;
  82309. private _diffPositionForCollisions;
  82310. /**
  82311. * Gets or sets a collision mask used to mask collisions (default is -1).
  82312. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  82313. */
  82314. collisionMask: number;
  82315. /**
  82316. * Gets or sets the current collision group mask (-1 by default).
  82317. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  82318. */
  82319. collisionGroup: number;
  82320. /**
  82321. * Defines edge width used when edgesRenderer is enabled
  82322. * @see https://www.babylonjs-playground.com/#10OJSG#13
  82323. */
  82324. edgesWidth: number;
  82325. /**
  82326. * Defines edge color used when edgesRenderer is enabled
  82327. * @see https://www.babylonjs-playground.com/#10OJSG#13
  82328. */
  82329. edgesColor: Color4;
  82330. /** @hidden */
  82331. _edgesRenderer: Nullable<IEdgesRenderer>;
  82332. /** @hidden */
  82333. _masterMesh: Nullable<AbstractMesh>;
  82334. /** @hidden */
  82335. _boundingInfo: Nullable<BoundingInfo>;
  82336. /** @hidden */
  82337. _renderId: number;
  82338. /**
  82339. * Gets or sets the list of subMeshes
  82340. * @see http://doc.babylonjs.com/how_to/multi_materials
  82341. */
  82342. subMeshes: SubMesh[];
  82343. /** @hidden */
  82344. _intersectionsInProgress: AbstractMesh[];
  82345. /** @hidden */
  82346. _unIndexed: boolean;
  82347. /** @hidden */
  82348. _lightSources: Light[];
  82349. /** @hidden */
  82350. readonly _positions: Nullable<Vector3[]>;
  82351. /** @hidden */
  82352. _waitingActions: any;
  82353. /** @hidden */
  82354. _waitingFreezeWorldMatrix: Nullable<boolean>;
  82355. private _skeleton;
  82356. /** @hidden */
  82357. _bonesTransformMatrices: Nullable<Float32Array>;
  82358. /**
  82359. * Gets or sets a skeleton to apply skining transformations
  82360. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  82361. */
  82362. skeleton: Nullable<Skeleton>;
  82363. /**
  82364. * An event triggered when the mesh is rebuilt.
  82365. */
  82366. onRebuildObservable: Observable<AbstractMesh>;
  82367. /**
  82368. * Creates a new AbstractMesh
  82369. * @param name defines the name of the mesh
  82370. * @param scene defines the hosting scene
  82371. */
  82372. constructor(name: string, scene?: Nullable<Scene>);
  82373. /**
  82374. * Returns the string "AbstractMesh"
  82375. * @returns "AbstractMesh"
  82376. */
  82377. getClassName(): string;
  82378. /**
  82379. * Gets a string representation of the current mesh
  82380. * @param fullDetails defines a boolean indicating if full details must be included
  82381. * @returns a string representation of the current mesh
  82382. */
  82383. toString(fullDetails?: boolean): string;
  82384. /** @hidden */
  82385. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  82386. /** @hidden */
  82387. _rebuild(): void;
  82388. /** @hidden */
  82389. _resyncLightSources(): void;
  82390. /** @hidden */
  82391. _resyncLighSource(light: Light): void;
  82392. /** @hidden */
  82393. _unBindEffect(): void;
  82394. /** @hidden */
  82395. _removeLightSource(light: Light): void;
  82396. private _markSubMeshesAsDirty;
  82397. /** @hidden */
  82398. _markSubMeshesAsLightDirty(): void;
  82399. /** @hidden */
  82400. _markSubMeshesAsAttributesDirty(): void;
  82401. /** @hidden */
  82402. _markSubMeshesAsMiscDirty(): void;
  82403. /**
  82404. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  82405. */
  82406. scaling: Vector3;
  82407. /**
  82408. * Returns true if the mesh is blocked. Implemented by child classes
  82409. */
  82410. readonly isBlocked: boolean;
  82411. /**
  82412. * Returns the mesh itself by default. Implemented by child classes
  82413. * @param camera defines the camera to use to pick the right LOD level
  82414. * @returns the currentAbstractMesh
  82415. */
  82416. getLOD(camera: Camera): Nullable<AbstractMesh>;
  82417. /**
  82418. * Returns 0 by default. Implemented by child classes
  82419. * @returns an integer
  82420. */
  82421. getTotalVertices(): number;
  82422. /**
  82423. * Returns a positive integer : the total number of indices in this mesh geometry.
  82424. * @returns the numner of indices or zero if the mesh has no geometry.
  82425. */
  82426. getTotalIndices(): number;
  82427. /**
  82428. * Returns null by default. Implemented by child classes
  82429. * @returns null
  82430. */
  82431. getIndices(): Nullable<IndicesArray>;
  82432. /**
  82433. * Returns the array of the requested vertex data kind. Implemented by child classes
  82434. * @param kind defines the vertex data kind to use
  82435. * @returns null
  82436. */
  82437. getVerticesData(kind: string): Nullable<FloatArray>;
  82438. /**
  82439. * Sets the vertex data of the mesh geometry for the requested `kind`.
  82440. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  82441. * Note that a new underlying VertexBuffer object is created each call.
  82442. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  82443. * @param kind defines vertex data kind:
  82444. * * VertexBuffer.PositionKind
  82445. * * VertexBuffer.UVKind
  82446. * * VertexBuffer.UV2Kind
  82447. * * VertexBuffer.UV3Kind
  82448. * * VertexBuffer.UV4Kind
  82449. * * VertexBuffer.UV5Kind
  82450. * * VertexBuffer.UV6Kind
  82451. * * VertexBuffer.ColorKind
  82452. * * VertexBuffer.MatricesIndicesKind
  82453. * * VertexBuffer.MatricesIndicesExtraKind
  82454. * * VertexBuffer.MatricesWeightsKind
  82455. * * VertexBuffer.MatricesWeightsExtraKind
  82456. * @param data defines the data source
  82457. * @param updatable defines if the data must be flagged as updatable (or static)
  82458. * @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
  82459. * @returns the current mesh
  82460. */
  82461. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  82462. /**
  82463. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  82464. * If the mesh has no geometry, it is simply returned as it is.
  82465. * @param kind defines vertex data kind:
  82466. * * VertexBuffer.PositionKind
  82467. * * VertexBuffer.UVKind
  82468. * * VertexBuffer.UV2Kind
  82469. * * VertexBuffer.UV3Kind
  82470. * * VertexBuffer.UV4Kind
  82471. * * VertexBuffer.UV5Kind
  82472. * * VertexBuffer.UV6Kind
  82473. * * VertexBuffer.ColorKind
  82474. * * VertexBuffer.MatricesIndicesKind
  82475. * * VertexBuffer.MatricesIndicesExtraKind
  82476. * * VertexBuffer.MatricesWeightsKind
  82477. * * VertexBuffer.MatricesWeightsExtraKind
  82478. * @param data defines the data source
  82479. * @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
  82480. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  82481. * @returns the current mesh
  82482. */
  82483. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  82484. /**
  82485. * Sets the mesh indices,
  82486. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  82487. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  82488. * @param totalVertices Defines the total number of vertices
  82489. * @returns the current mesh
  82490. */
  82491. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  82492. /**
  82493. * Gets a boolean indicating if specific vertex data is present
  82494. * @param kind defines the vertex data kind to use
  82495. * @returns true is data kind is present
  82496. */
  82497. isVerticesDataPresent(kind: string): boolean;
  82498. /**
  82499. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  82500. * @returns a BoundingInfo
  82501. */
  82502. getBoundingInfo(): BoundingInfo;
  82503. /**
  82504. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  82505. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  82506. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  82507. * @returns the current mesh
  82508. */
  82509. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  82510. /**
  82511. * Overwrite the current bounding info
  82512. * @param boundingInfo defines the new bounding info
  82513. * @returns the current mesh
  82514. */
  82515. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  82516. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  82517. readonly useBones: boolean;
  82518. /** @hidden */
  82519. _preActivate(): void;
  82520. /** @hidden */
  82521. _preActivateForIntermediateRendering(renderId: number): void;
  82522. /** @hidden */
  82523. _activate(renderId: number): void;
  82524. /**
  82525. * Gets the current world matrix
  82526. * @returns a Matrix
  82527. */
  82528. getWorldMatrix(): Matrix;
  82529. /** @hidden */
  82530. _getWorldMatrixDeterminant(): number;
  82531. /**
  82532. * Perform relative position change from the point of view of behind the front of the mesh.
  82533. * This is performed taking into account the meshes current rotation, so you do not have to care.
  82534. * Supports definition of mesh facing forward or backward
  82535. * @param amountRight defines the distance on the right axis
  82536. * @param amountUp defines the distance on the up axis
  82537. * @param amountForward defines the distance on the forward axis
  82538. * @returns the current mesh
  82539. */
  82540. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  82541. /**
  82542. * Calculate relative position change from the point of view of behind the front of the mesh.
  82543. * This is performed taking into account the meshes current rotation, so you do not have to care.
  82544. * Supports definition of mesh facing forward or backward
  82545. * @param amountRight defines the distance on the right axis
  82546. * @param amountUp defines the distance on the up axis
  82547. * @param amountForward defines the distance on the forward axis
  82548. * @returns the new displacement vector
  82549. */
  82550. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  82551. /**
  82552. * Perform relative rotation change from the point of view of behind the front of the mesh.
  82553. * Supports definition of mesh facing forward or backward
  82554. * @param flipBack defines the flip
  82555. * @param twirlClockwise defines the twirl
  82556. * @param tiltRight defines the tilt
  82557. * @returns the current mesh
  82558. */
  82559. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  82560. /**
  82561. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  82562. * Supports definition of mesh facing forward or backward.
  82563. * @param flipBack defines the flip
  82564. * @param twirlClockwise defines the twirl
  82565. * @param tiltRight defines the tilt
  82566. * @returns the new rotation vector
  82567. */
  82568. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  82569. /**
  82570. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  82571. * @param includeDescendants Include bounding info from descendants as well (true by default)
  82572. * @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
  82573. * @returns the new bounding vectors
  82574. */
  82575. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  82576. min: Vector3;
  82577. max: Vector3;
  82578. };
  82579. /**
  82580. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  82581. * This means the mesh underlying bounding box and sphere are recomputed.
  82582. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  82583. * @returns the current mesh
  82584. */
  82585. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  82586. /** @hidden */
  82587. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  82588. /** @hidden */
  82589. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  82590. /** @hidden */
  82591. _updateBoundingInfo(): AbstractMesh;
  82592. /** @hidden */
  82593. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  82594. /** @hidden */
  82595. protected _afterComputeWorldMatrix(): void;
  82596. /**
  82597. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  82598. * A mesh is in the frustum if its bounding box intersects the frustum
  82599. * @param frustumPlanes defines the frustum to test
  82600. * @returns true if the mesh is in the frustum planes
  82601. */
  82602. isInFrustum(frustumPlanes: Plane[]): boolean;
  82603. /**
  82604. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  82605. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  82606. * @param frustumPlanes defines the frustum to test
  82607. * @returns true if the mesh is completely in the frustum planes
  82608. */
  82609. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  82610. /**
  82611. * True if the mesh intersects another mesh or a SolidParticle object
  82612. * @param mesh defines a target mesh or SolidParticle to test
  82613. * @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)
  82614. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  82615. * @returns true if there is an intersection
  82616. */
  82617. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  82618. /**
  82619. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  82620. * @param point defines the point to test
  82621. * @returns true if there is an intersection
  82622. */
  82623. intersectsPoint(point: Vector3): boolean;
  82624. /**
  82625. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  82626. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  82627. */
  82628. checkCollisions: boolean;
  82629. /**
  82630. * Gets Collider object used to compute collisions (not physics)
  82631. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  82632. */
  82633. readonly collider: Collider;
  82634. /**
  82635. * Move the mesh using collision engine
  82636. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  82637. * @param displacement defines the requested displacement vector
  82638. * @returns the current mesh
  82639. */
  82640. moveWithCollisions(displacement: Vector3): AbstractMesh;
  82641. private _onCollisionPositionChange;
  82642. /** @hidden */
  82643. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  82644. /** @hidden */
  82645. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  82646. /** @hidden */
  82647. _checkCollision(collider: Collider): AbstractMesh;
  82648. /** @hidden */
  82649. _generatePointsArray(): boolean;
  82650. /**
  82651. * Checks if the passed Ray intersects with the mesh
  82652. * @param ray defines the ray to use
  82653. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  82654. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  82655. * @returns the picking info
  82656. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  82657. */
  82658. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  82659. /**
  82660. * Clones the current mesh
  82661. * @param name defines the mesh name
  82662. * @param newParent defines the new mesh parent
  82663. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  82664. * @returns the new mesh
  82665. */
  82666. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  82667. /**
  82668. * Disposes all the submeshes of the current meshnp
  82669. * @returns the current mesh
  82670. */
  82671. releaseSubMeshes(): AbstractMesh;
  82672. /**
  82673. * Releases resources associated with this abstract mesh.
  82674. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  82675. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  82676. */
  82677. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  82678. /**
  82679. * Adds the passed mesh as a child to the current mesh
  82680. * @param mesh defines the child mesh
  82681. * @returns the current mesh
  82682. */
  82683. addChild(mesh: AbstractMesh): AbstractMesh;
  82684. /**
  82685. * Removes the passed mesh from the current mesh children list
  82686. * @param mesh defines the child mesh
  82687. * @returns the current mesh
  82688. */
  82689. removeChild(mesh: AbstractMesh): AbstractMesh;
  82690. /** @hidden */
  82691. private _initFacetData;
  82692. /**
  82693. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  82694. * This method can be called within the render loop.
  82695. * 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
  82696. * @returns the current mesh
  82697. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82698. */
  82699. updateFacetData(): AbstractMesh;
  82700. /**
  82701. * Returns the facetLocalNormals array.
  82702. * The normals are expressed in the mesh local spac
  82703. * @returns an array of Vector3
  82704. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82705. */
  82706. getFacetLocalNormals(): Vector3[];
  82707. /**
  82708. * Returns the facetLocalPositions array.
  82709. * The facet positions are expressed in the mesh local space
  82710. * @returns an array of Vector3
  82711. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82712. */
  82713. getFacetLocalPositions(): Vector3[];
  82714. /**
  82715. * Returns the facetLocalPartioning array
  82716. * @returns an array of array of numbers
  82717. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82718. */
  82719. getFacetLocalPartitioning(): number[][];
  82720. /**
  82721. * Returns the i-th facet position in the world system.
  82722. * This method allocates a new Vector3 per call
  82723. * @param i defines the facet index
  82724. * @returns a new Vector3
  82725. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82726. */
  82727. getFacetPosition(i: number): Vector3;
  82728. /**
  82729. * Sets the reference Vector3 with the i-th facet position in the world system
  82730. * @param i defines the facet index
  82731. * @param ref defines the target vector
  82732. * @returns the current mesh
  82733. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82734. */
  82735. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  82736. /**
  82737. * Returns the i-th facet normal in the world system.
  82738. * This method allocates a new Vector3 per call
  82739. * @param i defines the facet index
  82740. * @returns a new Vector3
  82741. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82742. */
  82743. getFacetNormal(i: number): Vector3;
  82744. /**
  82745. * Sets the reference Vector3 with the i-th facet normal in the world system
  82746. * @param i defines the facet index
  82747. * @param ref defines the target vector
  82748. * @returns the current mesh
  82749. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82750. */
  82751. getFacetNormalToRef(i: number, ref: Vector3): this;
  82752. /**
  82753. * 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)
  82754. * @param x defines x coordinate
  82755. * @param y defines y coordinate
  82756. * @param z defines z coordinate
  82757. * @returns the array of facet indexes
  82758. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82759. */
  82760. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  82761. /**
  82762. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  82763. * @param projected sets as the (x,y,z) world projection on the facet
  82764. * @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
  82765. * @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
  82766. * @param x defines x coordinate
  82767. * @param y defines y coordinate
  82768. * @param z defines z coordinate
  82769. * @returns the face index if found (or null instead)
  82770. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82771. */
  82772. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  82773. /**
  82774. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  82775. * @param projected sets as the (x,y,z) local projection on the facet
  82776. * @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
  82777. * @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
  82778. * @param x defines x coordinate
  82779. * @param y defines y coordinate
  82780. * @param z defines z coordinate
  82781. * @returns the face index if found (or null instead)
  82782. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82783. */
  82784. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  82785. /**
  82786. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  82787. * @returns the parameters
  82788. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82789. */
  82790. getFacetDataParameters(): any;
  82791. /**
  82792. * Disables the feature FacetData and frees the related memory
  82793. * @returns the current mesh
  82794. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82795. */
  82796. disableFacetData(): AbstractMesh;
  82797. /**
  82798. * Updates the AbstractMesh indices array
  82799. * @param indices defines the data source
  82800. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  82801. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  82802. * @returns the current mesh
  82803. */
  82804. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  82805. /**
  82806. * Creates new normals data for the mesh
  82807. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  82808. * @returns the current mesh
  82809. */
  82810. createNormals(updatable: boolean): AbstractMesh;
  82811. /**
  82812. * Align the mesh with a normal
  82813. * @param normal defines the normal to use
  82814. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  82815. * @returns the current mesh
  82816. */
  82817. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  82818. /** @hidden */
  82819. _checkOcclusionQuery(): boolean;
  82820. }
  82821. }
  82822. declare module BABYLON {
  82823. /**
  82824. * Interface used to define ActionEvent
  82825. */
  82826. export interface IActionEvent {
  82827. /** The mesh or sprite that triggered the action */
  82828. source: any;
  82829. /** The X mouse cursor position at the time of the event */
  82830. pointerX: number;
  82831. /** The Y mouse cursor position at the time of the event */
  82832. pointerY: number;
  82833. /** The mesh that is currently pointed at (can be null) */
  82834. meshUnderPointer: Nullable<AbstractMesh>;
  82835. /** the original (browser) event that triggered the ActionEvent */
  82836. sourceEvent?: any;
  82837. /** additional data for the event */
  82838. additionalData?: any;
  82839. }
  82840. /**
  82841. * ActionEvent is the event being sent when an action is triggered.
  82842. */
  82843. export class ActionEvent implements IActionEvent {
  82844. /** The mesh or sprite that triggered the action */
  82845. source: any;
  82846. /** The X mouse cursor position at the time of the event */
  82847. pointerX: number;
  82848. /** The Y mouse cursor position at the time of the event */
  82849. pointerY: number;
  82850. /** The mesh that is currently pointed at (can be null) */
  82851. meshUnderPointer: Nullable<AbstractMesh>;
  82852. /** the original (browser) event that triggered the ActionEvent */
  82853. sourceEvent?: any;
  82854. /** additional data for the event */
  82855. additionalData?: any;
  82856. /**
  82857. * Creates a new ActionEvent
  82858. * @param source The mesh or sprite that triggered the action
  82859. * @param pointerX The X mouse cursor position at the time of the event
  82860. * @param pointerY The Y mouse cursor position at the time of the event
  82861. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  82862. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  82863. * @param additionalData additional data for the event
  82864. */
  82865. constructor(
  82866. /** The mesh or sprite that triggered the action */
  82867. source: any,
  82868. /** The X mouse cursor position at the time of the event */
  82869. pointerX: number,
  82870. /** The Y mouse cursor position at the time of the event */
  82871. pointerY: number,
  82872. /** The mesh that is currently pointed at (can be null) */
  82873. meshUnderPointer: Nullable<AbstractMesh>,
  82874. /** the original (browser) event that triggered the ActionEvent */
  82875. sourceEvent?: any,
  82876. /** additional data for the event */
  82877. additionalData?: any);
  82878. /**
  82879. * Helper function to auto-create an ActionEvent from a source mesh.
  82880. * @param source The source mesh that triggered the event
  82881. * @param evt The original (browser) event
  82882. * @param additionalData additional data for the event
  82883. * @returns the new ActionEvent
  82884. */
  82885. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  82886. /**
  82887. * Helper function to auto-create an ActionEvent from a source sprite
  82888. * @param source The source sprite that triggered the event
  82889. * @param scene Scene associated with the sprite
  82890. * @param evt The original (browser) event
  82891. * @param additionalData additional data for the event
  82892. * @returns the new ActionEvent
  82893. */
  82894. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  82895. /**
  82896. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  82897. * @param scene the scene where the event occurred
  82898. * @param evt The original (browser) event
  82899. * @returns the new ActionEvent
  82900. */
  82901. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  82902. /**
  82903. * Helper function to auto-create an ActionEvent from a primitive
  82904. * @param prim defines the target primitive
  82905. * @param pointerPos defines the pointer position
  82906. * @param evt The original (browser) event
  82907. * @param additionalData additional data for the event
  82908. * @returns the new ActionEvent
  82909. */
  82910. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  82911. }
  82912. }
  82913. declare module BABYLON {
  82914. /**
  82915. * Abstract class used to decouple action Manager from scene and meshes.
  82916. * Do not instantiate.
  82917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82918. */
  82919. export abstract class AbstractActionManager implements IDisposable {
  82920. /** Gets the list of active triggers */
  82921. static Triggers: {
  82922. [key: string]: number;
  82923. };
  82924. /** Gets the cursor to use when hovering items */
  82925. hoverCursor: string;
  82926. /** Gets the list of actions */
  82927. actions: IAction[];
  82928. /**
  82929. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  82930. */
  82931. isRecursive: boolean;
  82932. /**
  82933. * Releases all associated resources
  82934. */
  82935. abstract dispose(): void;
  82936. /**
  82937. * Does this action manager has pointer triggers
  82938. */
  82939. abstract readonly hasPointerTriggers: boolean;
  82940. /**
  82941. * Does this action manager has pick triggers
  82942. */
  82943. abstract readonly hasPickTriggers: boolean;
  82944. /**
  82945. * Process a specific trigger
  82946. * @param trigger defines the trigger to process
  82947. * @param evt defines the event details to be processed
  82948. */
  82949. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  82950. /**
  82951. * Does this action manager handles actions of any of the given triggers
  82952. * @param triggers defines the triggers to be tested
  82953. * @return a boolean indicating whether one (or more) of the triggers is handled
  82954. */
  82955. abstract hasSpecificTriggers(triggers: number[]): boolean;
  82956. /**
  82957. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  82958. * speed.
  82959. * @param triggerA defines the trigger to be tested
  82960. * @param triggerB defines the trigger to be tested
  82961. * @return a boolean indicating whether one (or more) of the triggers is handled
  82962. */
  82963. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  82964. /**
  82965. * Does this action manager handles actions of a given trigger
  82966. * @param trigger defines the trigger to be tested
  82967. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  82968. * @return whether the trigger is handled
  82969. */
  82970. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  82971. /**
  82972. * Serialize this manager to a JSON object
  82973. * @param name defines the property name to store this manager
  82974. * @returns a JSON representation of this manager
  82975. */
  82976. abstract serialize(name: string): any;
  82977. /**
  82978. * Registers an action to this action manager
  82979. * @param action defines the action to be registered
  82980. * @return the action amended (prepared) after registration
  82981. */
  82982. abstract registerAction(action: IAction): Nullable<IAction>;
  82983. /**
  82984. * Unregisters an action to this action manager
  82985. * @param action defines the action to be unregistered
  82986. * @return a boolean indicating whether the action has been unregistered
  82987. */
  82988. abstract unregisterAction(action: IAction): Boolean;
  82989. /**
  82990. * Does exist one action manager with at least one trigger
  82991. **/
  82992. static readonly HasTriggers: boolean;
  82993. /**
  82994. * Does exist one action manager with at least one pick trigger
  82995. **/
  82996. static readonly HasPickTriggers: boolean;
  82997. /**
  82998. * Does exist one action manager that handles actions of a given trigger
  82999. * @param trigger defines the trigger to be tested
  83000. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  83001. **/
  83002. static HasSpecificTrigger(trigger: number): boolean;
  83003. }
  83004. }
  83005. declare module BABYLON {
  83006. /**
  83007. * Defines how a node can be built from a string name.
  83008. */
  83009. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  83010. /**
  83011. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  83012. */
  83013. export class Node implements IBehaviorAware<Node> {
  83014. /** @hidden */
  83015. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  83016. private static _NodeConstructors;
  83017. /**
  83018. * Add a new node constructor
  83019. * @param type defines the type name of the node to construct
  83020. * @param constructorFunc defines the constructor function
  83021. */
  83022. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  83023. /**
  83024. * Returns a node constructor based on type name
  83025. * @param type defines the type name
  83026. * @param name defines the new node name
  83027. * @param scene defines the hosting scene
  83028. * @param options defines optional options to transmit to constructors
  83029. * @returns the new constructor or null
  83030. */
  83031. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  83032. /**
  83033. * Gets or sets the name of the node
  83034. */
  83035. name: string;
  83036. /**
  83037. * Gets or sets the id of the node
  83038. */
  83039. id: string;
  83040. /**
  83041. * Gets or sets the unique id of the node
  83042. */
  83043. uniqueId: number;
  83044. /**
  83045. * Gets or sets a string used to store user defined state for the node
  83046. */
  83047. state: string;
  83048. /**
  83049. * Gets or sets an object used to store user defined information for the node
  83050. */
  83051. metadata: any;
  83052. /**
  83053. * For internal use only. Please do not use.
  83054. */
  83055. reservedDataStore: any;
  83056. /**
  83057. * List of inspectable custom properties (used by the Inspector)
  83058. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  83059. */
  83060. inspectableCustomProperties: IInspectable[];
  83061. /**
  83062. * Gets or sets a boolean used to define if the node must be serialized
  83063. */
  83064. doNotSerialize: boolean;
  83065. /** @hidden */
  83066. _isDisposed: boolean;
  83067. /**
  83068. * Gets a list of Animations associated with the node
  83069. */
  83070. animations: Animation[];
  83071. protected _ranges: {
  83072. [name: string]: Nullable<AnimationRange>;
  83073. };
  83074. /**
  83075. * Callback raised when the node is ready to be used
  83076. */
  83077. onReady: (node: Node) => void;
  83078. private _isEnabled;
  83079. private _isParentEnabled;
  83080. private _isReady;
  83081. /** @hidden */
  83082. _currentRenderId: number;
  83083. private _parentRenderId;
  83084. protected _childRenderId: number;
  83085. /** @hidden */
  83086. _waitingParentId: Nullable<string>;
  83087. /** @hidden */
  83088. _scene: Scene;
  83089. /** @hidden */
  83090. _cache: any;
  83091. private _parentNode;
  83092. private _children;
  83093. /** @hidden */
  83094. _worldMatrix: Matrix;
  83095. /** @hidden */
  83096. _worldMatrixDeterminant: number;
  83097. /** @hidden */
  83098. private _sceneRootNodesIndex;
  83099. /**
  83100. * Gets a boolean indicating if the node has been disposed
  83101. * @returns true if the node was disposed
  83102. */
  83103. isDisposed(): boolean;
  83104. /**
  83105. * Gets or sets the parent of the node (without keeping the current position in the scene)
  83106. * @see https://doc.babylonjs.com/how_to/parenting
  83107. */
  83108. parent: Nullable<Node>;
  83109. private addToSceneRootNodes;
  83110. private removeFromSceneRootNodes;
  83111. private _animationPropertiesOverride;
  83112. /**
  83113. * Gets or sets the animation properties override
  83114. */
  83115. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  83116. /**
  83117. * Gets a string idenfifying the name of the class
  83118. * @returns "Node" string
  83119. */
  83120. getClassName(): string;
  83121. /** @hidden */
  83122. readonly _isNode: boolean;
  83123. /**
  83124. * An event triggered when the mesh is disposed
  83125. */
  83126. onDisposeObservable: Observable<Node>;
  83127. private _onDisposeObserver;
  83128. /**
  83129. * Sets a callback that will be raised when the node will be disposed
  83130. */
  83131. onDispose: () => void;
  83132. /**
  83133. * Creates a new Node
  83134. * @param name the name and id to be given to this node
  83135. * @param scene the scene this node will be added to
  83136. * @param addToRootNodes the node will be added to scene.rootNodes
  83137. */
  83138. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  83139. /**
  83140. * Gets the scene of the node
  83141. * @returns a scene
  83142. */
  83143. getScene(): Scene;
  83144. /**
  83145. * Gets the engine of the node
  83146. * @returns a Engine
  83147. */
  83148. getEngine(): Engine;
  83149. private _behaviors;
  83150. /**
  83151. * Attach a behavior to the node
  83152. * @see http://doc.babylonjs.com/features/behaviour
  83153. * @param behavior defines the behavior to attach
  83154. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  83155. * @returns the current Node
  83156. */
  83157. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  83158. /**
  83159. * Remove an attached behavior
  83160. * @see http://doc.babylonjs.com/features/behaviour
  83161. * @param behavior defines the behavior to attach
  83162. * @returns the current Node
  83163. */
  83164. removeBehavior(behavior: Behavior<Node>): Node;
  83165. /**
  83166. * Gets the list of attached behaviors
  83167. * @see http://doc.babylonjs.com/features/behaviour
  83168. */
  83169. readonly behaviors: Behavior<Node>[];
  83170. /**
  83171. * Gets an attached behavior by name
  83172. * @param name defines the name of the behavior to look for
  83173. * @see http://doc.babylonjs.com/features/behaviour
  83174. * @returns null if behavior was not found else the requested behavior
  83175. */
  83176. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  83177. /**
  83178. * Returns the latest update of the World matrix
  83179. * @returns a Matrix
  83180. */
  83181. getWorldMatrix(): Matrix;
  83182. /** @hidden */
  83183. _getWorldMatrixDeterminant(): number;
  83184. /**
  83185. * Returns directly the latest state of the mesh World matrix.
  83186. * A Matrix is returned.
  83187. */
  83188. readonly worldMatrixFromCache: Matrix;
  83189. /** @hidden */
  83190. _initCache(): void;
  83191. /** @hidden */
  83192. updateCache(force?: boolean): void;
  83193. /** @hidden */
  83194. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  83195. /** @hidden */
  83196. _updateCache(ignoreParentClass?: boolean): void;
  83197. /** @hidden */
  83198. _isSynchronized(): boolean;
  83199. /** @hidden */
  83200. _markSyncedWithParent(): void;
  83201. /** @hidden */
  83202. isSynchronizedWithParent(): boolean;
  83203. /** @hidden */
  83204. isSynchronized(): boolean;
  83205. /**
  83206. * Is this node ready to be used/rendered
  83207. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  83208. * @return true if the node is ready
  83209. */
  83210. isReady(completeCheck?: boolean): boolean;
  83211. /**
  83212. * Is this node enabled?
  83213. * 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
  83214. * @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
  83215. * @return whether this node (and its parent) is enabled
  83216. */
  83217. isEnabled(checkAncestors?: boolean): boolean;
  83218. /** @hidden */
  83219. protected _syncParentEnabledState(): void;
  83220. /**
  83221. * Set the enabled state of this node
  83222. * @param value defines the new enabled state
  83223. */
  83224. setEnabled(value: boolean): void;
  83225. /**
  83226. * Is this node a descendant of the given node?
  83227. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  83228. * @param ancestor defines the parent node to inspect
  83229. * @returns a boolean indicating if this node is a descendant of the given node
  83230. */
  83231. isDescendantOf(ancestor: Node): boolean;
  83232. /** @hidden */
  83233. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  83234. /**
  83235. * Will return all nodes that have this node as ascendant
  83236. * @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
  83237. * @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
  83238. * @return all children nodes of all types
  83239. */
  83240. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  83241. /**
  83242. * Get all child-meshes of this node
  83243. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: false)
  83244. * @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
  83245. * @returns an array of AbstractMesh
  83246. */
  83247. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  83248. /**
  83249. * Get all direct children of this node
  83250. * @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
  83251. * @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)
  83252. * @returns an array of Node
  83253. */
  83254. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  83255. /** @hidden */
  83256. _setReady(state: boolean): void;
  83257. /**
  83258. * Get an animation by name
  83259. * @param name defines the name of the animation to look for
  83260. * @returns null if not found else the requested animation
  83261. */
  83262. getAnimationByName(name: string): Nullable<Animation>;
  83263. /**
  83264. * Creates an animation range for this node
  83265. * @param name defines the name of the range
  83266. * @param from defines the starting key
  83267. * @param to defines the end key
  83268. */
  83269. createAnimationRange(name: string, from: number, to: number): void;
  83270. /**
  83271. * Delete a specific animation range
  83272. * @param name defines the name of the range to delete
  83273. * @param deleteFrames defines if animation frames from the range must be deleted as well
  83274. */
  83275. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  83276. /**
  83277. * Get an animation range by name
  83278. * @param name defines the name of the animation range to look for
  83279. * @returns null if not found else the requested animation range
  83280. */
  83281. getAnimationRange(name: string): Nullable<AnimationRange>;
  83282. /**
  83283. * Gets the list of all animation ranges defined on this node
  83284. * @returns an array
  83285. */
  83286. getAnimationRanges(): Nullable<AnimationRange>[];
  83287. /**
  83288. * Will start the animation sequence
  83289. * @param name defines the range frames for animation sequence
  83290. * @param loop defines if the animation should loop (false by default)
  83291. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  83292. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  83293. * @returns the object created for this animation. If range does not exist, it will return null
  83294. */
  83295. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  83296. /**
  83297. * Serialize animation ranges into a JSON compatible object
  83298. * @returns serialization object
  83299. */
  83300. serializeAnimationRanges(): any;
  83301. /**
  83302. * Computes the world matrix of the node
  83303. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  83304. * @returns the world matrix
  83305. */
  83306. computeWorldMatrix(force?: boolean): Matrix;
  83307. /**
  83308. * Releases resources associated with this node.
  83309. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  83310. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  83311. */
  83312. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  83313. /**
  83314. * Parse animation range data from a serialization object and store them into a given node
  83315. * @param node defines where to store the animation ranges
  83316. * @param parsedNode defines the serialization object to read data from
  83317. * @param scene defines the hosting scene
  83318. */
  83319. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  83320. }
  83321. }
  83322. declare module BABYLON {
  83323. /**
  83324. * Class used to store any kind of animation
  83325. */
  83326. export class Animation {
  83327. /**Name of the animation */
  83328. name: string;
  83329. /**Property to animate */
  83330. targetProperty: string;
  83331. /**The frames per second of the animation */
  83332. framePerSecond: number;
  83333. /**The data type of the animation */
  83334. dataType: number;
  83335. /**The loop mode of the animation */
  83336. loopMode?: number | undefined;
  83337. /**Specifies if blending should be enabled */
  83338. enableBlending?: boolean | undefined;
  83339. /**
  83340. * Use matrix interpolation instead of using direct key value when animating matrices
  83341. */
  83342. static AllowMatricesInterpolation: boolean;
  83343. /**
  83344. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  83345. */
  83346. static AllowMatrixDecomposeForInterpolation: boolean;
  83347. /**
  83348. * Stores the key frames of the animation
  83349. */
  83350. private _keys;
  83351. /**
  83352. * Stores the easing function of the animation
  83353. */
  83354. private _easingFunction;
  83355. /**
  83356. * @hidden Internal use only
  83357. */
  83358. _runtimeAnimations: RuntimeAnimation[];
  83359. /**
  83360. * The set of event that will be linked to this animation
  83361. */
  83362. private _events;
  83363. /**
  83364. * Stores an array of target property paths
  83365. */
  83366. targetPropertyPath: string[];
  83367. /**
  83368. * Stores the blending speed of the animation
  83369. */
  83370. blendingSpeed: number;
  83371. /**
  83372. * Stores the animation ranges for the animation
  83373. */
  83374. private _ranges;
  83375. /**
  83376. * @hidden Internal use
  83377. */
  83378. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  83379. /**
  83380. * Sets up an animation
  83381. * @param property The property to animate
  83382. * @param animationType The animation type to apply
  83383. * @param framePerSecond The frames per second of the animation
  83384. * @param easingFunction The easing function used in the animation
  83385. * @returns The created animation
  83386. */
  83387. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  83388. /**
  83389. * Create and start an animation on a node
  83390. * @param name defines the name of the global animation that will be run on all nodes
  83391. * @param node defines the root node where the animation will take place
  83392. * @param targetProperty defines property to animate
  83393. * @param framePerSecond defines the number of frame per second yo use
  83394. * @param totalFrame defines the number of frames in total
  83395. * @param from defines the initial value
  83396. * @param to defines the final value
  83397. * @param loopMode defines which loop mode you want to use (off by default)
  83398. * @param easingFunction defines the easing function to use (linear by default)
  83399. * @param onAnimationEnd defines the callback to call when animation end
  83400. * @returns the animatable created for this animation
  83401. */
  83402. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  83403. /**
  83404. * Create and start an animation on a node and its descendants
  83405. * @param name defines the name of the global animation that will be run on all nodes
  83406. * @param node defines the root node where the animation will take place
  83407. * @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
  83408. * @param targetProperty defines property to animate
  83409. * @param framePerSecond defines the number of frame per second to use
  83410. * @param totalFrame defines the number of frames in total
  83411. * @param from defines the initial value
  83412. * @param to defines the final value
  83413. * @param loopMode defines which loop mode you want to use (off by default)
  83414. * @param easingFunction defines the easing function to use (linear by default)
  83415. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  83416. * @returns the list of animatables created for all nodes
  83417. * @example https://www.babylonjs-playground.com/#MH0VLI
  83418. */
  83419. 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[]>;
  83420. /**
  83421. * Creates a new animation, merges it with the existing animations and starts it
  83422. * @param name Name of the animation
  83423. * @param node Node which contains the scene that begins the animations
  83424. * @param targetProperty Specifies which property to animate
  83425. * @param framePerSecond The frames per second of the animation
  83426. * @param totalFrame The total number of frames
  83427. * @param from The frame at the beginning of the animation
  83428. * @param to The frame at the end of the animation
  83429. * @param loopMode Specifies the loop mode of the animation
  83430. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  83431. * @param onAnimationEnd Callback to run once the animation is complete
  83432. * @returns Nullable animation
  83433. */
  83434. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  83435. /**
  83436. * Transition property of an host to the target Value
  83437. * @param property The property to transition
  83438. * @param targetValue The target Value of the property
  83439. * @param host The object where the property to animate belongs
  83440. * @param scene Scene used to run the animation
  83441. * @param frameRate Framerate (in frame/s) to use
  83442. * @param transition The transition type we want to use
  83443. * @param duration The duration of the animation, in milliseconds
  83444. * @param onAnimationEnd Callback trigger at the end of the animation
  83445. * @returns Nullable animation
  83446. */
  83447. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  83448. /**
  83449. * Return the array of runtime animations currently using this animation
  83450. */
  83451. readonly runtimeAnimations: RuntimeAnimation[];
  83452. /**
  83453. * Specifies if any of the runtime animations are currently running
  83454. */
  83455. readonly hasRunningRuntimeAnimations: boolean;
  83456. /**
  83457. * Initializes the animation
  83458. * @param name Name of the animation
  83459. * @param targetProperty Property to animate
  83460. * @param framePerSecond The frames per second of the animation
  83461. * @param dataType The data type of the animation
  83462. * @param loopMode The loop mode of the animation
  83463. * @param enableBlending Specifies if blending should be enabled
  83464. */
  83465. constructor(
  83466. /**Name of the animation */
  83467. name: string,
  83468. /**Property to animate */
  83469. targetProperty: string,
  83470. /**The frames per second of the animation */
  83471. framePerSecond: number,
  83472. /**The data type of the animation */
  83473. dataType: number,
  83474. /**The loop mode of the animation */
  83475. loopMode?: number | undefined,
  83476. /**Specifies if blending should be enabled */
  83477. enableBlending?: boolean | undefined);
  83478. /**
  83479. * Converts the animation to a string
  83480. * @param fullDetails support for multiple levels of logging within scene loading
  83481. * @returns String form of the animation
  83482. */
  83483. toString(fullDetails?: boolean): string;
  83484. /**
  83485. * Add an event to this animation
  83486. * @param event Event to add
  83487. */
  83488. addEvent(event: AnimationEvent): void;
  83489. /**
  83490. * Remove all events found at the given frame
  83491. * @param frame The frame to remove events from
  83492. */
  83493. removeEvents(frame: number): void;
  83494. /**
  83495. * Retrieves all the events from the animation
  83496. * @returns Events from the animation
  83497. */
  83498. getEvents(): AnimationEvent[];
  83499. /**
  83500. * Creates an animation range
  83501. * @param name Name of the animation range
  83502. * @param from Starting frame of the animation range
  83503. * @param to Ending frame of the animation
  83504. */
  83505. createRange(name: string, from: number, to: number): void;
  83506. /**
  83507. * Deletes an animation range by name
  83508. * @param name Name of the animation range to delete
  83509. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  83510. */
  83511. deleteRange(name: string, deleteFrames?: boolean): void;
  83512. /**
  83513. * Gets the animation range by name, or null if not defined
  83514. * @param name Name of the animation range
  83515. * @returns Nullable animation range
  83516. */
  83517. getRange(name: string): Nullable<AnimationRange>;
  83518. /**
  83519. * Gets the key frames from the animation
  83520. * @returns The key frames of the animation
  83521. */
  83522. getKeys(): Array<IAnimationKey>;
  83523. /**
  83524. * Gets the highest frame rate of the animation
  83525. * @returns Highest frame rate of the animation
  83526. */
  83527. getHighestFrame(): number;
  83528. /**
  83529. * Gets the easing function of the animation
  83530. * @returns Easing function of the animation
  83531. */
  83532. getEasingFunction(): IEasingFunction;
  83533. /**
  83534. * Sets the easing function of the animation
  83535. * @param easingFunction A custom mathematical formula for animation
  83536. */
  83537. setEasingFunction(easingFunction: EasingFunction): void;
  83538. /**
  83539. * Interpolates a scalar linearly
  83540. * @param startValue Start value of the animation curve
  83541. * @param endValue End value of the animation curve
  83542. * @param gradient Scalar amount to interpolate
  83543. * @returns Interpolated scalar value
  83544. */
  83545. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  83546. /**
  83547. * Interpolates a scalar cubically
  83548. * @param startValue Start value of the animation curve
  83549. * @param outTangent End tangent of the animation
  83550. * @param endValue End value of the animation curve
  83551. * @param inTangent Start tangent of the animation curve
  83552. * @param gradient Scalar amount to interpolate
  83553. * @returns Interpolated scalar value
  83554. */
  83555. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  83556. /**
  83557. * Interpolates a quaternion using a spherical linear interpolation
  83558. * @param startValue Start value of the animation curve
  83559. * @param endValue End value of the animation curve
  83560. * @param gradient Scalar amount to interpolate
  83561. * @returns Interpolated quaternion value
  83562. */
  83563. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  83564. /**
  83565. * Interpolates a quaternion cubically
  83566. * @param startValue Start value of the animation curve
  83567. * @param outTangent End tangent of the animation curve
  83568. * @param endValue End value of the animation curve
  83569. * @param inTangent Start tangent of the animation curve
  83570. * @param gradient Scalar amount to interpolate
  83571. * @returns Interpolated quaternion value
  83572. */
  83573. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  83574. /**
  83575. * Interpolates a Vector3 linearl
  83576. * @param startValue Start value of the animation curve
  83577. * @param endValue End value of the animation curve
  83578. * @param gradient Scalar amount to interpolate
  83579. * @returns Interpolated scalar value
  83580. */
  83581. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  83582. /**
  83583. * Interpolates a Vector3 cubically
  83584. * @param startValue Start value of the animation curve
  83585. * @param outTangent End tangent of the animation
  83586. * @param endValue End value of the animation curve
  83587. * @param inTangent Start tangent of the animation curve
  83588. * @param gradient Scalar amount to interpolate
  83589. * @returns InterpolatedVector3 value
  83590. */
  83591. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  83592. /**
  83593. * Interpolates a Vector2 linearly
  83594. * @param startValue Start value of the animation curve
  83595. * @param endValue End value of the animation curve
  83596. * @param gradient Scalar amount to interpolate
  83597. * @returns Interpolated Vector2 value
  83598. */
  83599. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  83600. /**
  83601. * Interpolates a Vector2 cubically
  83602. * @param startValue Start value of the animation curve
  83603. * @param outTangent End tangent of the animation
  83604. * @param endValue End value of the animation curve
  83605. * @param inTangent Start tangent of the animation curve
  83606. * @param gradient Scalar amount to interpolate
  83607. * @returns Interpolated Vector2 value
  83608. */
  83609. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  83610. /**
  83611. * Interpolates a size linearly
  83612. * @param startValue Start value of the animation curve
  83613. * @param endValue End value of the animation curve
  83614. * @param gradient Scalar amount to interpolate
  83615. * @returns Interpolated Size value
  83616. */
  83617. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  83618. /**
  83619. * Interpolates a Color3 linearly
  83620. * @param startValue Start value of the animation curve
  83621. * @param endValue End value of the animation curve
  83622. * @param gradient Scalar amount to interpolate
  83623. * @returns Interpolated Color3 value
  83624. */
  83625. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  83626. /**
  83627. * @hidden Internal use only
  83628. */
  83629. _getKeyValue(value: any): any;
  83630. /**
  83631. * @hidden Internal use only
  83632. */
  83633. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  83634. /**
  83635. * Defines the function to use to interpolate matrices
  83636. * @param startValue defines the start matrix
  83637. * @param endValue defines the end matrix
  83638. * @param gradient defines the gradient between both matrices
  83639. * @param result defines an optional target matrix where to store the interpolation
  83640. * @returns the interpolated matrix
  83641. */
  83642. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  83643. /**
  83644. * Makes a copy of the animation
  83645. * @returns Cloned animation
  83646. */
  83647. clone(): Animation;
  83648. /**
  83649. * Sets the key frames of the animation
  83650. * @param values The animation key frames to set
  83651. */
  83652. setKeys(values: Array<IAnimationKey>): void;
  83653. /**
  83654. * Serializes the animation to an object
  83655. * @returns Serialized object
  83656. */
  83657. serialize(): any;
  83658. /**
  83659. * Float animation type
  83660. */
  83661. private static _ANIMATIONTYPE_FLOAT;
  83662. /**
  83663. * Vector3 animation type
  83664. */
  83665. private static _ANIMATIONTYPE_VECTOR3;
  83666. /**
  83667. * Quaternion animation type
  83668. */
  83669. private static _ANIMATIONTYPE_QUATERNION;
  83670. /**
  83671. * Matrix animation type
  83672. */
  83673. private static _ANIMATIONTYPE_MATRIX;
  83674. /**
  83675. * Color3 animation type
  83676. */
  83677. private static _ANIMATIONTYPE_COLOR3;
  83678. /**
  83679. * Vector2 animation type
  83680. */
  83681. private static _ANIMATIONTYPE_VECTOR2;
  83682. /**
  83683. * Size animation type
  83684. */
  83685. private static _ANIMATIONTYPE_SIZE;
  83686. /**
  83687. * Relative Loop Mode
  83688. */
  83689. private static _ANIMATIONLOOPMODE_RELATIVE;
  83690. /**
  83691. * Cycle Loop Mode
  83692. */
  83693. private static _ANIMATIONLOOPMODE_CYCLE;
  83694. /**
  83695. * Constant Loop Mode
  83696. */
  83697. private static _ANIMATIONLOOPMODE_CONSTANT;
  83698. /**
  83699. * Get the float animation type
  83700. */
  83701. static readonly ANIMATIONTYPE_FLOAT: number;
  83702. /**
  83703. * Get the Vector3 animation type
  83704. */
  83705. static readonly ANIMATIONTYPE_VECTOR3: number;
  83706. /**
  83707. * Get the Vector2 animation type
  83708. */
  83709. static readonly ANIMATIONTYPE_VECTOR2: number;
  83710. /**
  83711. * Get the Size animation type
  83712. */
  83713. static readonly ANIMATIONTYPE_SIZE: number;
  83714. /**
  83715. * Get the Quaternion animation type
  83716. */
  83717. static readonly ANIMATIONTYPE_QUATERNION: number;
  83718. /**
  83719. * Get the Matrix animation type
  83720. */
  83721. static readonly ANIMATIONTYPE_MATRIX: number;
  83722. /**
  83723. * Get the Color3 animation type
  83724. */
  83725. static readonly ANIMATIONTYPE_COLOR3: number;
  83726. /**
  83727. * Get the Relative Loop Mode
  83728. */
  83729. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  83730. /**
  83731. * Get the Cycle Loop Mode
  83732. */
  83733. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  83734. /**
  83735. * Get the Constant Loop Mode
  83736. */
  83737. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  83738. /** @hidden */
  83739. static _UniversalLerp(left: any, right: any, amount: number): any;
  83740. /**
  83741. * Parses an animation object and creates an animation
  83742. * @param parsedAnimation Parsed animation object
  83743. * @returns Animation object
  83744. */
  83745. static Parse(parsedAnimation: any): Animation;
  83746. /**
  83747. * Appends the serialized animations from the source animations
  83748. * @param source Source containing the animations
  83749. * @param destination Target to store the animations
  83750. */
  83751. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  83752. }
  83753. }
  83754. declare module BABYLON {
  83755. /**
  83756. * Base class of all the textures in babylon.
  83757. * It groups all the common properties the materials, post process, lights... might need
  83758. * in order to make a correct use of the texture.
  83759. */
  83760. export class BaseTexture implements IAnimatable {
  83761. /**
  83762. * Default anisotropic filtering level for the application.
  83763. * It is set to 4 as a good tradeoff between perf and quality.
  83764. */
  83765. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  83766. /**
  83767. * Gets or sets the unique id of the texture
  83768. */
  83769. uniqueId: number;
  83770. /**
  83771. * Define the name of the texture.
  83772. */
  83773. name: string;
  83774. /**
  83775. * Gets or sets an object used to store user defined information.
  83776. */
  83777. metadata: any;
  83778. /**
  83779. * For internal use only. Please do not use.
  83780. */
  83781. reservedDataStore: any;
  83782. private _hasAlpha;
  83783. /**
  83784. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  83785. */
  83786. hasAlpha: boolean;
  83787. /**
  83788. * Defines if the alpha value should be determined via the rgb values.
  83789. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  83790. */
  83791. getAlphaFromRGB: boolean;
  83792. /**
  83793. * Intensity or strength of the texture.
  83794. * It is commonly used by materials to fine tune the intensity of the texture
  83795. */
  83796. level: number;
  83797. /**
  83798. * Define the UV chanel to use starting from 0 and defaulting to 0.
  83799. * This is part of the texture as textures usually maps to one uv set.
  83800. */
  83801. coordinatesIndex: number;
  83802. private _coordinatesMode;
  83803. /**
  83804. * How a texture is mapped.
  83805. *
  83806. * | Value | Type | Description |
  83807. * | ----- | ----------------------------------- | ----------- |
  83808. * | 0 | EXPLICIT_MODE | |
  83809. * | 1 | SPHERICAL_MODE | |
  83810. * | 2 | PLANAR_MODE | |
  83811. * | 3 | CUBIC_MODE | |
  83812. * | 4 | PROJECTION_MODE | |
  83813. * | 5 | SKYBOX_MODE | |
  83814. * | 6 | INVCUBIC_MODE | |
  83815. * | 7 | EQUIRECTANGULAR_MODE | |
  83816. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  83817. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  83818. */
  83819. coordinatesMode: number;
  83820. /**
  83821. * | Value | Type | Description |
  83822. * | ----- | ------------------ | ----------- |
  83823. * | 0 | CLAMP_ADDRESSMODE | |
  83824. * | 1 | WRAP_ADDRESSMODE | |
  83825. * | 2 | MIRROR_ADDRESSMODE | |
  83826. */
  83827. wrapU: number;
  83828. /**
  83829. * | Value | Type | Description |
  83830. * | ----- | ------------------ | ----------- |
  83831. * | 0 | CLAMP_ADDRESSMODE | |
  83832. * | 1 | WRAP_ADDRESSMODE | |
  83833. * | 2 | MIRROR_ADDRESSMODE | |
  83834. */
  83835. wrapV: number;
  83836. /**
  83837. * | Value | Type | Description |
  83838. * | ----- | ------------------ | ----------- |
  83839. * | 0 | CLAMP_ADDRESSMODE | |
  83840. * | 1 | WRAP_ADDRESSMODE | |
  83841. * | 2 | MIRROR_ADDRESSMODE | |
  83842. */
  83843. wrapR: number;
  83844. /**
  83845. * With compliant hardware and browser (supporting anisotropic filtering)
  83846. * this defines the level of anisotropic filtering in the texture.
  83847. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  83848. */
  83849. anisotropicFilteringLevel: number;
  83850. /**
  83851. * Define if the texture is a cube texture or if false a 2d texture.
  83852. */
  83853. isCube: boolean;
  83854. /**
  83855. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  83856. */
  83857. is3D: boolean;
  83858. /**
  83859. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  83860. * HDR texture are usually stored in linear space.
  83861. * This only impacts the PBR and Background materials
  83862. */
  83863. gammaSpace: boolean;
  83864. /**
  83865. * Gets whether or not the texture contains RGBD data.
  83866. */
  83867. readonly isRGBD: boolean;
  83868. /**
  83869. * Is Z inverted in the texture (useful in a cube texture).
  83870. */
  83871. invertZ: boolean;
  83872. /**
  83873. * Are mip maps generated for this texture or not.
  83874. */
  83875. readonly noMipmap: boolean;
  83876. /**
  83877. * @hidden
  83878. */
  83879. lodLevelInAlpha: boolean;
  83880. /**
  83881. * With prefiltered texture, defined the offset used during the prefiltering steps.
  83882. */
  83883. lodGenerationOffset: number;
  83884. /**
  83885. * With prefiltered texture, defined the scale used during the prefiltering steps.
  83886. */
  83887. lodGenerationScale: number;
  83888. /**
  83889. * Define if the texture is a render target.
  83890. */
  83891. isRenderTarget: boolean;
  83892. /**
  83893. * Define the unique id of the texture in the scene.
  83894. */
  83895. readonly uid: string;
  83896. /**
  83897. * Return a string representation of the texture.
  83898. * @returns the texture as a string
  83899. */
  83900. toString(): string;
  83901. /**
  83902. * Get the class name of the texture.
  83903. * @returns "BaseTexture"
  83904. */
  83905. getClassName(): string;
  83906. /**
  83907. * Define the list of animation attached to the texture.
  83908. */
  83909. animations: Animation[];
  83910. /**
  83911. * An event triggered when the texture is disposed.
  83912. */
  83913. onDisposeObservable: Observable<BaseTexture>;
  83914. private _onDisposeObserver;
  83915. /**
  83916. * Callback triggered when the texture has been disposed.
  83917. * Kept for back compatibility, you can use the onDisposeObservable instead.
  83918. */
  83919. onDispose: () => void;
  83920. /**
  83921. * Define the current state of the loading sequence when in delayed load mode.
  83922. */
  83923. delayLoadState: number;
  83924. private _scene;
  83925. /** @hidden */
  83926. _texture: Nullable<InternalTexture>;
  83927. private _uid;
  83928. /**
  83929. * Define if the texture is preventinga material to render or not.
  83930. * If not and the texture is not ready, the engine will use a default black texture instead.
  83931. */
  83932. readonly isBlocking: boolean;
  83933. /**
  83934. * Instantiates a new BaseTexture.
  83935. * Base class of all the textures in babylon.
  83936. * It groups all the common properties the materials, post process, lights... might need
  83937. * in order to make a correct use of the texture.
  83938. * @param scene Define the scene the texture blongs to
  83939. */
  83940. constructor(scene: Nullable<Scene>);
  83941. /**
  83942. * Get the scene the texture belongs to.
  83943. * @returns the scene or null if undefined
  83944. */
  83945. getScene(): Nullable<Scene>;
  83946. /**
  83947. * Get the texture transform matrix used to offset tile the texture for istance.
  83948. * @returns the transformation matrix
  83949. */
  83950. getTextureMatrix(): Matrix;
  83951. /**
  83952. * Get the texture reflection matrix used to rotate/transform the reflection.
  83953. * @returns the reflection matrix
  83954. */
  83955. getReflectionTextureMatrix(): Matrix;
  83956. /**
  83957. * Get the underlying lower level texture from Babylon.
  83958. * @returns the insternal texture
  83959. */
  83960. getInternalTexture(): Nullable<InternalTexture>;
  83961. /**
  83962. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  83963. * @returns true if ready or not blocking
  83964. */
  83965. isReadyOrNotBlocking(): boolean;
  83966. /**
  83967. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  83968. * @returns true if fully ready
  83969. */
  83970. isReady(): boolean;
  83971. private _cachedSize;
  83972. /**
  83973. * Get the size of the texture.
  83974. * @returns the texture size.
  83975. */
  83976. getSize(): ISize;
  83977. /**
  83978. * Get the base size of the texture.
  83979. * It can be different from the size if the texture has been resized for POT for instance
  83980. * @returns the base size
  83981. */
  83982. getBaseSize(): ISize;
  83983. /**
  83984. * Update the sampling mode of the texture.
  83985. * Default is Trilinear mode.
  83986. *
  83987. * | Value | Type | Description |
  83988. * | ----- | ------------------ | ----------- |
  83989. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  83990. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  83991. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  83992. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  83993. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  83994. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  83995. * | 7 | NEAREST_LINEAR | |
  83996. * | 8 | NEAREST_NEAREST | |
  83997. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  83998. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  83999. * | 11 | LINEAR_LINEAR | |
  84000. * | 12 | LINEAR_NEAREST | |
  84001. *
  84002. * > _mag_: magnification filter (close to the viewer)
  84003. * > _min_: minification filter (far from the viewer)
  84004. * > _mip_: filter used between mip map levels
  84005. *@param samplingMode Define the new sampling mode of the texture
  84006. */
  84007. updateSamplingMode(samplingMode: number): void;
  84008. /**
  84009. * Scales the texture if is `canRescale()`
  84010. * @param ratio the resize factor we want to use to rescale
  84011. */
  84012. scale(ratio: number): void;
  84013. /**
  84014. * Get if the texture can rescale.
  84015. */
  84016. readonly canRescale: boolean;
  84017. /** @hidden */
  84018. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  84019. /** @hidden */
  84020. _rebuild(): void;
  84021. /**
  84022. * Triggers the load sequence in delayed load mode.
  84023. */
  84024. delayLoad(): void;
  84025. /**
  84026. * Clones the texture.
  84027. * @returns the cloned texture
  84028. */
  84029. clone(): Nullable<BaseTexture>;
  84030. /**
  84031. * Get the texture underlying type (INT, FLOAT...)
  84032. */
  84033. readonly textureType: number;
  84034. /**
  84035. * Get the texture underlying format (RGB, RGBA...)
  84036. */
  84037. readonly textureFormat: number;
  84038. /**
  84039. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  84040. * This will returns an RGBA array buffer containing either in values (0-255) or
  84041. * float values (0-1) depending of the underlying buffer type.
  84042. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  84043. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  84044. * @param buffer defines a user defined buffer to fill with data (can be null)
  84045. * @returns The Array buffer containing the pixels data.
  84046. */
  84047. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  84048. /**
  84049. * Release and destroy the underlying lower level texture aka internalTexture.
  84050. */
  84051. releaseInternalTexture(): void;
  84052. /**
  84053. * Get the polynomial representation of the texture data.
  84054. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  84055. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  84056. */
  84057. sphericalPolynomial: Nullable<SphericalPolynomial>;
  84058. /** @hidden */
  84059. readonly _lodTextureHigh: Nullable<BaseTexture>;
  84060. /** @hidden */
  84061. readonly _lodTextureMid: Nullable<BaseTexture>;
  84062. /** @hidden */
  84063. readonly _lodTextureLow: Nullable<BaseTexture>;
  84064. /**
  84065. * Dispose the texture and release its associated resources.
  84066. */
  84067. dispose(): void;
  84068. /**
  84069. * Serialize the texture into a JSON representation that can be parsed later on.
  84070. * @returns the JSON representation of the texture
  84071. */
  84072. serialize(): any;
  84073. /**
  84074. * Helper function to be called back once a list of texture contains only ready textures.
  84075. * @param textures Define the list of textures to wait for
  84076. * @param callback Define the callback triggered once the entire list will be ready
  84077. */
  84078. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  84079. }
  84080. }
  84081. declare module BABYLON {
  84082. /**
  84083. * Uniform buffer objects.
  84084. *
  84085. * Handles blocks of uniform on the GPU.
  84086. *
  84087. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  84088. *
  84089. * For more information, please refer to :
  84090. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  84091. */
  84092. export class UniformBuffer {
  84093. private _engine;
  84094. private _buffer;
  84095. private _data;
  84096. private _bufferData;
  84097. private _dynamic?;
  84098. private _uniformLocations;
  84099. private _uniformSizes;
  84100. private _uniformLocationPointer;
  84101. private _needSync;
  84102. private _noUBO;
  84103. private _currentEffect;
  84104. private static _MAX_UNIFORM_SIZE;
  84105. private static _tempBuffer;
  84106. /**
  84107. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  84108. * This is dynamic to allow compat with webgl 1 and 2.
  84109. * You will need to pass the name of the uniform as well as the value.
  84110. */
  84111. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  84112. /**
  84113. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  84114. * This is dynamic to allow compat with webgl 1 and 2.
  84115. * You will need to pass the name of the uniform as well as the value.
  84116. */
  84117. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  84118. /**
  84119. * Lambda to Update a single float in a uniform buffer.
  84120. * This is dynamic to allow compat with webgl 1 and 2.
  84121. * You will need to pass the name of the uniform as well as the value.
  84122. */
  84123. updateFloat: (name: string, x: number) => void;
  84124. /**
  84125. * Lambda to Update a vec2 of float in a uniform buffer.
  84126. * This is dynamic to allow compat with webgl 1 and 2.
  84127. * You will need to pass the name of the uniform as well as the value.
  84128. */
  84129. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  84130. /**
  84131. * Lambda to Update a vec3 of float in a uniform buffer.
  84132. * This is dynamic to allow compat with webgl 1 and 2.
  84133. * You will need to pass the name of the uniform as well as the value.
  84134. */
  84135. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  84136. /**
  84137. * Lambda to Update a vec4 of float in a uniform buffer.
  84138. * This is dynamic to allow compat with webgl 1 and 2.
  84139. * You will need to pass the name of the uniform as well as the value.
  84140. */
  84141. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  84142. /**
  84143. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  84144. * This is dynamic to allow compat with webgl 1 and 2.
  84145. * You will need to pass the name of the uniform as well as the value.
  84146. */
  84147. updateMatrix: (name: string, mat: Matrix) => void;
  84148. /**
  84149. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  84150. * This is dynamic to allow compat with webgl 1 and 2.
  84151. * You will need to pass the name of the uniform as well as the value.
  84152. */
  84153. updateVector3: (name: string, vector: Vector3) => void;
  84154. /**
  84155. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  84156. * This is dynamic to allow compat with webgl 1 and 2.
  84157. * You will need to pass the name of the uniform as well as the value.
  84158. */
  84159. updateVector4: (name: string, vector: Vector4) => void;
  84160. /**
  84161. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  84162. * This is dynamic to allow compat with webgl 1 and 2.
  84163. * You will need to pass the name of the uniform as well as the value.
  84164. */
  84165. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  84166. /**
  84167. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  84168. * This is dynamic to allow compat with webgl 1 and 2.
  84169. * You will need to pass the name of the uniform as well as the value.
  84170. */
  84171. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  84172. /**
  84173. * Instantiates a new Uniform buffer objects.
  84174. *
  84175. * Handles blocks of uniform on the GPU.
  84176. *
  84177. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  84178. *
  84179. * For more information, please refer to :
  84180. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  84181. * @param engine Define the engine the buffer is associated with
  84182. * @param data Define the data contained in the buffer
  84183. * @param dynamic Define if the buffer is updatable
  84184. */
  84185. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  84186. /**
  84187. * Indicates if the buffer is using the WebGL2 UBO implementation,
  84188. * or just falling back on setUniformXXX calls.
  84189. */
  84190. readonly useUbo: boolean;
  84191. /**
  84192. * Indicates if the WebGL underlying uniform buffer is in sync
  84193. * with the javascript cache data.
  84194. */
  84195. readonly isSync: boolean;
  84196. /**
  84197. * Indicates if the WebGL underlying uniform buffer is dynamic.
  84198. * Also, a dynamic UniformBuffer will disable cache verification and always
  84199. * update the underlying WebGL uniform buffer to the GPU.
  84200. * @returns if Dynamic, otherwise false
  84201. */
  84202. isDynamic(): boolean;
  84203. /**
  84204. * The data cache on JS side.
  84205. * @returns the underlying data as a float array
  84206. */
  84207. getData(): Float32Array;
  84208. /**
  84209. * The underlying WebGL Uniform buffer.
  84210. * @returns the webgl buffer
  84211. */
  84212. getBuffer(): Nullable<WebGLBuffer>;
  84213. /**
  84214. * std140 layout specifies how to align data within an UBO structure.
  84215. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  84216. * for specs.
  84217. */
  84218. private _fillAlignment;
  84219. /**
  84220. * Adds an uniform in the buffer.
  84221. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  84222. * for the layout to be correct !
  84223. * @param name Name of the uniform, as used in the uniform block in the shader.
  84224. * @param size Data size, or data directly.
  84225. */
  84226. addUniform(name: string, size: number | number[]): void;
  84227. /**
  84228. * Adds a Matrix 4x4 to the uniform buffer.
  84229. * @param name Name of the uniform, as used in the uniform block in the shader.
  84230. * @param mat A 4x4 matrix.
  84231. */
  84232. addMatrix(name: string, mat: Matrix): void;
  84233. /**
  84234. * Adds a vec2 to the uniform buffer.
  84235. * @param name Name of the uniform, as used in the uniform block in the shader.
  84236. * @param x Define the x component value of the vec2
  84237. * @param y Define the y component value of the vec2
  84238. */
  84239. addFloat2(name: string, x: number, y: number): void;
  84240. /**
  84241. * Adds a vec3 to the uniform buffer.
  84242. * @param name Name of the uniform, as used in the uniform block in the shader.
  84243. * @param x Define the x component value of the vec3
  84244. * @param y Define the y component value of the vec3
  84245. * @param z Define the z component value of the vec3
  84246. */
  84247. addFloat3(name: string, x: number, y: number, z: number): void;
  84248. /**
  84249. * Adds a vec3 to the uniform buffer.
  84250. * @param name Name of the uniform, as used in the uniform block in the shader.
  84251. * @param color Define the vec3 from a Color
  84252. */
  84253. addColor3(name: string, color: Color3): void;
  84254. /**
  84255. * Adds a vec4 to the uniform buffer.
  84256. * @param name Name of the uniform, as used in the uniform block in the shader.
  84257. * @param color Define the rgb components from a Color
  84258. * @param alpha Define the a component of the vec4
  84259. */
  84260. addColor4(name: string, color: Color3, alpha: number): void;
  84261. /**
  84262. * Adds a vec3 to the uniform buffer.
  84263. * @param name Name of the uniform, as used in the uniform block in the shader.
  84264. * @param vector Define the vec3 components from a Vector
  84265. */
  84266. addVector3(name: string, vector: Vector3): void;
  84267. /**
  84268. * Adds a Matrix 3x3 to the uniform buffer.
  84269. * @param name Name of the uniform, as used in the uniform block in the shader.
  84270. */
  84271. addMatrix3x3(name: string): void;
  84272. /**
  84273. * Adds a Matrix 2x2 to the uniform buffer.
  84274. * @param name Name of the uniform, as used in the uniform block in the shader.
  84275. */
  84276. addMatrix2x2(name: string): void;
  84277. /**
  84278. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  84279. */
  84280. create(): void;
  84281. /** @hidden */
  84282. _rebuild(): void;
  84283. /**
  84284. * Updates the WebGL Uniform Buffer on the GPU.
  84285. * If the `dynamic` flag is set to true, no cache comparison is done.
  84286. * Otherwise, the buffer will be updated only if the cache differs.
  84287. */
  84288. update(): void;
  84289. /**
  84290. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  84291. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  84292. * @param data Define the flattened data
  84293. * @param size Define the size of the data.
  84294. */
  84295. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  84296. private _updateMatrix3x3ForUniform;
  84297. private _updateMatrix3x3ForEffect;
  84298. private _updateMatrix2x2ForEffect;
  84299. private _updateMatrix2x2ForUniform;
  84300. private _updateFloatForEffect;
  84301. private _updateFloatForUniform;
  84302. private _updateFloat2ForEffect;
  84303. private _updateFloat2ForUniform;
  84304. private _updateFloat3ForEffect;
  84305. private _updateFloat3ForUniform;
  84306. private _updateFloat4ForEffect;
  84307. private _updateFloat4ForUniform;
  84308. private _updateMatrixForEffect;
  84309. private _updateMatrixForUniform;
  84310. private _updateVector3ForEffect;
  84311. private _updateVector3ForUniform;
  84312. private _updateVector4ForEffect;
  84313. private _updateVector4ForUniform;
  84314. private _updateColor3ForEffect;
  84315. private _updateColor3ForUniform;
  84316. private _updateColor4ForEffect;
  84317. private _updateColor4ForUniform;
  84318. /**
  84319. * Sets a sampler uniform on the effect.
  84320. * @param name Define the name of the sampler.
  84321. * @param texture Define the texture to set in the sampler
  84322. */
  84323. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  84324. /**
  84325. * Directly updates the value of the uniform in the cache AND on the GPU.
  84326. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  84327. * @param data Define the flattened data
  84328. */
  84329. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  84330. /**
  84331. * Binds this uniform buffer to an effect.
  84332. * @param effect Define the effect to bind the buffer to
  84333. * @param name Name of the uniform block in the shader.
  84334. */
  84335. bindToEffect(effect: Effect, name: string): void;
  84336. /**
  84337. * Disposes the uniform buffer.
  84338. */
  84339. dispose(): void;
  84340. }
  84341. }
  84342. declare module BABYLON {
  84343. /**
  84344. * This represents the required contract to create a new type of texture loader.
  84345. */
  84346. export interface IInternalTextureLoader {
  84347. /**
  84348. * Defines wether the loader supports cascade loading the different faces.
  84349. */
  84350. supportCascades: boolean;
  84351. /**
  84352. * This returns if the loader support the current file information.
  84353. * @param extension defines the file extension of the file being loaded
  84354. * @param textureFormatInUse defines the current compressed format in use iun the engine
  84355. * @param fallback defines the fallback internal texture if any
  84356. * @param isBase64 defines whether the texture is encoded as a base64
  84357. * @param isBuffer defines whether the texture data are stored as a buffer
  84358. * @returns true if the loader can load the specified file
  84359. */
  84360. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  84361. /**
  84362. * Transform the url before loading if required.
  84363. * @param rootUrl the url of the texture
  84364. * @param textureFormatInUse defines the current compressed format in use iun the engine
  84365. * @returns the transformed texture
  84366. */
  84367. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  84368. /**
  84369. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  84370. * @param rootUrl the url of the texture
  84371. * @param textureFormatInUse defines the current compressed format in use iun the engine
  84372. * @returns the fallback texture
  84373. */
  84374. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  84375. /**
  84376. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  84377. * @param data contains the texture data
  84378. * @param texture defines the BabylonJS internal texture
  84379. * @param createPolynomials will be true if polynomials have been requested
  84380. * @param onLoad defines the callback to trigger once the texture is ready
  84381. * @param onError defines the callback to trigger in case of error
  84382. */
  84383. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  84384. /**
  84385. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  84386. * @param data contains the texture data
  84387. * @param texture defines the BabylonJS internal texture
  84388. * @param callback defines the method to call once ready to upload
  84389. */
  84390. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  84391. }
  84392. }
  84393. declare module BABYLON {
  84394. /**
  84395. * Creation options of the multi render target texture.
  84396. */
  84397. export interface IMultiRenderTargetOptions {
  84398. /**
  84399. * Define if the texture needs to create mip maps after render.
  84400. */
  84401. generateMipMaps?: boolean;
  84402. /**
  84403. * Define the types of all the draw buffers we want to create
  84404. */
  84405. types?: number[];
  84406. /**
  84407. * Define the sampling modes of all the draw buffers we want to create
  84408. */
  84409. samplingModes?: number[];
  84410. /**
  84411. * Define if a depth buffer is required
  84412. */
  84413. generateDepthBuffer?: boolean;
  84414. /**
  84415. * Define if a stencil buffer is required
  84416. */
  84417. generateStencilBuffer?: boolean;
  84418. /**
  84419. * Define if a depth texture is required instead of a depth buffer
  84420. */
  84421. generateDepthTexture?: boolean;
  84422. /**
  84423. * Define the number of desired draw buffers
  84424. */
  84425. textureCount?: number;
  84426. /**
  84427. * Define if aspect ratio should be adapted to the texture or stay the scene one
  84428. */
  84429. doNotChangeAspectRatio?: boolean;
  84430. /**
  84431. * Define the default type of the buffers we are creating
  84432. */
  84433. defaultType?: number;
  84434. }
  84435. /**
  84436. * A multi render target, like a render target provides the ability to render to a texture.
  84437. * Unlike the render target, it can render to several draw buffers in one draw.
  84438. * This is specially interesting in deferred rendering or for any effects requiring more than
  84439. * just one color from a single pass.
  84440. */
  84441. export class MultiRenderTarget extends RenderTargetTexture {
  84442. private _internalTextures;
  84443. private _textures;
  84444. private _multiRenderTargetOptions;
  84445. /**
  84446. * Get if draw buffers are currently supported by the used hardware and browser.
  84447. */
  84448. readonly isSupported: boolean;
  84449. /**
  84450. * Get the list of textures generated by the multi render target.
  84451. */
  84452. readonly textures: Texture[];
  84453. /**
  84454. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  84455. */
  84456. readonly depthTexture: Texture;
  84457. /**
  84458. * Set the wrapping mode on U of all the textures we are rendering to.
  84459. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  84460. */
  84461. wrapU: number;
  84462. /**
  84463. * Set the wrapping mode on V of all the textures we are rendering to.
  84464. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  84465. */
  84466. wrapV: number;
  84467. /**
  84468. * Instantiate a new multi render target texture.
  84469. * A multi render target, like a render target provides the ability to render to a texture.
  84470. * Unlike the render target, it can render to several draw buffers in one draw.
  84471. * This is specially interesting in deferred rendering or for any effects requiring more than
  84472. * just one color from a single pass.
  84473. * @param name Define the name of the texture
  84474. * @param size Define the size of the buffers to render to
  84475. * @param count Define the number of target we are rendering into
  84476. * @param scene Define the scene the texture belongs to
  84477. * @param options Define the options used to create the multi render target
  84478. */
  84479. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  84480. /** @hidden */
  84481. _rebuild(): void;
  84482. private _createInternalTextures;
  84483. private _createTextures;
  84484. /**
  84485. * Define the number of samples used if MSAA is enabled.
  84486. */
  84487. samples: number;
  84488. /**
  84489. * Resize all the textures in the multi render target.
  84490. * Be carrefull as it will recreate all the data in the new texture.
  84491. * @param size Define the new size
  84492. */
  84493. resize(size: any): void;
  84494. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  84495. /**
  84496. * Dispose the render targets and their associated resources
  84497. */
  84498. dispose(): void;
  84499. /**
  84500. * Release all the underlying texture used as draw buffers.
  84501. */
  84502. releaseInternalTextures(): void;
  84503. }
  84504. }
  84505. declare module BABYLON {
  84506. /**
  84507. * Class used to work with sound analyzer using fast fourier transform (FFT)
  84508. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  84509. */
  84510. export class Analyser {
  84511. /**
  84512. * Gets or sets the smoothing
  84513. * @ignorenaming
  84514. */
  84515. SMOOTHING: number;
  84516. /**
  84517. * Gets or sets the FFT table size
  84518. * @ignorenaming
  84519. */
  84520. FFT_SIZE: number;
  84521. /**
  84522. * Gets or sets the bar graph amplitude
  84523. * @ignorenaming
  84524. */
  84525. BARGRAPHAMPLITUDE: number;
  84526. /**
  84527. * Gets or sets the position of the debug canvas
  84528. * @ignorenaming
  84529. */
  84530. DEBUGCANVASPOS: {
  84531. x: number;
  84532. y: number;
  84533. };
  84534. /**
  84535. * Gets or sets the debug canvas size
  84536. * @ignorenaming
  84537. */
  84538. DEBUGCANVASSIZE: {
  84539. width: number;
  84540. height: number;
  84541. };
  84542. private _byteFreqs;
  84543. private _byteTime;
  84544. private _floatFreqs;
  84545. private _webAudioAnalyser;
  84546. private _debugCanvas;
  84547. private _debugCanvasContext;
  84548. private _scene;
  84549. private _registerFunc;
  84550. private _audioEngine;
  84551. /**
  84552. * Creates a new analyser
  84553. * @param scene defines hosting scene
  84554. */
  84555. constructor(scene: Scene);
  84556. /**
  84557. * Get the number of data values you will have to play with for the visualization
  84558. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  84559. * @returns a number
  84560. */
  84561. getFrequencyBinCount(): number;
  84562. /**
  84563. * Gets the current frequency data as a byte array
  84564. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  84565. * @returns a Uint8Array
  84566. */
  84567. getByteFrequencyData(): Uint8Array;
  84568. /**
  84569. * Gets the current waveform as a byte array
  84570. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  84571. * @returns a Uint8Array
  84572. */
  84573. getByteTimeDomainData(): Uint8Array;
  84574. /**
  84575. * Gets the current frequency data as a float array
  84576. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  84577. * @returns a Float32Array
  84578. */
  84579. getFloatFrequencyData(): Float32Array;
  84580. /**
  84581. * Renders the debug canvas
  84582. */
  84583. drawDebugCanvas(): void;
  84584. /**
  84585. * Stops rendering the debug canvas and removes it
  84586. */
  84587. stopDebugCanvas(): void;
  84588. /**
  84589. * Connects two audio nodes
  84590. * @param inputAudioNode defines first node to connect
  84591. * @param outputAudioNode defines second node to connect
  84592. */
  84593. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  84594. /**
  84595. * Releases all associated resources
  84596. */
  84597. dispose(): void;
  84598. }
  84599. }
  84600. declare module BABYLON {
  84601. /**
  84602. * This represents an audio engine and it is responsible
  84603. * to play, synchronize and analyse sounds throughout the application.
  84604. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  84605. */
  84606. export interface IAudioEngine extends IDisposable {
  84607. /**
  84608. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  84609. */
  84610. readonly canUseWebAudio: boolean;
  84611. /**
  84612. * Gets the current AudioContext if available.
  84613. */
  84614. readonly audioContext: Nullable<AudioContext>;
  84615. /**
  84616. * The master gain node defines the global audio volume of your audio engine.
  84617. */
  84618. readonly masterGain: GainNode;
  84619. /**
  84620. * Gets whether or not mp3 are supported by your browser.
  84621. */
  84622. readonly isMP3supported: boolean;
  84623. /**
  84624. * Gets whether or not ogg are supported by your browser.
  84625. */
  84626. readonly isOGGsupported: boolean;
  84627. /**
  84628. * Defines if Babylon should emit a warning if WebAudio is not supported.
  84629. * @ignoreNaming
  84630. */
  84631. WarnedWebAudioUnsupported: boolean;
  84632. /**
  84633. * Defines if the audio engine relies on a custom unlocked button.
  84634. * In this case, the embedded button will not be displayed.
  84635. */
  84636. useCustomUnlockedButton: boolean;
  84637. /**
  84638. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  84639. */
  84640. readonly unlocked: boolean;
  84641. /**
  84642. * Event raised when audio has been unlocked on the browser.
  84643. */
  84644. onAudioUnlockedObservable: Observable<AudioEngine>;
  84645. /**
  84646. * Event raised when audio has been locked on the browser.
  84647. */
  84648. onAudioLockedObservable: Observable<AudioEngine>;
  84649. /**
  84650. * Flags the audio engine in Locked state.
  84651. * This happens due to new browser policies preventing audio to autoplay.
  84652. */
  84653. lock(): void;
  84654. /**
  84655. * Unlocks the audio engine once a user action has been done on the dom.
  84656. * This is helpful to resume play once browser policies have been satisfied.
  84657. */
  84658. unlock(): void;
  84659. }
  84660. /**
  84661. * This represents the default audio engine used in babylon.
  84662. * It is responsible to play, synchronize and analyse sounds throughout the application.
  84663. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  84664. */
  84665. export class AudioEngine implements IAudioEngine {
  84666. private _audioContext;
  84667. private _audioContextInitialized;
  84668. private _muteButton;
  84669. private _hostElement;
  84670. /**
  84671. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  84672. */
  84673. canUseWebAudio: boolean;
  84674. /**
  84675. * The master gain node defines the global audio volume of your audio engine.
  84676. */
  84677. masterGain: GainNode;
  84678. /**
  84679. * Defines if Babylon should emit a warning if WebAudio is not supported.
  84680. * @ignoreNaming
  84681. */
  84682. WarnedWebAudioUnsupported: boolean;
  84683. /**
  84684. * Gets whether or not mp3 are supported by your browser.
  84685. */
  84686. isMP3supported: boolean;
  84687. /**
  84688. * Gets whether or not ogg are supported by your browser.
  84689. */
  84690. isOGGsupported: boolean;
  84691. /**
  84692. * Gets whether audio has been unlocked on the device.
  84693. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  84694. * a user interaction has happened.
  84695. */
  84696. unlocked: boolean;
  84697. /**
  84698. * Defines if the audio engine relies on a custom unlocked button.
  84699. * In this case, the embedded button will not be displayed.
  84700. */
  84701. useCustomUnlockedButton: boolean;
  84702. /**
  84703. * Event raised when audio has been unlocked on the browser.
  84704. */
  84705. onAudioUnlockedObservable: Observable<AudioEngine>;
  84706. /**
  84707. * Event raised when audio has been locked on the browser.
  84708. */
  84709. onAudioLockedObservable: Observable<AudioEngine>;
  84710. /**
  84711. * Gets the current AudioContext if available.
  84712. */
  84713. readonly audioContext: Nullable<AudioContext>;
  84714. private _connectedAnalyser;
  84715. /**
  84716. * Instantiates a new audio engine.
  84717. *
  84718. * There should be only one per page as some browsers restrict the number
  84719. * of audio contexts you can create.
  84720. * @param hostElement defines the host element where to display the mute icon if necessary
  84721. */
  84722. constructor(hostElement?: Nullable<HTMLElement>);
  84723. /**
  84724. * Flags the audio engine in Locked state.
  84725. * This happens due to new browser policies preventing audio to autoplay.
  84726. */
  84727. lock(): void;
  84728. /**
  84729. * Unlocks the audio engine once a user action has been done on the dom.
  84730. * This is helpful to resume play once browser policies have been satisfied.
  84731. */
  84732. unlock(): void;
  84733. private _resumeAudioContext;
  84734. private _initializeAudioContext;
  84735. private _tryToRun;
  84736. private _triggerRunningState;
  84737. private _triggerSuspendedState;
  84738. private _displayMuteButton;
  84739. private _moveButtonToTopLeft;
  84740. private _onResize;
  84741. private _hideMuteButton;
  84742. /**
  84743. * Destroy and release the resources associated with the audio ccontext.
  84744. */
  84745. dispose(): void;
  84746. /**
  84747. * Gets the global volume sets on the master gain.
  84748. * @returns the global volume if set or -1 otherwise
  84749. */
  84750. getGlobalVolume(): number;
  84751. /**
  84752. * Sets the global volume of your experience (sets on the master gain).
  84753. * @param newVolume Defines the new global volume of the application
  84754. */
  84755. setGlobalVolume(newVolume: number): void;
  84756. /**
  84757. * Connect the audio engine to an audio analyser allowing some amazing
  84758. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  84759. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  84760. * @param analyser The analyser to connect to the engine
  84761. */
  84762. connectToAnalyser(analyser: Analyser): void;
  84763. }
  84764. }
  84765. declare module BABYLON {
  84766. /**
  84767. * Interface used to present a loading screen while loading a scene
  84768. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84769. */
  84770. export interface ILoadingScreen {
  84771. /**
  84772. * Function called to display the loading screen
  84773. */
  84774. displayLoadingUI: () => void;
  84775. /**
  84776. * Function called to hide the loading screen
  84777. */
  84778. hideLoadingUI: () => void;
  84779. /**
  84780. * Gets or sets the color to use for the background
  84781. */
  84782. loadingUIBackgroundColor: string;
  84783. /**
  84784. * Gets or sets the text to display while loading
  84785. */
  84786. loadingUIText: string;
  84787. }
  84788. /**
  84789. * Class used for the default loading screen
  84790. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84791. */
  84792. export class DefaultLoadingScreen implements ILoadingScreen {
  84793. private _renderingCanvas;
  84794. private _loadingText;
  84795. private _loadingDivBackgroundColor;
  84796. private _loadingDiv;
  84797. private _loadingTextDiv;
  84798. /**
  84799. * Creates a new default loading screen
  84800. * @param _renderingCanvas defines the canvas used to render the scene
  84801. * @param _loadingText defines the default text to display
  84802. * @param _loadingDivBackgroundColor defines the default background color
  84803. */
  84804. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  84805. /**
  84806. * Function called to display the loading screen
  84807. */
  84808. displayLoadingUI(): void;
  84809. /**
  84810. * Function called to hide the loading screen
  84811. */
  84812. hideLoadingUI(): void;
  84813. /**
  84814. * Gets or sets the text to display while loading
  84815. */
  84816. loadingUIText: string;
  84817. /**
  84818. * Gets or sets the color to use for the background
  84819. */
  84820. loadingUIBackgroundColor: string;
  84821. private _resizeLoadingUI;
  84822. }
  84823. }
  84824. declare module BABYLON {
  84825. /**
  84826. * Settings for finer control over video usage
  84827. */
  84828. export interface VideoTextureSettings {
  84829. /**
  84830. * Applies `autoplay` to video, if specified
  84831. */
  84832. autoPlay?: boolean;
  84833. /**
  84834. * Applies `loop` to video, if specified
  84835. */
  84836. loop?: boolean;
  84837. /**
  84838. * Automatically updates internal texture from video at every frame in the render loop
  84839. */
  84840. autoUpdateTexture: boolean;
  84841. /**
  84842. * Image src displayed during the video loading or until the user interacts with the video.
  84843. */
  84844. poster?: string;
  84845. }
  84846. /**
  84847. * If you want to display a video in your scene, this is the special texture for that.
  84848. * This special texture works similar to other textures, with the exception of a few parameters.
  84849. * @see https://doc.babylonjs.com/how_to/video_texture
  84850. */
  84851. export class VideoTexture extends Texture {
  84852. /**
  84853. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  84854. */
  84855. readonly autoUpdateTexture: boolean;
  84856. /**
  84857. * The video instance used by the texture internally
  84858. */
  84859. readonly video: HTMLVideoElement;
  84860. private _onUserActionRequestedObservable;
  84861. /**
  84862. * Event triggerd when a dom action is required by the user to play the video.
  84863. * This happens due to recent changes in browser policies preventing video to auto start.
  84864. */
  84865. readonly onUserActionRequestedObservable: Observable<Texture>;
  84866. private _generateMipMaps;
  84867. private _engine;
  84868. private _stillImageCaptured;
  84869. private _displayingPosterTexture;
  84870. private _settings;
  84871. private _createInternalTextureOnEvent;
  84872. /**
  84873. * Creates a video texture.
  84874. * If you want to display a video in your scene, this is the special texture for that.
  84875. * This special texture works similar to other textures, with the exception of a few parameters.
  84876. * @see https://doc.babylonjs.com/how_to/video_texture
  84877. * @param name optional name, will detect from video source, if not defined
  84878. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  84879. * @param scene is obviously the current scene.
  84880. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  84881. * @param invertY is false by default but can be used to invert video on Y axis
  84882. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  84883. * @param settings allows finer control over video usage
  84884. */
  84885. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  84886. private _getName;
  84887. private _getVideo;
  84888. private _createInternalTexture;
  84889. private reset;
  84890. /**
  84891. * @hidden Internal method to initiate `update`.
  84892. */
  84893. _rebuild(): void;
  84894. /**
  84895. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  84896. */
  84897. update(): void;
  84898. /**
  84899. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  84900. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  84901. */
  84902. updateTexture(isVisible: boolean): void;
  84903. protected _updateInternalTexture: () => void;
  84904. /**
  84905. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  84906. * @param url New url.
  84907. */
  84908. updateURL(url: string): void;
  84909. /**
  84910. * Dispose the texture and release its associated resources.
  84911. */
  84912. dispose(): void;
  84913. /**
  84914. * Creates a video texture straight from a stream.
  84915. * @param scene Define the scene the texture should be created in
  84916. * @param stream Define the stream the texture should be created from
  84917. * @returns The created video texture as a promise
  84918. */
  84919. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  84920. /**
  84921. * Creates a video texture straight from your WebCam video feed.
  84922. * @param scene Define the scene the texture should be created in
  84923. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  84924. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  84925. * @returns The created video texture as a promise
  84926. */
  84927. static CreateFromWebCamAsync(scene: Scene, constraints: {
  84928. minWidth: number;
  84929. maxWidth: number;
  84930. minHeight: number;
  84931. maxHeight: number;
  84932. deviceId: string;
  84933. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  84934. /**
  84935. * Creates a video texture straight from your WebCam video feed.
  84936. * @param scene Define the scene the texture should be created in
  84937. * @param onReady Define a callback to triggered once the texture will be ready
  84938. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  84939. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  84940. */
  84941. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  84942. minWidth: number;
  84943. maxWidth: number;
  84944. minHeight: number;
  84945. maxHeight: number;
  84946. deviceId: string;
  84947. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  84948. }
  84949. }
  84950. declare module BABYLON {
  84951. /**
  84952. * Interface for attribute information associated with buffer instanciation
  84953. */
  84954. export class InstancingAttributeInfo {
  84955. /**
  84956. * Index/offset of the attribute in the vertex shader
  84957. */
  84958. index: number;
  84959. /**
  84960. * size of the attribute, 1, 2, 3 or 4
  84961. */
  84962. attributeSize: number;
  84963. /**
  84964. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  84965. * default is FLOAT
  84966. */
  84967. attribyteType: number;
  84968. /**
  84969. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  84970. */
  84971. normalized: boolean;
  84972. /**
  84973. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  84974. */
  84975. offset: number;
  84976. /**
  84977. * Name of the GLSL attribute, for debugging purpose only
  84978. */
  84979. attributeName: string;
  84980. }
  84981. /**
  84982. * Define options used to create a depth texture
  84983. */
  84984. export class DepthTextureCreationOptions {
  84985. /** Specifies whether or not a stencil should be allocated in the texture */
  84986. generateStencil?: boolean;
  84987. /** Specifies whether or not bilinear filtering is enable on the texture */
  84988. bilinearFiltering?: boolean;
  84989. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  84990. comparisonFunction?: number;
  84991. /** Specifies if the created texture is a cube texture */
  84992. isCube?: boolean;
  84993. }
  84994. /**
  84995. * Class used to describe the capabilities of the engine relatively to the current browser
  84996. */
  84997. export class EngineCapabilities {
  84998. /** Maximum textures units per fragment shader */
  84999. maxTexturesImageUnits: number;
  85000. /** Maximum texture units per vertex shader */
  85001. maxVertexTextureImageUnits: number;
  85002. /** Maximum textures units in the entire pipeline */
  85003. maxCombinedTexturesImageUnits: number;
  85004. /** Maximum texture size */
  85005. maxTextureSize: number;
  85006. /** Maximum cube texture size */
  85007. maxCubemapTextureSize: number;
  85008. /** Maximum render texture size */
  85009. maxRenderTextureSize: number;
  85010. /** Maximum number of vertex attributes */
  85011. maxVertexAttribs: number;
  85012. /** Maximum number of varyings */
  85013. maxVaryingVectors: number;
  85014. /** Maximum number of uniforms per vertex shader */
  85015. maxVertexUniformVectors: number;
  85016. /** Maximum number of uniforms per fragment shader */
  85017. maxFragmentUniformVectors: number;
  85018. /** Defines if standard derivates (dx/dy) are supported */
  85019. standardDerivatives: boolean;
  85020. /** Defines if s3tc texture compression is supported */
  85021. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  85022. /** Defines if pvrtc texture compression is supported */
  85023. pvrtc: any;
  85024. /** Defines if etc1 texture compression is supported */
  85025. etc1: any;
  85026. /** Defines if etc2 texture compression is supported */
  85027. etc2: any;
  85028. /** Defines if astc texture compression is supported */
  85029. astc: any;
  85030. /** Defines if float textures are supported */
  85031. textureFloat: boolean;
  85032. /** Defines if vertex array objects are supported */
  85033. vertexArrayObject: boolean;
  85034. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  85035. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  85036. /** Gets the maximum level of anisotropy supported */
  85037. maxAnisotropy: number;
  85038. /** Defines if instancing is supported */
  85039. instancedArrays: boolean;
  85040. /** Defines if 32 bits indices are supported */
  85041. uintIndices: boolean;
  85042. /** Defines if high precision shaders are supported */
  85043. highPrecisionShaderSupported: boolean;
  85044. /** Defines if depth reading in the fragment shader is supported */
  85045. fragmentDepthSupported: boolean;
  85046. /** Defines if float texture linear filtering is supported*/
  85047. textureFloatLinearFiltering: boolean;
  85048. /** Defines if rendering to float textures is supported */
  85049. textureFloatRender: boolean;
  85050. /** Defines if half float textures are supported*/
  85051. textureHalfFloat: boolean;
  85052. /** Defines if half float texture linear filtering is supported*/
  85053. textureHalfFloatLinearFiltering: boolean;
  85054. /** Defines if rendering to half float textures is supported */
  85055. textureHalfFloatRender: boolean;
  85056. /** Defines if textureLOD shader command is supported */
  85057. textureLOD: boolean;
  85058. /** Defines if draw buffers extension is supported */
  85059. drawBuffersExtension: boolean;
  85060. /** Defines if depth textures are supported */
  85061. depthTextureExtension: boolean;
  85062. /** Defines if float color buffer are supported */
  85063. colorBufferFloat: boolean;
  85064. /** Gets disjoint timer query extension (null if not supported) */
  85065. timerQuery: EXT_disjoint_timer_query;
  85066. /** Defines if timestamp can be used with timer query */
  85067. canUseTimestampForTimerQuery: boolean;
  85068. /** Function used to let the system compiles shaders in background */
  85069. parallelShaderCompile: {
  85070. COMPLETION_STATUS_KHR: number;
  85071. };
  85072. }
  85073. /** Interface defining initialization parameters for Engine class */
  85074. export interface EngineOptions extends WebGLContextAttributes {
  85075. /**
  85076. * Defines if the engine should no exceed a specified device ratio
  85077. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  85078. */
  85079. limitDeviceRatio?: number;
  85080. /**
  85081. * Defines if webvr should be enabled automatically
  85082. * @see http://doc.babylonjs.com/how_to/webvr_camera
  85083. */
  85084. autoEnableWebVR?: boolean;
  85085. /**
  85086. * Defines if webgl2 should be turned off even if supported
  85087. * @see http://doc.babylonjs.com/features/webgl2
  85088. */
  85089. disableWebGL2Support?: boolean;
  85090. /**
  85091. * Defines if webaudio should be initialized as well
  85092. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85093. */
  85094. audioEngine?: boolean;
  85095. /**
  85096. * Defines if animations should run using a deterministic lock step
  85097. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  85098. */
  85099. deterministicLockstep?: boolean;
  85100. /** Defines the maximum steps to use with deterministic lock step mode */
  85101. lockstepMaxSteps?: number;
  85102. /**
  85103. * Defines that engine should ignore context lost events
  85104. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  85105. */
  85106. doNotHandleContextLost?: boolean;
  85107. /**
  85108. * Defines that engine should ignore modifying touch action attribute and style
  85109. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  85110. */
  85111. doNotHandleTouchAction?: boolean;
  85112. /**
  85113. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  85114. */
  85115. useHighPrecisionFloats?: boolean;
  85116. }
  85117. /**
  85118. * Defines the interface used by display changed events
  85119. */
  85120. export interface IDisplayChangedEventArgs {
  85121. /** Gets the vrDisplay object (if any) */
  85122. vrDisplay: Nullable<any>;
  85123. /** Gets a boolean indicating if webVR is supported */
  85124. vrSupported: boolean;
  85125. }
  85126. /**
  85127. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  85128. */
  85129. export class Engine {
  85130. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  85131. static ExceptionList: ({
  85132. key: string;
  85133. capture: string;
  85134. captureConstraint: number;
  85135. targets: string[];
  85136. } | {
  85137. key: string;
  85138. capture: null;
  85139. captureConstraint: null;
  85140. targets: string[];
  85141. })[];
  85142. /** Gets the list of created engines */
  85143. static readonly Instances: Engine[];
  85144. /**
  85145. * Gets the latest created engine
  85146. */
  85147. static readonly LastCreatedEngine: Nullable<Engine>;
  85148. /**
  85149. * Gets the latest created scene
  85150. */
  85151. static readonly LastCreatedScene: Nullable<Scene>;
  85152. /**
  85153. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  85154. * @param flag defines which part of the materials must be marked as dirty
  85155. * @param predicate defines a predicate used to filter which materials should be affected
  85156. */
  85157. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  85158. /**
  85159. * Hidden
  85160. */
  85161. static _TextureLoaders: IInternalTextureLoader[];
  85162. /** Defines that alpha blending is disabled */
  85163. static readonly ALPHA_DISABLE: number;
  85164. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  85165. static readonly ALPHA_ADD: number;
  85166. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  85167. static readonly ALPHA_COMBINE: number;
  85168. /** Defines that alpha blending to DEST - SRC * DEST */
  85169. static readonly ALPHA_SUBTRACT: number;
  85170. /** Defines that alpha blending to SRC * DEST */
  85171. static readonly ALPHA_MULTIPLY: number;
  85172. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  85173. static readonly ALPHA_MAXIMIZED: number;
  85174. /** Defines that alpha blending to SRC + DEST */
  85175. static readonly ALPHA_ONEONE: number;
  85176. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  85177. static readonly ALPHA_PREMULTIPLIED: number;
  85178. /**
  85179. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  85180. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  85181. */
  85182. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  85183. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  85184. static readonly ALPHA_INTERPOLATE: number;
  85185. /**
  85186. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  85187. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  85188. */
  85189. static readonly ALPHA_SCREENMODE: number;
  85190. /** Defines that the ressource is not delayed*/
  85191. static readonly DELAYLOADSTATE_NONE: number;
  85192. /** Defines that the ressource was successfully delay loaded */
  85193. static readonly DELAYLOADSTATE_LOADED: number;
  85194. /** Defines that the ressource is currently delay loading */
  85195. static readonly DELAYLOADSTATE_LOADING: number;
  85196. /** Defines that the ressource is delayed and has not started loading */
  85197. static readonly DELAYLOADSTATE_NOTLOADED: number;
  85198. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  85199. static readonly NEVER: number;
  85200. /** 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 */
  85201. static readonly ALWAYS: number;
  85202. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  85203. static readonly LESS: number;
  85204. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  85205. static readonly EQUAL: number;
  85206. /** 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 */
  85207. static readonly LEQUAL: number;
  85208. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  85209. static readonly GREATER: number;
  85210. /** 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 */
  85211. static readonly GEQUAL: number;
  85212. /** 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 */
  85213. static readonly NOTEQUAL: number;
  85214. /** Passed to stencilOperation to specify that stencil value must be kept */
  85215. static readonly KEEP: number;
  85216. /** Passed to stencilOperation to specify that stencil value must be replaced */
  85217. static readonly REPLACE: number;
  85218. /** Passed to stencilOperation to specify that stencil value must be incremented */
  85219. static readonly INCR: number;
  85220. /** Passed to stencilOperation to specify that stencil value must be decremented */
  85221. static readonly DECR: number;
  85222. /** Passed to stencilOperation to specify that stencil value must be inverted */
  85223. static readonly INVERT: number;
  85224. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  85225. static readonly INCR_WRAP: number;
  85226. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  85227. static readonly DECR_WRAP: number;
  85228. /** Texture is not repeating outside of 0..1 UVs */
  85229. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  85230. /** Texture is repeating outside of 0..1 UVs */
  85231. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  85232. /** Texture is repeating and mirrored */
  85233. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  85234. /** ALPHA */
  85235. static readonly TEXTUREFORMAT_ALPHA: number;
  85236. /** LUMINANCE */
  85237. static readonly TEXTUREFORMAT_LUMINANCE: number;
  85238. /** LUMINANCE_ALPHA */
  85239. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  85240. /** RGB */
  85241. static readonly TEXTUREFORMAT_RGB: number;
  85242. /** RGBA */
  85243. static readonly TEXTUREFORMAT_RGBA: number;
  85244. /** RED */
  85245. static readonly TEXTUREFORMAT_RED: number;
  85246. /** RED (2nd reference) */
  85247. static readonly TEXTUREFORMAT_R: number;
  85248. /** RG */
  85249. static readonly TEXTUREFORMAT_RG: number;
  85250. /** RED_INTEGER */
  85251. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  85252. /** RED_INTEGER (2nd reference) */
  85253. static readonly TEXTUREFORMAT_R_INTEGER: number;
  85254. /** RG_INTEGER */
  85255. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  85256. /** RGB_INTEGER */
  85257. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  85258. /** RGBA_INTEGER */
  85259. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  85260. /** UNSIGNED_BYTE */
  85261. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  85262. /** UNSIGNED_BYTE (2nd reference) */
  85263. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  85264. /** FLOAT */
  85265. static readonly TEXTURETYPE_FLOAT: number;
  85266. /** HALF_FLOAT */
  85267. static readonly TEXTURETYPE_HALF_FLOAT: number;
  85268. /** BYTE */
  85269. static readonly TEXTURETYPE_BYTE: number;
  85270. /** SHORT */
  85271. static readonly TEXTURETYPE_SHORT: number;
  85272. /** UNSIGNED_SHORT */
  85273. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  85274. /** INT */
  85275. static readonly TEXTURETYPE_INT: number;
  85276. /** UNSIGNED_INT */
  85277. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  85278. /** UNSIGNED_SHORT_4_4_4_4 */
  85279. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  85280. /** UNSIGNED_SHORT_5_5_5_1 */
  85281. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  85282. /** UNSIGNED_SHORT_5_6_5 */
  85283. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  85284. /** UNSIGNED_INT_2_10_10_10_REV */
  85285. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  85286. /** UNSIGNED_INT_24_8 */
  85287. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  85288. /** UNSIGNED_INT_10F_11F_11F_REV */
  85289. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  85290. /** UNSIGNED_INT_5_9_9_9_REV */
  85291. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  85292. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  85293. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  85294. /** nearest is mag = nearest and min = nearest and mip = linear */
  85295. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  85296. /** Bilinear is mag = linear and min = linear and mip = nearest */
  85297. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  85298. /** Trilinear is mag = linear and min = linear and mip = linear */
  85299. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  85300. /** nearest is mag = nearest and min = nearest and mip = linear */
  85301. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  85302. /** Bilinear is mag = linear and min = linear and mip = nearest */
  85303. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  85304. /** Trilinear is mag = linear and min = linear and mip = linear */
  85305. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  85306. /** mag = nearest and min = nearest and mip = nearest */
  85307. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  85308. /** mag = nearest and min = linear and mip = nearest */
  85309. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  85310. /** mag = nearest and min = linear and mip = linear */
  85311. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  85312. /** mag = nearest and min = linear and mip = none */
  85313. static readonly TEXTURE_NEAREST_LINEAR: number;
  85314. /** mag = nearest and min = nearest and mip = none */
  85315. static readonly TEXTURE_NEAREST_NEAREST: number;
  85316. /** mag = linear and min = nearest and mip = nearest */
  85317. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  85318. /** mag = linear and min = nearest and mip = linear */
  85319. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  85320. /** mag = linear and min = linear and mip = none */
  85321. static readonly TEXTURE_LINEAR_LINEAR: number;
  85322. /** mag = linear and min = nearest and mip = none */
  85323. static readonly TEXTURE_LINEAR_NEAREST: number;
  85324. /** Explicit coordinates mode */
  85325. static readonly TEXTURE_EXPLICIT_MODE: number;
  85326. /** Spherical coordinates mode */
  85327. static readonly TEXTURE_SPHERICAL_MODE: number;
  85328. /** Planar coordinates mode */
  85329. static readonly TEXTURE_PLANAR_MODE: number;
  85330. /** Cubic coordinates mode */
  85331. static readonly TEXTURE_CUBIC_MODE: number;
  85332. /** Projection coordinates mode */
  85333. static readonly TEXTURE_PROJECTION_MODE: number;
  85334. /** Skybox coordinates mode */
  85335. static readonly TEXTURE_SKYBOX_MODE: number;
  85336. /** Inverse Cubic coordinates mode */
  85337. static readonly TEXTURE_INVCUBIC_MODE: number;
  85338. /** Equirectangular coordinates mode */
  85339. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  85340. /** Equirectangular Fixed coordinates mode */
  85341. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  85342. /** Equirectangular Fixed Mirrored coordinates mode */
  85343. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  85344. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  85345. static readonly SCALEMODE_FLOOR: number;
  85346. /** Defines that texture rescaling will look for the nearest power of 2 size */
  85347. static readonly SCALEMODE_NEAREST: number;
  85348. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  85349. static readonly SCALEMODE_CEILING: number;
  85350. /**
  85351. * Returns the current npm package of the sdk
  85352. */
  85353. static readonly NpmPackage: string;
  85354. /**
  85355. * Returns the current version of the framework
  85356. */
  85357. static readonly Version: string;
  85358. /**
  85359. * Returns a string describing the current engine
  85360. */
  85361. readonly description: string;
  85362. /**
  85363. * Gets or sets the epsilon value used by collision engine
  85364. */
  85365. static CollisionsEpsilon: number;
  85366. /**
  85367. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  85368. */
  85369. static ShadersRepository: string;
  85370. /**
  85371. * Method called to create the default loading screen.
  85372. * This can be overriden in your own app.
  85373. * @param canvas The rendering canvas element
  85374. * @returns The loading screen
  85375. */
  85376. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  85377. /**
  85378. * Method called to create the default rescale post process on each engine.
  85379. */
  85380. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  85381. /**
  85382. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  85383. */
  85384. forcePOTTextures: boolean;
  85385. /**
  85386. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  85387. */
  85388. isFullscreen: boolean;
  85389. /**
  85390. * Gets a boolean indicating if the pointer is currently locked
  85391. */
  85392. isPointerLock: boolean;
  85393. /**
  85394. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  85395. */
  85396. cullBackFaces: boolean;
  85397. /**
  85398. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  85399. */
  85400. renderEvenInBackground: boolean;
  85401. /**
  85402. * Gets or sets a boolean indicating that cache can be kept between frames
  85403. */
  85404. preventCacheWipeBetweenFrames: boolean;
  85405. /**
  85406. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  85407. **/
  85408. enableOfflineSupport: boolean;
  85409. /**
  85410. * 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)
  85411. **/
  85412. disableManifestCheck: boolean;
  85413. /**
  85414. * Gets the list of created scenes
  85415. */
  85416. scenes: Scene[];
  85417. /**
  85418. * Event raised when a new scene is created
  85419. */
  85420. onNewSceneAddedObservable: Observable<Scene>;
  85421. /**
  85422. * Gets the list of created postprocesses
  85423. */
  85424. postProcesses: PostProcess[];
  85425. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  85426. validateShaderPrograms: boolean;
  85427. /**
  85428. * Observable event triggered each time the rendering canvas is resized
  85429. */
  85430. onResizeObservable: Observable<Engine>;
  85431. /**
  85432. * Observable event triggered each time the canvas loses focus
  85433. */
  85434. onCanvasBlurObservable: Observable<Engine>;
  85435. /**
  85436. * Observable event triggered each time the canvas gains focus
  85437. */
  85438. onCanvasFocusObservable: Observable<Engine>;
  85439. /**
  85440. * Observable event triggered each time the canvas receives pointerout event
  85441. */
  85442. onCanvasPointerOutObservable: Observable<PointerEvent>;
  85443. /**
  85444. * Observable event triggered before each texture is initialized
  85445. */
  85446. onBeforeTextureInitObservable: Observable<Texture>;
  85447. private _vrDisplay;
  85448. private _vrSupported;
  85449. private _oldSize;
  85450. private _oldHardwareScaleFactor;
  85451. private _vrExclusivePointerMode;
  85452. private _webVRInitPromise;
  85453. /**
  85454. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  85455. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  85456. */
  85457. readonly isInVRExclusivePointerMode: boolean;
  85458. /**
  85459. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  85460. */
  85461. disableUniformBuffers: boolean;
  85462. /** @hidden */
  85463. _uniformBuffers: UniformBuffer[];
  85464. /**
  85465. * Gets a boolean indicating that the engine supports uniform buffers
  85466. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85467. */
  85468. readonly supportsUniformBuffers: boolean;
  85469. /**
  85470. * Observable raised when the engine begins a new frame
  85471. */
  85472. onBeginFrameObservable: Observable<Engine>;
  85473. /**
  85474. * If set, will be used to request the next animation frame for the render loop
  85475. */
  85476. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  85477. /**
  85478. * Observable raised when the engine ends the current frame
  85479. */
  85480. onEndFrameObservable: Observable<Engine>;
  85481. /**
  85482. * Observable raised when the engine is about to compile a shader
  85483. */
  85484. onBeforeShaderCompilationObservable: Observable<Engine>;
  85485. /**
  85486. * Observable raised when the engine has jsut compiled a shader
  85487. */
  85488. onAfterShaderCompilationObservable: Observable<Engine>;
  85489. /** @hidden */
  85490. _gl: WebGLRenderingContext;
  85491. private _renderingCanvas;
  85492. private _windowIsBackground;
  85493. private _webGLVersion;
  85494. protected _highPrecisionShadersAllowed: boolean;
  85495. /** @hidden */
  85496. readonly _shouldUseHighPrecisionShader: boolean;
  85497. /**
  85498. * Gets a boolean indicating that only power of 2 textures are supported
  85499. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  85500. */
  85501. readonly needPOTTextures: boolean;
  85502. /** @hidden */
  85503. _badOS: boolean;
  85504. /** @hidden */
  85505. _badDesktopOS: boolean;
  85506. /**
  85507. * Gets or sets a value indicating if we want to disable texture binding optimization.
  85508. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  85509. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  85510. */
  85511. disableTextureBindingOptimization: boolean;
  85512. /**
  85513. * Gets the audio engine
  85514. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85515. * @ignorenaming
  85516. */
  85517. static audioEngine: IAudioEngine;
  85518. /**
  85519. * Default AudioEngine factory responsible of creating the Audio Engine.
  85520. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  85521. */
  85522. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  85523. /**
  85524. * Default offline support factory responsible of creating a tool used to store data locally.
  85525. * By default, this will create a Database object if the workload has been embedded.
  85526. */
  85527. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  85528. private _onFocus;
  85529. private _onBlur;
  85530. private _onCanvasPointerOut;
  85531. private _onCanvasBlur;
  85532. private _onCanvasFocus;
  85533. private _onFullscreenChange;
  85534. private _onPointerLockChange;
  85535. private _onVRDisplayPointerRestricted;
  85536. private _onVRDisplayPointerUnrestricted;
  85537. private _onVrDisplayConnect;
  85538. private _onVrDisplayDisconnect;
  85539. private _onVrDisplayPresentChange;
  85540. /**
  85541. * Observable signaled when VR display mode changes
  85542. */
  85543. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  85544. /**
  85545. * Observable signaled when VR request present is complete
  85546. */
  85547. onVRRequestPresentComplete: Observable<boolean>;
  85548. /**
  85549. * Observable signaled when VR request present starts
  85550. */
  85551. onVRRequestPresentStart: Observable<Engine>;
  85552. private _hardwareScalingLevel;
  85553. /** @hidden */
  85554. protected _caps: EngineCapabilities;
  85555. private _pointerLockRequested;
  85556. private _isStencilEnable;
  85557. private _colorWrite;
  85558. private _loadingScreen;
  85559. /** @hidden */
  85560. _drawCalls: PerfCounter;
  85561. /** @hidden */
  85562. _textureCollisions: PerfCounter;
  85563. private _glVersion;
  85564. private _glRenderer;
  85565. private _glVendor;
  85566. private _videoTextureSupported;
  85567. private _renderingQueueLaunched;
  85568. private _activeRenderLoops;
  85569. private _deterministicLockstep;
  85570. private _lockstepMaxSteps;
  85571. /**
  85572. * Observable signaled when a context lost event is raised
  85573. */
  85574. onContextLostObservable: Observable<Engine>;
  85575. /**
  85576. * Observable signaled when a context restored event is raised
  85577. */
  85578. onContextRestoredObservable: Observable<Engine>;
  85579. private _onContextLost;
  85580. private _onContextRestored;
  85581. private _contextWasLost;
  85582. private _doNotHandleContextLost;
  85583. /**
  85584. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  85585. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  85586. */
  85587. doNotHandleContextLost: boolean;
  85588. private _performanceMonitor;
  85589. private _fps;
  85590. private _deltaTime;
  85591. /**
  85592. * Turn this value on if you want to pause FPS computation when in background
  85593. */
  85594. disablePerformanceMonitorInBackground: boolean;
  85595. /**
  85596. * Gets the performance monitor attached to this engine
  85597. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  85598. */
  85599. readonly performanceMonitor: PerformanceMonitor;
  85600. /** @hidden */
  85601. protected _depthCullingState: _DepthCullingState;
  85602. /** @hidden */
  85603. protected _stencilState: _StencilState;
  85604. /** @hidden */
  85605. protected _alphaState: _AlphaState;
  85606. /** @hidden */
  85607. protected _alphaMode: number;
  85608. protected _internalTexturesCache: InternalTexture[];
  85609. /** @hidden */
  85610. protected _activeChannel: number;
  85611. private _currentTextureChannel;
  85612. /** @hidden */
  85613. protected _boundTexturesCache: {
  85614. [key: string]: Nullable<InternalTexture>;
  85615. };
  85616. /** @hidden */
  85617. protected _currentEffect: Nullable<Effect>;
  85618. /** @hidden */
  85619. protected _currentProgram: Nullable<WebGLProgram>;
  85620. private _compiledEffects;
  85621. private _vertexAttribArraysEnabled;
  85622. /** @hidden */
  85623. protected _cachedViewport: Nullable<Viewport>;
  85624. private _cachedVertexArrayObject;
  85625. /** @hidden */
  85626. protected _cachedVertexBuffers: any;
  85627. /** @hidden */
  85628. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  85629. /** @hidden */
  85630. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  85631. /** @hidden */
  85632. protected _currentRenderTarget: Nullable<InternalTexture>;
  85633. private _uintIndicesCurrentlySet;
  85634. private _currentBoundBuffer;
  85635. /** @hidden */
  85636. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  85637. private _currentBufferPointers;
  85638. private _currentInstanceLocations;
  85639. private _currentInstanceBuffers;
  85640. private _textureUnits;
  85641. private _firstBoundInternalTextureTracker;
  85642. private _lastBoundInternalTextureTracker;
  85643. private _workingCanvas;
  85644. private _workingContext;
  85645. private _rescalePostProcess;
  85646. private _dummyFramebuffer;
  85647. private _externalData;
  85648. private _bindedRenderFunction;
  85649. private _vaoRecordInProgress;
  85650. private _mustWipeVertexAttributes;
  85651. private _emptyTexture;
  85652. private _emptyCubeTexture;
  85653. private _emptyTexture3D;
  85654. /** @hidden */
  85655. _frameHandler: number;
  85656. private _nextFreeTextureSlots;
  85657. private _maxSimultaneousTextures;
  85658. private _activeRequests;
  85659. private _texturesSupported;
  85660. private _textureFormatInUse;
  85661. /**
  85662. * Gets the list of texture formats supported
  85663. */
  85664. readonly texturesSupported: Array<string>;
  85665. /**
  85666. * Gets the list of texture formats in use
  85667. */
  85668. readonly textureFormatInUse: Nullable<string>;
  85669. /**
  85670. * Gets the current viewport
  85671. */
  85672. readonly currentViewport: Nullable<Viewport>;
  85673. /**
  85674. * Gets the default empty texture
  85675. */
  85676. readonly emptyTexture: InternalTexture;
  85677. /**
  85678. * Gets the default empty 3D texture
  85679. */
  85680. readonly emptyTexture3D: InternalTexture;
  85681. /**
  85682. * Gets the default empty cube texture
  85683. */
  85684. readonly emptyCubeTexture: InternalTexture;
  85685. /**
  85686. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  85687. */
  85688. readonly premultipliedAlpha: boolean;
  85689. /**
  85690. * Creates a new engine
  85691. * @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
  85692. * @param antialias defines enable antialiasing (default: false)
  85693. * @param options defines further options to be sent to the getContext() function
  85694. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  85695. */
  85696. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  85697. private _disableTouchAction;
  85698. private _rebuildInternalTextures;
  85699. private _rebuildEffects;
  85700. /**
  85701. * Gets a boolean indicating if all created effects are ready
  85702. * @returns true if all effects are ready
  85703. */
  85704. areAllEffectsReady(): boolean;
  85705. private _rebuildBuffers;
  85706. private _initGLContext;
  85707. /**
  85708. * Gets version of the current webGL context
  85709. */
  85710. readonly webGLVersion: number;
  85711. /**
  85712. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  85713. */
  85714. readonly isStencilEnable: boolean;
  85715. private _prepareWorkingCanvas;
  85716. /**
  85717. * Reset the texture cache to empty state
  85718. */
  85719. resetTextureCache(): void;
  85720. /**
  85721. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  85722. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  85723. * @returns true if engine is in deterministic lock step mode
  85724. */
  85725. isDeterministicLockStep(): boolean;
  85726. /**
  85727. * Gets the max steps when engine is running in deterministic lock step
  85728. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  85729. * @returns the max steps
  85730. */
  85731. getLockstepMaxSteps(): number;
  85732. /**
  85733. * Gets an object containing information about the current webGL context
  85734. * @returns an object containing the vender, the renderer and the version of the current webGL context
  85735. */
  85736. getGlInfo(): {
  85737. vendor: string;
  85738. renderer: string;
  85739. version: string;
  85740. };
  85741. /**
  85742. * Gets current aspect ratio
  85743. * @param camera defines the camera to use to get the aspect ratio
  85744. * @param useScreen defines if screen size must be used (or the current render target if any)
  85745. * @returns a number defining the aspect ratio
  85746. */
  85747. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  85748. /**
  85749. * Gets current screen aspect ratio
  85750. * @returns a number defining the aspect ratio
  85751. */
  85752. getScreenAspectRatio(): number;
  85753. /**
  85754. * Gets the current render width
  85755. * @param useScreen defines if screen size must be used (or the current render target if any)
  85756. * @returns a number defining the current render width
  85757. */
  85758. getRenderWidth(useScreen?: boolean): number;
  85759. /**
  85760. * Gets the current render height
  85761. * @param useScreen defines if screen size must be used (or the current render target if any)
  85762. * @returns a number defining the current render height
  85763. */
  85764. getRenderHeight(useScreen?: boolean): number;
  85765. /**
  85766. * Gets the HTML canvas attached with the current webGL context
  85767. * @returns a HTML canvas
  85768. */
  85769. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  85770. /**
  85771. * Gets the client rect of the HTML canvas attached with the current webGL context
  85772. * @returns a client rectanglee
  85773. */
  85774. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  85775. /**
  85776. * Defines the hardware scaling level.
  85777. * By default the hardware scaling level is computed from the window device ratio.
  85778. * 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.
  85779. * @param level defines the level to use
  85780. */
  85781. setHardwareScalingLevel(level: number): void;
  85782. /**
  85783. * Gets the current hardware scaling level.
  85784. * By default the hardware scaling level is computed from the window device ratio.
  85785. * 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.
  85786. * @returns a number indicating the current hardware scaling level
  85787. */
  85788. getHardwareScalingLevel(): number;
  85789. /**
  85790. * Gets the list of loaded textures
  85791. * @returns an array containing all loaded textures
  85792. */
  85793. getLoadedTexturesCache(): InternalTexture[];
  85794. /**
  85795. * Gets the object containing all engine capabilities
  85796. * @returns the EngineCapabilities object
  85797. */
  85798. getCaps(): EngineCapabilities;
  85799. /**
  85800. * Gets the current depth function
  85801. * @returns a number defining the depth function
  85802. */
  85803. getDepthFunction(): Nullable<number>;
  85804. /**
  85805. * Sets the current depth function
  85806. * @param depthFunc defines the function to use
  85807. */
  85808. setDepthFunction(depthFunc: number): void;
  85809. /**
  85810. * Sets the current depth function to GREATER
  85811. */
  85812. setDepthFunctionToGreater(): void;
  85813. /**
  85814. * Sets the current depth function to GEQUAL
  85815. */
  85816. setDepthFunctionToGreaterOrEqual(): void;
  85817. /**
  85818. * Sets the current depth function to LESS
  85819. */
  85820. setDepthFunctionToLess(): void;
  85821. private _cachedStencilBuffer;
  85822. private _cachedStencilFunction;
  85823. private _cachedStencilMask;
  85824. private _cachedStencilOperationPass;
  85825. private _cachedStencilOperationFail;
  85826. private _cachedStencilOperationDepthFail;
  85827. private _cachedStencilReference;
  85828. /**
  85829. * Caches the the state of the stencil buffer
  85830. */
  85831. cacheStencilState(): void;
  85832. /**
  85833. * Restores the state of the stencil buffer
  85834. */
  85835. restoreStencilState(): void;
  85836. /**
  85837. * Sets the current depth function to LEQUAL
  85838. */
  85839. setDepthFunctionToLessOrEqual(): void;
  85840. /**
  85841. * Gets a boolean indicating if stencil buffer is enabled
  85842. * @returns the current stencil buffer state
  85843. */
  85844. getStencilBuffer(): boolean;
  85845. /**
  85846. * Enable or disable the stencil buffer
  85847. * @param enable defines if the stencil buffer must be enabled or disabled
  85848. */
  85849. setStencilBuffer(enable: boolean): void;
  85850. /**
  85851. * Gets the current stencil mask
  85852. * @returns a number defining the new stencil mask to use
  85853. */
  85854. getStencilMask(): number;
  85855. /**
  85856. * Sets the current stencil mask
  85857. * @param mask defines the new stencil mask to use
  85858. */
  85859. setStencilMask(mask: number): void;
  85860. /**
  85861. * Gets the current stencil function
  85862. * @returns a number defining the stencil function to use
  85863. */
  85864. getStencilFunction(): number;
  85865. /**
  85866. * Gets the current stencil reference value
  85867. * @returns a number defining the stencil reference value to use
  85868. */
  85869. getStencilFunctionReference(): number;
  85870. /**
  85871. * Gets the current stencil mask
  85872. * @returns a number defining the stencil mask to use
  85873. */
  85874. getStencilFunctionMask(): number;
  85875. /**
  85876. * Sets the current stencil function
  85877. * @param stencilFunc defines the new stencil function to use
  85878. */
  85879. setStencilFunction(stencilFunc: number): void;
  85880. /**
  85881. * Sets the current stencil reference
  85882. * @param reference defines the new stencil reference to use
  85883. */
  85884. setStencilFunctionReference(reference: number): void;
  85885. /**
  85886. * Sets the current stencil mask
  85887. * @param mask defines the new stencil mask to use
  85888. */
  85889. setStencilFunctionMask(mask: number): void;
  85890. /**
  85891. * Gets the current stencil operation when stencil fails
  85892. * @returns a number defining stencil operation to use when stencil fails
  85893. */
  85894. getStencilOperationFail(): number;
  85895. /**
  85896. * Gets the current stencil operation when depth fails
  85897. * @returns a number defining stencil operation to use when depth fails
  85898. */
  85899. getStencilOperationDepthFail(): number;
  85900. /**
  85901. * Gets the current stencil operation when stencil passes
  85902. * @returns a number defining stencil operation to use when stencil passes
  85903. */
  85904. getStencilOperationPass(): number;
  85905. /**
  85906. * Sets the stencil operation to use when stencil fails
  85907. * @param operation defines the stencil operation to use when stencil fails
  85908. */
  85909. setStencilOperationFail(operation: number): void;
  85910. /**
  85911. * Sets the stencil operation to use when depth fails
  85912. * @param operation defines the stencil operation to use when depth fails
  85913. */
  85914. setStencilOperationDepthFail(operation: number): void;
  85915. /**
  85916. * Sets the stencil operation to use when stencil passes
  85917. * @param operation defines the stencil operation to use when stencil passes
  85918. */
  85919. setStencilOperationPass(operation: number): void;
  85920. /**
  85921. * Sets a boolean indicating if the dithering state is enabled or disabled
  85922. * @param value defines the dithering state
  85923. */
  85924. setDitheringState(value: boolean): void;
  85925. /**
  85926. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  85927. * @param value defines the rasterizer state
  85928. */
  85929. setRasterizerState(value: boolean): void;
  85930. /**
  85931. * stop executing a render loop function and remove it from the execution array
  85932. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  85933. */
  85934. stopRenderLoop(renderFunction?: () => void): void;
  85935. /** @hidden */
  85936. _renderLoop(): void;
  85937. /**
  85938. * Register and execute a render loop. The engine can have more than one render function
  85939. * @param renderFunction defines the function to continuously execute
  85940. */
  85941. runRenderLoop(renderFunction: () => void): void;
  85942. /**
  85943. * Toggle full screen mode
  85944. * @param requestPointerLock defines if a pointer lock should be requested from the user
  85945. */
  85946. switchFullscreen(requestPointerLock: boolean): void;
  85947. /**
  85948. * Enters full screen mode
  85949. * @param requestPointerLock defines if a pointer lock should be requested from the user
  85950. */
  85951. enterFullscreen(requestPointerLock: boolean): void;
  85952. /**
  85953. * Exits full screen mode
  85954. */
  85955. exitFullscreen(): void;
  85956. /**
  85957. * Clear the current render buffer or the current render target (if any is set up)
  85958. * @param color defines the color to use
  85959. * @param backBuffer defines if the back buffer must be cleared
  85960. * @param depth defines if the depth buffer must be cleared
  85961. * @param stencil defines if the stencil buffer must be cleared
  85962. */
  85963. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  85964. /**
  85965. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  85966. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  85967. * @param y defines the y-coordinate of the corner of the clear rectangle
  85968. * @param width defines the width of the clear rectangle
  85969. * @param height defines the height of the clear rectangle
  85970. * @param clearColor defines the clear color
  85971. */
  85972. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  85973. /**
  85974. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  85975. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  85976. * @param y defines the y-coordinate of the corner of the clear rectangle
  85977. * @param width defines the width of the clear rectangle
  85978. * @param height defines the height of the clear rectangle
  85979. */
  85980. enableScissor(x: number, y: number, width: number, height: number): void;
  85981. /**
  85982. * Disable previously set scissor test rectangle
  85983. */
  85984. disableScissor(): void;
  85985. private _viewportCached;
  85986. /** @hidden */
  85987. _viewport(x: number, y: number, width: number, height: number): void;
  85988. /**
  85989. * Set the WebGL's viewport
  85990. * @param viewport defines the viewport element to be used
  85991. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  85992. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  85993. */
  85994. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  85995. /**
  85996. * Directly set the WebGL Viewport
  85997. * @param x defines the x coordinate of the viewport (in screen space)
  85998. * @param y defines the y coordinate of the viewport (in screen space)
  85999. * @param width defines the width of the viewport (in screen space)
  86000. * @param height defines the height of the viewport (in screen space)
  86001. * @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
  86002. */
  86003. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  86004. /**
  86005. * Begin a new frame
  86006. */
  86007. beginFrame(): void;
  86008. /**
  86009. * Enf the current frame
  86010. */
  86011. endFrame(): void;
  86012. /**
  86013. * Resize the view according to the canvas' size
  86014. */
  86015. resize(): void;
  86016. /**
  86017. * Force a specific size of the canvas
  86018. * @param width defines the new canvas' width
  86019. * @param height defines the new canvas' height
  86020. */
  86021. setSize(width: number, height: number): void;
  86022. /**
  86023. * Gets a boolean indicating if a webVR device was detected
  86024. * @returns true if a webVR device was detected
  86025. */
  86026. isVRDevicePresent(): boolean;
  86027. /**
  86028. * Gets the current webVR device
  86029. * @returns the current webVR device (or null)
  86030. */
  86031. getVRDevice(): any;
  86032. /**
  86033. * Initializes a webVR display and starts listening to display change events
  86034. * The onVRDisplayChangedObservable will be notified upon these changes
  86035. * @returns The onVRDisplayChangedObservable
  86036. */
  86037. initWebVR(): Observable<IDisplayChangedEventArgs>;
  86038. /**
  86039. * Initializes a webVR display and starts listening to display change events
  86040. * The onVRDisplayChangedObservable will be notified upon these changes
  86041. * @returns A promise containing a VRDisplay and if vr is supported
  86042. */
  86043. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  86044. /**
  86045. * Call this function to switch to webVR mode
  86046. * Will do nothing if webVR is not supported or if there is no webVR device
  86047. * @see http://doc.babylonjs.com/how_to/webvr_camera
  86048. */
  86049. enableVR(): void;
  86050. /**
  86051. * Call this function to leave webVR mode
  86052. * Will do nothing if webVR is not supported or if there is no webVR device
  86053. * @see http://doc.babylonjs.com/how_to/webvr_camera
  86054. */
  86055. disableVR(): void;
  86056. private _onVRFullScreenTriggered;
  86057. private _getVRDisplaysAsync;
  86058. /**
  86059. * Binds the frame buffer to the specified texture.
  86060. * @param texture The texture to render to or null for the default canvas
  86061. * @param faceIndex The face of the texture to render to in case of cube texture
  86062. * @param requiredWidth The width of the target to render to
  86063. * @param requiredHeight The height of the target to render to
  86064. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  86065. * @param depthStencilTexture The depth stencil texture to use to render
  86066. * @param lodLevel defines le lod level to bind to the frame buffer
  86067. */
  86068. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  86069. private bindUnboundFramebuffer;
  86070. /**
  86071. * Unbind the current render target texture from the webGL context
  86072. * @param texture defines the render target texture to unbind
  86073. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  86074. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  86075. */
  86076. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  86077. /**
  86078. * Unbind a list of render target textures from the webGL context
  86079. * This is used only when drawBuffer extension or webGL2 are active
  86080. * @param textures defines the render target textures to unbind
  86081. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  86082. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  86083. */
  86084. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  86085. /**
  86086. * Force the mipmap generation for the given render target texture
  86087. * @param texture defines the render target texture to use
  86088. */
  86089. generateMipMapsForCubemap(texture: InternalTexture): void;
  86090. /**
  86091. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  86092. */
  86093. flushFramebuffer(): void;
  86094. /**
  86095. * Unbind the current render target and bind the default framebuffer
  86096. */
  86097. restoreDefaultFramebuffer(): void;
  86098. /**
  86099. * Create an uniform buffer
  86100. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86101. * @param elements defines the content of the uniform buffer
  86102. * @returns the webGL uniform buffer
  86103. */
  86104. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  86105. /**
  86106. * Create a dynamic uniform buffer
  86107. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86108. * @param elements defines the content of the uniform buffer
  86109. * @returns the webGL uniform buffer
  86110. */
  86111. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  86112. /**
  86113. * Update an existing uniform buffer
  86114. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86115. * @param uniformBuffer defines the target uniform buffer
  86116. * @param elements defines the content to update
  86117. * @param offset defines the offset in the uniform buffer where update should start
  86118. * @param count defines the size of the data to update
  86119. */
  86120. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  86121. private _resetVertexBufferBinding;
  86122. /**
  86123. * Creates a vertex buffer
  86124. * @param data the data for the vertex buffer
  86125. * @returns the new WebGL static buffer
  86126. */
  86127. createVertexBuffer(data: DataArray): WebGLBuffer;
  86128. /**
  86129. * Creates a dynamic vertex buffer
  86130. * @param data the data for the dynamic vertex buffer
  86131. * @returns the new WebGL dynamic buffer
  86132. */
  86133. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  86134. /**
  86135. * Update a dynamic index buffer
  86136. * @param indexBuffer defines the target index buffer
  86137. * @param indices defines the data to update
  86138. * @param offset defines the offset in the target index buffer where update should start
  86139. */
  86140. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  86141. /**
  86142. * Updates a dynamic vertex buffer.
  86143. * @param vertexBuffer the vertex buffer to update
  86144. * @param data the data used to update the vertex buffer
  86145. * @param byteOffset the byte offset of the data
  86146. * @param byteLength the byte length of the data
  86147. */
  86148. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  86149. private _resetIndexBufferBinding;
  86150. /**
  86151. * Creates a new index buffer
  86152. * @param indices defines the content of the index buffer
  86153. * @param updatable defines if the index buffer must be updatable
  86154. * @returns a new webGL buffer
  86155. */
  86156. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  86157. /**
  86158. * Bind a webGL buffer to the webGL context
  86159. * @param buffer defines the buffer to bind
  86160. */
  86161. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  86162. /**
  86163. * Bind an uniform buffer to the current webGL context
  86164. * @param buffer defines the buffer to bind
  86165. */
  86166. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  86167. /**
  86168. * Bind a buffer to the current webGL context at a given location
  86169. * @param buffer defines the buffer to bind
  86170. * @param location defines the index where to bind the buffer
  86171. */
  86172. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  86173. /**
  86174. * Bind a specific block at a given index in a specific shader program
  86175. * @param shaderProgram defines the shader program
  86176. * @param blockName defines the block name
  86177. * @param index defines the index where to bind the block
  86178. */
  86179. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  86180. private bindIndexBuffer;
  86181. private bindBuffer;
  86182. /**
  86183. * update the bound buffer with the given data
  86184. * @param data defines the data to update
  86185. */
  86186. updateArrayBuffer(data: Float32Array): void;
  86187. private _vertexAttribPointer;
  86188. private _bindIndexBufferWithCache;
  86189. private _bindVertexBuffersAttributes;
  86190. /**
  86191. * Records a vertex array object
  86192. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  86193. * @param vertexBuffers defines the list of vertex buffers to store
  86194. * @param indexBuffer defines the index buffer to store
  86195. * @param effect defines the effect to store
  86196. * @returns the new vertex array object
  86197. */
  86198. recordVertexArrayObject(vertexBuffers: {
  86199. [key: string]: VertexBuffer;
  86200. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  86201. /**
  86202. * Bind a specific vertex array object
  86203. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  86204. * @param vertexArrayObject defines the vertex array object to bind
  86205. * @param indexBuffer defines the index buffer to bind
  86206. */
  86207. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  86208. /**
  86209. * Bind webGl buffers directly to the webGL context
  86210. * @param vertexBuffer defines the vertex buffer to bind
  86211. * @param indexBuffer defines the index buffer to bind
  86212. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  86213. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  86214. * @param effect defines the effect associated with the vertex buffer
  86215. */
  86216. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  86217. private _unbindVertexArrayObject;
  86218. /**
  86219. * Bind a list of vertex buffers to the webGL context
  86220. * @param vertexBuffers defines the list of vertex buffers to bind
  86221. * @param indexBuffer defines the index buffer to bind
  86222. * @param effect defines the effect associated with the vertex buffers
  86223. */
  86224. bindBuffers(vertexBuffers: {
  86225. [key: string]: Nullable<VertexBuffer>;
  86226. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  86227. /**
  86228. * Unbind all instance attributes
  86229. */
  86230. unbindInstanceAttributes(): void;
  86231. /**
  86232. * Release and free the memory of a vertex array object
  86233. * @param vao defines the vertex array object to delete
  86234. */
  86235. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  86236. /** @hidden */
  86237. _releaseBuffer(buffer: WebGLBuffer): boolean;
  86238. /**
  86239. * Creates a webGL buffer to use with instanciation
  86240. * @param capacity defines the size of the buffer
  86241. * @returns the webGL buffer
  86242. */
  86243. createInstancesBuffer(capacity: number): WebGLBuffer;
  86244. /**
  86245. * Delete a webGL buffer used with instanciation
  86246. * @param buffer defines the webGL buffer to delete
  86247. */
  86248. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  86249. /**
  86250. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  86251. * @param instancesBuffer defines the webGL buffer to update and bind
  86252. * @param data defines the data to store in the buffer
  86253. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  86254. */
  86255. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  86256. /**
  86257. * Apply all cached states (depth, culling, stencil and alpha)
  86258. */
  86259. applyStates(): void;
  86260. /**
  86261. * Send a draw order
  86262. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  86263. * @param indexStart defines the starting index
  86264. * @param indexCount defines the number of index to draw
  86265. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  86266. */
  86267. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  86268. /**
  86269. * Draw a list of points
  86270. * @param verticesStart defines the index of first vertex to draw
  86271. * @param verticesCount defines the count of vertices to draw
  86272. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  86273. */
  86274. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  86275. /**
  86276. * Draw a list of unindexed primitives
  86277. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  86278. * @param verticesStart defines the index of first vertex to draw
  86279. * @param verticesCount defines the count of vertices to draw
  86280. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  86281. */
  86282. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  86283. /**
  86284. * Draw a list of indexed primitives
  86285. * @param fillMode defines the primitive to use
  86286. * @param indexStart defines the starting index
  86287. * @param indexCount defines the number of index to draw
  86288. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  86289. */
  86290. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  86291. /**
  86292. * Draw a list of unindexed primitives
  86293. * @param fillMode defines the primitive to use
  86294. * @param verticesStart defines the index of first vertex to draw
  86295. * @param verticesCount defines the count of vertices to draw
  86296. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  86297. */
  86298. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  86299. private _drawMode;
  86300. /** @hidden */
  86301. _releaseEffect(effect: Effect): void;
  86302. /** @hidden */
  86303. _deleteProgram(program: WebGLProgram): void;
  86304. /**
  86305. * Create a new effect (used to store vertex/fragment shaders)
  86306. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  86307. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  86308. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  86309. * @param samplers defines an array of string used to represent textures
  86310. * @param defines defines the string containing the defines to use to compile the shaders
  86311. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  86312. * @param onCompiled defines a function to call when the effect creation is successful
  86313. * @param onError defines a function to call when the effect creation has failed
  86314. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  86315. * @returns the new Effect
  86316. */
  86317. 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;
  86318. private _compileShader;
  86319. private _compileRawShader;
  86320. /**
  86321. * Directly creates a webGL program
  86322. * @param vertexCode defines the vertex shader code to use
  86323. * @param fragmentCode defines the fragment shader code to use
  86324. * @param context defines the webGL context to use (if not set, the current one will be used)
  86325. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  86326. * @returns the new webGL program
  86327. */
  86328. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  86329. /**
  86330. * Creates a webGL program
  86331. * @param vertexCode defines the vertex shader code to use
  86332. * @param fragmentCode defines the fragment shader code to use
  86333. * @param defines defines the string containing the defines to use to compile the shaders
  86334. * @param context defines the webGL context to use (if not set, the current one will be used)
  86335. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  86336. * @returns the new webGL program
  86337. */
  86338. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  86339. private _createShaderProgram;
  86340. private _finalizeProgram;
  86341. /** @hidden */
  86342. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  86343. /** @hidden */
  86344. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  86345. /**
  86346. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  86347. * @param shaderProgram defines the webGL program to use
  86348. * @param uniformsNames defines the list of uniform names
  86349. * @returns an array of webGL uniform locations
  86350. */
  86351. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  86352. /**
  86353. * Gets the lsit of active attributes for a given webGL program
  86354. * @param shaderProgram defines the webGL program to use
  86355. * @param attributesNames defines the list of attribute names to get
  86356. * @returns an array of indices indicating the offset of each attribute
  86357. */
  86358. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  86359. /**
  86360. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  86361. * @param effect defines the effect to activate
  86362. */
  86363. enableEffect(effect: Nullable<Effect>): void;
  86364. /**
  86365. * Set the value of an uniform to an array of int32
  86366. * @param uniform defines the webGL uniform location where to store the value
  86367. * @param array defines the array of int32 to store
  86368. */
  86369. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  86370. /**
  86371. * Set the value of an uniform to an array of int32 (stored as vec2)
  86372. * @param uniform defines the webGL uniform location where to store the value
  86373. * @param array defines the array of int32 to store
  86374. */
  86375. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  86376. /**
  86377. * Set the value of an uniform to an array of int32 (stored as vec3)
  86378. * @param uniform defines the webGL uniform location where to store the value
  86379. * @param array defines the array of int32 to store
  86380. */
  86381. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  86382. /**
  86383. * Set the value of an uniform to an array of int32 (stored as vec4)
  86384. * @param uniform defines the webGL uniform location where to store the value
  86385. * @param array defines the array of int32 to store
  86386. */
  86387. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  86388. /**
  86389. * Set the value of an uniform to an array of float32
  86390. * @param uniform defines the webGL uniform location where to store the value
  86391. * @param array defines the array of float32 to store
  86392. */
  86393. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  86394. /**
  86395. * Set the value of an uniform to an array of float32 (stored as vec2)
  86396. * @param uniform defines the webGL uniform location where to store the value
  86397. * @param array defines the array of float32 to store
  86398. */
  86399. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  86400. /**
  86401. * Set the value of an uniform to an array of float32 (stored as vec3)
  86402. * @param uniform defines the webGL uniform location where to store the value
  86403. * @param array defines the array of float32 to store
  86404. */
  86405. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  86406. /**
  86407. * Set the value of an uniform to an array of float32 (stored as vec4)
  86408. * @param uniform defines the webGL uniform location where to store the value
  86409. * @param array defines the array of float32 to store
  86410. */
  86411. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  86412. /**
  86413. * Set the value of an uniform to an array of number
  86414. * @param uniform defines the webGL uniform location where to store the value
  86415. * @param array defines the array of number to store
  86416. */
  86417. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  86418. /**
  86419. * Set the value of an uniform to an array of number (stored as vec2)
  86420. * @param uniform defines the webGL uniform location where to store the value
  86421. * @param array defines the array of number to store
  86422. */
  86423. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  86424. /**
  86425. * Set the value of an uniform to an array of number (stored as vec3)
  86426. * @param uniform defines the webGL uniform location where to store the value
  86427. * @param array defines the array of number to store
  86428. */
  86429. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  86430. /**
  86431. * Set the value of an uniform to an array of number (stored as vec4)
  86432. * @param uniform defines the webGL uniform location where to store the value
  86433. * @param array defines the array of number to store
  86434. */
  86435. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  86436. /**
  86437. * Set the value of an uniform to an array of float32 (stored as matrices)
  86438. * @param uniform defines the webGL uniform location where to store the value
  86439. * @param matrices defines the array of float32 to store
  86440. */
  86441. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  86442. /**
  86443. * Set the value of an uniform to a matrix
  86444. * @param uniform defines the webGL uniform location where to store the value
  86445. * @param matrix defines the matrix to store
  86446. */
  86447. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  86448. /**
  86449. * Set the value of an uniform to a matrix (3x3)
  86450. * @param uniform defines the webGL uniform location where to store the value
  86451. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  86452. */
  86453. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  86454. /**
  86455. * Set the value of an uniform to a matrix (2x2)
  86456. * @param uniform defines the webGL uniform location where to store the value
  86457. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  86458. */
  86459. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  86460. /**
  86461. * Set the value of an uniform to a number (int)
  86462. * @param uniform defines the webGL uniform location where to store the value
  86463. * @param value defines the int number to store
  86464. */
  86465. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  86466. /**
  86467. * Set the value of an uniform to a number (float)
  86468. * @param uniform defines the webGL uniform location where to store the value
  86469. * @param value defines the float number to store
  86470. */
  86471. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  86472. /**
  86473. * Set the value of an uniform to a vec2
  86474. * @param uniform defines the webGL uniform location where to store the value
  86475. * @param x defines the 1st component of the value
  86476. * @param y defines the 2nd component of the value
  86477. */
  86478. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  86479. /**
  86480. * Set the value of an uniform to a vec3
  86481. * @param uniform defines the webGL uniform location where to store the value
  86482. * @param x defines the 1st component of the value
  86483. * @param y defines the 2nd component of the value
  86484. * @param z defines the 3rd component of the value
  86485. */
  86486. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  86487. /**
  86488. * Set the value of an uniform to a boolean
  86489. * @param uniform defines the webGL uniform location where to store the value
  86490. * @param bool defines the boolean to store
  86491. */
  86492. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  86493. /**
  86494. * Set the value of an uniform to a vec4
  86495. * @param uniform defines the webGL uniform location where to store the value
  86496. * @param x defines the 1st component of the value
  86497. * @param y defines the 2nd component of the value
  86498. * @param z defines the 3rd component of the value
  86499. * @param w defines the 4th component of the value
  86500. */
  86501. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  86502. /**
  86503. * Set the value of an uniform to a Color3
  86504. * @param uniform defines the webGL uniform location where to store the value
  86505. * @param color3 defines the color to store
  86506. */
  86507. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  86508. /**
  86509. * Set the value of an uniform to a Color3 and an alpha value
  86510. * @param uniform defines the webGL uniform location where to store the value
  86511. * @param color3 defines the color to store
  86512. * @param alpha defines the alpha component to store
  86513. */
  86514. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  86515. /**
  86516. * Sets a Color4 on a uniform variable
  86517. * @param uniform defines the uniform location
  86518. * @param color4 defines the value to be set
  86519. */
  86520. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  86521. /**
  86522. * Set various states to the webGL context
  86523. * @param culling defines backface culling state
  86524. * @param zOffset defines the value to apply to zOffset (0 by default)
  86525. * @param force defines if states must be applied even if cache is up to date
  86526. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  86527. */
  86528. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  86529. /**
  86530. * Set the z offset to apply to current rendering
  86531. * @param value defines the offset to apply
  86532. */
  86533. setZOffset(value: number): void;
  86534. /**
  86535. * Gets the current value of the zOffset
  86536. * @returns the current zOffset state
  86537. */
  86538. getZOffset(): number;
  86539. /**
  86540. * Enable or disable depth buffering
  86541. * @param enable defines the state to set
  86542. */
  86543. setDepthBuffer(enable: boolean): void;
  86544. /**
  86545. * Gets a boolean indicating if depth writing is enabled
  86546. * @returns the current depth writing state
  86547. */
  86548. getDepthWrite(): boolean;
  86549. /**
  86550. * Enable or disable depth writing
  86551. * @param enable defines the state to set
  86552. */
  86553. setDepthWrite(enable: boolean): void;
  86554. /**
  86555. * Enable or disable color writing
  86556. * @param enable defines the state to set
  86557. */
  86558. setColorWrite(enable: boolean): void;
  86559. /**
  86560. * Gets a boolean indicating if color writing is enabled
  86561. * @returns the current color writing state
  86562. */
  86563. getColorWrite(): boolean;
  86564. /**
  86565. * Sets alpha constants used by some alpha blending modes
  86566. * @param r defines the red component
  86567. * @param g defines the green component
  86568. * @param b defines the blue component
  86569. * @param a defines the alpha component
  86570. */
  86571. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  86572. /**
  86573. * Sets the current alpha mode
  86574. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  86575. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  86576. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  86577. */
  86578. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  86579. /**
  86580. * Gets the current alpha mode
  86581. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  86582. * @returns the current alpha mode
  86583. */
  86584. getAlphaMode(): number;
  86585. /**
  86586. * Clears the list of texture accessible through engine.
  86587. * This can help preventing texture load conflict due to name collision.
  86588. */
  86589. clearInternalTexturesCache(): void;
  86590. /**
  86591. * Force the entire cache to be cleared
  86592. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  86593. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  86594. */
  86595. wipeCaches(bruteForce?: boolean): void;
  86596. /**
  86597. * Set the compressed texture format to use, based on the formats you have, and the formats
  86598. * supported by the hardware / browser.
  86599. *
  86600. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  86601. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  86602. * to API arguments needed to compressed textures. This puts the burden on the container
  86603. * generator to house the arcane code for determining these for current & future formats.
  86604. *
  86605. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  86606. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  86607. *
  86608. * Note: The result of this call is not taken into account when a texture is base64.
  86609. *
  86610. * @param formatsAvailable defines the list of those format families you have created
  86611. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  86612. *
  86613. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  86614. * @returns The extension selected.
  86615. */
  86616. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  86617. private _getSamplingParameters;
  86618. private _partialLoadImg;
  86619. private _cascadeLoadImgs;
  86620. /** @hidden */
  86621. _createTexture(): WebGLTexture;
  86622. /**
  86623. * Usually called from Texture.ts.
  86624. * Passed information to create a WebGLTexture
  86625. * @param urlArg defines a value which contains one of the following:
  86626. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  86627. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  86628. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  86629. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  86630. * @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)
  86631. * @param scene needed for loading to the correct scene
  86632. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  86633. * @param onLoad optional callback to be called upon successful completion
  86634. * @param onError optional callback to be called upon failure
  86635. * @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
  86636. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  86637. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  86638. * @param forcedExtension defines the extension to use to pick the right loader
  86639. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  86640. * @returns a InternalTexture for assignment back into BABYLON.Texture
  86641. */
  86642. 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;
  86643. private _rescaleTexture;
  86644. /**
  86645. * Update a raw texture
  86646. * @param texture defines the texture to update
  86647. * @param data defines the data to store in the texture
  86648. * @param format defines the format of the data
  86649. * @param invertY defines if data must be stored with Y axis inverted
  86650. * @param compression defines the compression used (null by default)
  86651. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86652. */
  86653. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  86654. /**
  86655. * Creates a raw texture
  86656. * @param data defines the data to store in the texture
  86657. * @param width defines the width of the texture
  86658. * @param height defines the height of the texture
  86659. * @param format defines the format of the data
  86660. * @param generateMipMaps defines if the engine should generate the mip levels
  86661. * @param invertY defines if data must be stored with Y axis inverted
  86662. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  86663. * @param compression defines the compression used (null by default)
  86664. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86665. * @returns the raw texture inside an InternalTexture
  86666. */
  86667. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  86668. private _unpackFlipYCached;
  86669. /**
  86670. * In case you are sharing the context with other applications, it might
  86671. * be interested to not cache the unpack flip y state to ensure a consistent
  86672. * value would be set.
  86673. */
  86674. enableUnpackFlipYCached: boolean;
  86675. /** @hidden */
  86676. _unpackFlipY(value: boolean): void;
  86677. /** @hidden */
  86678. _getUnpackAlignement(): number;
  86679. /**
  86680. * Creates a dynamic texture
  86681. * @param width defines the width of the texture
  86682. * @param height defines the height of the texture
  86683. * @param generateMipMaps defines if the engine should generate the mip levels
  86684. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  86685. * @returns the dynamic texture inside an InternalTexture
  86686. */
  86687. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  86688. /**
  86689. * Update the sampling mode of a given texture
  86690. * @param samplingMode defines the required sampling mode
  86691. * @param texture defines the texture to update
  86692. */
  86693. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  86694. /**
  86695. * Update the content of a dynamic texture
  86696. * @param texture defines the texture to update
  86697. * @param canvas defines the canvas containing the source
  86698. * @param invertY defines if data must be stored with Y axis inverted
  86699. * @param premulAlpha defines if alpha is stored as premultiplied
  86700. * @param format defines the format of the data
  86701. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  86702. */
  86703. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  86704. /**
  86705. * Update a video texture
  86706. * @param texture defines the texture to update
  86707. * @param video defines the video element to use
  86708. * @param invertY defines if data must be stored with Y axis inverted
  86709. */
  86710. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  86711. /**
  86712. * Updates a depth texture Comparison Mode and Function.
  86713. * If the comparison Function is equal to 0, the mode will be set to none.
  86714. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  86715. * @param texture The texture to set the comparison function for
  86716. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  86717. */
  86718. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  86719. private _setupDepthStencilTexture;
  86720. /**
  86721. * Creates a depth stencil texture.
  86722. * This is only available in WebGL 2 or with the depth texture extension available.
  86723. * @param size The size of face edge in the texture.
  86724. * @param options The options defining the texture.
  86725. * @returns The texture
  86726. */
  86727. createDepthStencilTexture(size: number | {
  86728. width: number;
  86729. height: number;
  86730. }, options: DepthTextureCreationOptions): InternalTexture;
  86731. /**
  86732. * Creates a depth stencil texture.
  86733. * This is only available in WebGL 2 or with the depth texture extension available.
  86734. * @param size The size of face edge in the texture.
  86735. * @param options The options defining the texture.
  86736. * @returns The texture
  86737. */
  86738. private _createDepthStencilTexture;
  86739. /**
  86740. * Creates a depth stencil cube texture.
  86741. * This is only available in WebGL 2.
  86742. * @param size The size of face edge in the cube texture.
  86743. * @param options The options defining the cube texture.
  86744. * @returns The cube texture
  86745. */
  86746. private _createDepthStencilCubeTexture;
  86747. /**
  86748. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  86749. * @param renderTarget The render target to set the frame buffer for
  86750. */
  86751. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  86752. /**
  86753. * Creates a new render target texture
  86754. * @param size defines the size of the texture
  86755. * @param options defines the options used to create the texture
  86756. * @returns a new render target texture stored in an InternalTexture
  86757. */
  86758. createRenderTargetTexture(size: number | {
  86759. width: number;
  86760. height: number;
  86761. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  86762. /**
  86763. * Create a multi render target texture
  86764. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  86765. * @param size defines the size of the texture
  86766. * @param options defines the creation options
  86767. * @returns the cube texture as an InternalTexture
  86768. */
  86769. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  86770. private _setupFramebufferDepthAttachments;
  86771. /**
  86772. * Updates the sample count of a render target texture
  86773. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  86774. * @param texture defines the texture to update
  86775. * @param samples defines the sample count to set
  86776. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  86777. */
  86778. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  86779. /**
  86780. * Update the sample count for a given multiple render target texture
  86781. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  86782. * @param textures defines the textures to update
  86783. * @param samples defines the sample count to set
  86784. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  86785. */
  86786. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  86787. /** @hidden */
  86788. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  86789. /** @hidden */
  86790. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  86791. /** @hidden */
  86792. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  86793. /** @hidden */
  86794. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  86795. /**
  86796. * Creates a new render target cube texture
  86797. * @param size defines the size of the texture
  86798. * @param options defines the options used to create the texture
  86799. * @returns a new render target cube texture stored in an InternalTexture
  86800. */
  86801. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  86802. /**
  86803. * Creates a cube texture
  86804. * @param rootUrl defines the url where the files to load is located
  86805. * @param scene defines the current scene
  86806. * @param files defines the list of files to load (1 per face)
  86807. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  86808. * @param onLoad defines an optional callback raised when the texture is loaded
  86809. * @param onError defines an optional callback raised if there is an issue to load the texture
  86810. * @param format defines the format of the data
  86811. * @param forcedExtension defines the extension to use to pick the right loader
  86812. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  86813. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  86814. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  86815. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  86816. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  86817. * @returns the cube texture as an InternalTexture
  86818. */
  86819. 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;
  86820. /**
  86821. * @hidden
  86822. */
  86823. _setCubeMapTextureParams(loadMipmap: boolean): void;
  86824. /**
  86825. * Update a raw cube texture
  86826. * @param texture defines the texture to udpdate
  86827. * @param data defines the data to store
  86828. * @param format defines the data format
  86829. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86830. * @param invertY defines if data must be stored with Y axis inverted
  86831. * @param compression defines the compression used (null by default)
  86832. * @param level defines which level of the texture to update
  86833. */
  86834. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  86835. /**
  86836. * Creates a new raw cube texture
  86837. * @param data defines the array of data to use to create each face
  86838. * @param size defines the size of the textures
  86839. * @param format defines the format of the data
  86840. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  86841. * @param generateMipMaps defines if the engine should generate the mip levels
  86842. * @param invertY defines if data must be stored with Y axis inverted
  86843. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  86844. * @param compression defines the compression used (null by default)
  86845. * @returns the cube texture as an InternalTexture
  86846. */
  86847. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  86848. /**
  86849. * Creates a new raw cube texture from a specified url
  86850. * @param url defines the url where the data is located
  86851. * @param scene defines the current scene
  86852. * @param size defines the size of the textures
  86853. * @param format defines the format of the data
  86854. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  86855. * @param noMipmap defines if the engine should avoid generating the mip levels
  86856. * @param callback defines a callback used to extract texture data from loaded data
  86857. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  86858. * @param onLoad defines a callback called when texture is loaded
  86859. * @param onError defines a callback called if there is an error
  86860. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  86861. * @param invertY defines if data must be stored with Y axis inverted
  86862. * @returns the cube texture as an InternalTexture
  86863. */
  86864. 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;
  86865. /**
  86866. * Update a raw 3D texture
  86867. * @param texture defines the texture to update
  86868. * @param data defines the data to store
  86869. * @param format defines the data format
  86870. * @param invertY defines if data must be stored with Y axis inverted
  86871. * @param compression defines the used compression (can be null)
  86872. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  86873. */
  86874. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  86875. /**
  86876. * Creates a new raw 3D texture
  86877. * @param data defines the data used to create the texture
  86878. * @param width defines the width of the texture
  86879. * @param height defines the height of the texture
  86880. * @param depth defines the depth of the texture
  86881. * @param format defines the format of the texture
  86882. * @param generateMipMaps defines if the engine must generate mip levels
  86883. * @param invertY defines if data must be stored with Y axis inverted
  86884. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  86885. * @param compression defines the compressed used (can be null)
  86886. * @param textureType defines the compressed used (can be null)
  86887. * @returns a new raw 3D texture (stored in an InternalTexture)
  86888. */
  86889. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  86890. private _prepareWebGLTextureContinuation;
  86891. private _prepareWebGLTexture;
  86892. private _convertRGBtoRGBATextureData;
  86893. /** @hidden */
  86894. _releaseFramebufferObjects(texture: InternalTexture): void;
  86895. /** @hidden */
  86896. _releaseTexture(texture: InternalTexture): void;
  86897. private setProgram;
  86898. private _boundUniforms;
  86899. /**
  86900. * Binds an effect to the webGL context
  86901. * @param effect defines the effect to bind
  86902. */
  86903. bindSamplers(effect: Effect): void;
  86904. private _moveBoundTextureOnTop;
  86905. private _getCorrectTextureChannel;
  86906. private _linkTrackers;
  86907. private _removeDesignatedSlot;
  86908. private _activateCurrentTexture;
  86909. /** @hidden */
  86910. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  86911. /** @hidden */
  86912. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  86913. /**
  86914. * Sets a texture to the webGL context from a postprocess
  86915. * @param channel defines the channel to use
  86916. * @param postProcess defines the source postprocess
  86917. */
  86918. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  86919. /**
  86920. * Binds the output of the passed in post process to the texture channel specified
  86921. * @param channel The channel the texture should be bound to
  86922. * @param postProcess The post process which's output should be bound
  86923. */
  86924. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  86925. /**
  86926. * Unbind all textures from the webGL context
  86927. */
  86928. unbindAllTextures(): void;
  86929. /**
  86930. * Sets a texture to the according uniform.
  86931. * @param channel The texture channel
  86932. * @param uniform The uniform to set
  86933. * @param texture The texture to apply
  86934. */
  86935. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  86936. /**
  86937. * Sets a depth stencil texture from a render target to the according uniform.
  86938. * @param channel The texture channel
  86939. * @param uniform The uniform to set
  86940. * @param texture The render target texture containing the depth stencil texture to apply
  86941. */
  86942. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  86943. private _bindSamplerUniformToChannel;
  86944. private _getTextureWrapMode;
  86945. private _setTexture;
  86946. /**
  86947. * Sets an array of texture to the webGL context
  86948. * @param channel defines the channel where the texture array must be set
  86949. * @param uniform defines the associated uniform location
  86950. * @param textures defines the array of textures to bind
  86951. */
  86952. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  86953. /** @hidden */
  86954. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  86955. private _setTextureParameterFloat;
  86956. private _setTextureParameterInteger;
  86957. /**
  86958. * Reads pixels from the current frame buffer. Please note that this function can be slow
  86959. * @param x defines the x coordinate of the rectangle where pixels must be read
  86960. * @param y defines the y coordinate of the rectangle where pixels must be read
  86961. * @param width defines the width of the rectangle where pixels must be read
  86962. * @param height defines the height of the rectangle where pixels must be read
  86963. * @returns a Uint8Array containing RGBA colors
  86964. */
  86965. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  86966. /**
  86967. * Add an externaly attached data from its key.
  86968. * This method call will fail and return false, if such key already exists.
  86969. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  86970. * @param key the unique key that identifies the data
  86971. * @param data the data object to associate to the key for this Engine instance
  86972. * @return true if no such key were already present and the data was added successfully, false otherwise
  86973. */
  86974. addExternalData<T>(key: string, data: T): boolean;
  86975. /**
  86976. * Get an externaly attached data from its key
  86977. * @param key the unique key that identifies the data
  86978. * @return the associated data, if present (can be null), or undefined if not present
  86979. */
  86980. getExternalData<T>(key: string): T;
  86981. /**
  86982. * Get an externaly attached data from its key, create it using a factory if it's not already present
  86983. * @param key the unique key that identifies the data
  86984. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  86985. * @return the associated data, can be null if the factory returned null.
  86986. */
  86987. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  86988. /**
  86989. * Remove an externaly attached data from the Engine instance
  86990. * @param key the unique key that identifies the data
  86991. * @return true if the data was successfully removed, false if it doesn't exist
  86992. */
  86993. removeExternalData(key: string): boolean;
  86994. /**
  86995. * Unbind all vertex attributes from the webGL context
  86996. */
  86997. unbindAllAttributes(): void;
  86998. /**
  86999. * 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
  87000. */
  87001. releaseEffects(): void;
  87002. /**
  87003. * Dispose and release all associated resources
  87004. */
  87005. dispose(): void;
  87006. /**
  87007. * Display the loading screen
  87008. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  87009. */
  87010. displayLoadingUI(): void;
  87011. /**
  87012. * Hide the loading screen
  87013. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  87014. */
  87015. hideLoadingUI(): void;
  87016. /**
  87017. * Gets the current loading screen object
  87018. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  87019. */
  87020. /**
  87021. * Sets the current loading screen object
  87022. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  87023. */
  87024. loadingScreen: ILoadingScreen;
  87025. /**
  87026. * Sets the current loading screen text
  87027. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  87028. */
  87029. loadingUIText: string;
  87030. /**
  87031. * Sets the current loading screen background color
  87032. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  87033. */
  87034. loadingUIBackgroundColor: string;
  87035. /**
  87036. * Attach a new callback raised when context lost event is fired
  87037. * @param callback defines the callback to call
  87038. */
  87039. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  87040. /**
  87041. * Attach a new callback raised when context restored event is fired
  87042. * @param callback defines the callback to call
  87043. */
  87044. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  87045. /**
  87046. * Gets the source code of the vertex shader associated with a specific webGL program
  87047. * @param program defines the program to use
  87048. * @returns a string containing the source code of the vertex shader associated with the program
  87049. */
  87050. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  87051. /**
  87052. * Gets the source code of the fragment shader associated with a specific webGL program
  87053. * @param program defines the program to use
  87054. * @returns a string containing the source code of the fragment shader associated with the program
  87055. */
  87056. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  87057. /**
  87058. * Get the current error code of the webGL context
  87059. * @returns the error code
  87060. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  87061. */
  87062. getError(): number;
  87063. /**
  87064. * Gets the current framerate
  87065. * @returns a number representing the framerate
  87066. */
  87067. getFps(): number;
  87068. /**
  87069. * Gets the time spent between current and previous frame
  87070. * @returns a number representing the delta time in ms
  87071. */
  87072. getDeltaTime(): number;
  87073. private _measureFps;
  87074. /** @hidden */
  87075. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  87076. private _canRenderToFloatFramebuffer;
  87077. private _canRenderToHalfFloatFramebuffer;
  87078. private _canRenderToFramebuffer;
  87079. /** @hidden */
  87080. _getWebGLTextureType(type: number): number;
  87081. private _getInternalFormat;
  87082. /** @hidden */
  87083. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  87084. /** @hidden */
  87085. _getRGBAMultiSampleBufferFormat(type: number): number;
  87086. /** @hidden */
  87087. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  87088. /** @hidden */
  87089. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  87090. private _partialLoadFile;
  87091. private _cascadeLoadFiles;
  87092. /**
  87093. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  87094. * @returns true if the engine can be created
  87095. * @ignorenaming
  87096. */
  87097. static isSupported(): boolean;
  87098. }
  87099. }
  87100. declare module BABYLON {
  87101. /**
  87102. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  87103. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  87104. */
  87105. export class EffectFallbacks {
  87106. private _defines;
  87107. private _currentRank;
  87108. private _maxRank;
  87109. private _mesh;
  87110. /**
  87111. * Removes the fallback from the bound mesh.
  87112. */
  87113. unBindMesh(): void;
  87114. /**
  87115. * Adds a fallback on the specified property.
  87116. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  87117. * @param define The name of the define in the shader
  87118. */
  87119. addFallback(rank: number, define: string): void;
  87120. /**
  87121. * Sets the mesh to use CPU skinning when needing to fallback.
  87122. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  87123. * @param mesh The mesh to use the fallbacks.
  87124. */
  87125. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  87126. /**
  87127. * Checks to see if more fallbacks are still availible.
  87128. */
  87129. readonly isMoreFallbacks: boolean;
  87130. /**
  87131. * Removes the defines that shoould be removed when falling back.
  87132. * @param currentDefines defines the current define statements for the shader.
  87133. * @param effect defines the current effect we try to compile
  87134. * @returns The resulting defines with defines of the current rank removed.
  87135. */
  87136. reduce(currentDefines: string, effect: Effect): string;
  87137. }
  87138. /**
  87139. * Options to be used when creating an effect.
  87140. */
  87141. export class EffectCreationOptions {
  87142. /**
  87143. * Atrributes that will be used in the shader.
  87144. */
  87145. attributes: string[];
  87146. /**
  87147. * Uniform varible names that will be set in the shader.
  87148. */
  87149. uniformsNames: string[];
  87150. /**
  87151. * Uniform buffer varible names that will be set in the shader.
  87152. */
  87153. uniformBuffersNames: string[];
  87154. /**
  87155. * Sampler texture variable names that will be set in the shader.
  87156. */
  87157. samplers: string[];
  87158. /**
  87159. * Define statements that will be set in the shader.
  87160. */
  87161. defines: any;
  87162. /**
  87163. * Possible fallbacks for this effect to improve performance when needed.
  87164. */
  87165. fallbacks: Nullable<EffectFallbacks>;
  87166. /**
  87167. * Callback that will be called when the shader is compiled.
  87168. */
  87169. onCompiled: Nullable<(effect: Effect) => void>;
  87170. /**
  87171. * Callback that will be called if an error occurs during shader compilation.
  87172. */
  87173. onError: Nullable<(effect: Effect, errors: string) => void>;
  87174. /**
  87175. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  87176. */
  87177. indexParameters: any;
  87178. /**
  87179. * Max number of lights that can be used in the shader.
  87180. */
  87181. maxSimultaneousLights: number;
  87182. /**
  87183. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  87184. */
  87185. transformFeedbackVaryings: Nullable<string[]>;
  87186. }
  87187. /**
  87188. * Effect containing vertex and fragment shader that can be executed on an object.
  87189. */
  87190. export class Effect {
  87191. /**
  87192. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  87193. */
  87194. static ShadersRepository: string;
  87195. /**
  87196. * Name of the effect.
  87197. */
  87198. name: any;
  87199. /**
  87200. * String container all the define statements that should be set on the shader.
  87201. */
  87202. defines: string;
  87203. /**
  87204. * Callback that will be called when the shader is compiled.
  87205. */
  87206. onCompiled: Nullable<(effect: Effect) => void>;
  87207. /**
  87208. * Callback that will be called if an error occurs during shader compilation.
  87209. */
  87210. onError: Nullable<(effect: Effect, errors: string) => void>;
  87211. /**
  87212. * Callback that will be called when effect is bound.
  87213. */
  87214. onBind: Nullable<(effect: Effect) => void>;
  87215. /**
  87216. * Unique ID of the effect.
  87217. */
  87218. uniqueId: number;
  87219. /**
  87220. * Observable that will be called when the shader is compiled.
  87221. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  87222. */
  87223. onCompileObservable: Observable<Effect>;
  87224. /**
  87225. * Observable that will be called if an error occurs during shader compilation.
  87226. */
  87227. onErrorObservable: Observable<Effect>;
  87228. /** @hidden */
  87229. _onBindObservable: Nullable<Observable<Effect>>;
  87230. /**
  87231. * Observable that will be called when effect is bound.
  87232. */
  87233. readonly onBindObservable: Observable<Effect>;
  87234. /** @hidden */
  87235. _bonesComputationForcedToCPU: boolean;
  87236. private static _uniqueIdSeed;
  87237. private _engine;
  87238. private _uniformBuffersNames;
  87239. private _uniformsNames;
  87240. private _samplers;
  87241. private _isReady;
  87242. private _compilationError;
  87243. private _attributesNames;
  87244. private _attributes;
  87245. private _uniforms;
  87246. /**
  87247. * Key for the effect.
  87248. * @hidden
  87249. */
  87250. _key: string;
  87251. private _indexParameters;
  87252. private _fallbacks;
  87253. private _vertexSourceCode;
  87254. private _fragmentSourceCode;
  87255. private _vertexSourceCodeOverride;
  87256. private _fragmentSourceCodeOverride;
  87257. private _transformFeedbackVaryings;
  87258. /**
  87259. * Compiled shader to webGL program.
  87260. * @hidden
  87261. */
  87262. _program: WebGLProgram;
  87263. private _valueCache;
  87264. private static _baseCache;
  87265. /**
  87266. * Instantiates an effect.
  87267. * An effect can be used to create/manage/execute vertex and fragment shaders.
  87268. * @param baseName Name of the effect.
  87269. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  87270. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  87271. * @param samplers List of sampler variables that will be passed to the shader.
  87272. * @param engine Engine to be used to render the effect
  87273. * @param defines Define statements to be added to the shader.
  87274. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  87275. * @param onCompiled Callback that will be called when the shader is compiled.
  87276. * @param onError Callback that will be called if an error occurs during shader compilation.
  87277. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  87278. */
  87279. 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);
  87280. /**
  87281. * Unique key for this effect
  87282. */
  87283. readonly key: string;
  87284. /**
  87285. * If the effect has been compiled and prepared.
  87286. * @returns if the effect is compiled and prepared.
  87287. */
  87288. isReady(): boolean;
  87289. /**
  87290. * The engine the effect was initialized with.
  87291. * @returns the engine.
  87292. */
  87293. getEngine(): Engine;
  87294. /**
  87295. * The compiled webGL program for the effect
  87296. * @returns the webGL program.
  87297. */
  87298. getProgram(): WebGLProgram;
  87299. /**
  87300. * The set of names of attribute variables for the shader.
  87301. * @returns An array of attribute names.
  87302. */
  87303. getAttributesNames(): string[];
  87304. /**
  87305. * Returns the attribute at the given index.
  87306. * @param index The index of the attribute.
  87307. * @returns The location of the attribute.
  87308. */
  87309. getAttributeLocation(index: number): number;
  87310. /**
  87311. * Returns the attribute based on the name of the variable.
  87312. * @param name of the attribute to look up.
  87313. * @returns the attribute location.
  87314. */
  87315. getAttributeLocationByName(name: string): number;
  87316. /**
  87317. * The number of attributes.
  87318. * @returns the numnber of attributes.
  87319. */
  87320. getAttributesCount(): number;
  87321. /**
  87322. * Gets the index of a uniform variable.
  87323. * @param uniformName of the uniform to look up.
  87324. * @returns the index.
  87325. */
  87326. getUniformIndex(uniformName: string): number;
  87327. /**
  87328. * Returns the attribute based on the name of the variable.
  87329. * @param uniformName of the uniform to look up.
  87330. * @returns the location of the uniform.
  87331. */
  87332. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  87333. /**
  87334. * Returns an array of sampler variable names
  87335. * @returns The array of sampler variable neames.
  87336. */
  87337. getSamplers(): string[];
  87338. /**
  87339. * The error from the last compilation.
  87340. * @returns the error string.
  87341. */
  87342. getCompilationError(): string;
  87343. /**
  87344. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  87345. * @param func The callback to be used.
  87346. */
  87347. executeWhenCompiled(func: (effect: Effect) => void): void;
  87348. private _checkIsReady;
  87349. /** @hidden */
  87350. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  87351. /** @hidden */
  87352. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  87353. /** @hidden */
  87354. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  87355. private _processShaderConversion;
  87356. private _processIncludes;
  87357. private _processPrecision;
  87358. /**
  87359. * Recompiles the webGL program
  87360. * @param vertexSourceCode The source code for the vertex shader.
  87361. * @param fragmentSourceCode The source code for the fragment shader.
  87362. * @param onCompiled Callback called when completed.
  87363. * @param onError Callback called on error.
  87364. * @hidden
  87365. */
  87366. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  87367. /**
  87368. * Gets the uniform locations of the the specified variable names
  87369. * @param names THe names of the variables to lookup.
  87370. * @returns Array of locations in the same order as variable names.
  87371. */
  87372. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  87373. /**
  87374. * Prepares the effect
  87375. * @hidden
  87376. */
  87377. _prepareEffect(): void;
  87378. /**
  87379. * Checks if the effect is supported. (Must be called after compilation)
  87380. */
  87381. readonly isSupported: boolean;
  87382. /**
  87383. * Binds a texture to the engine to be used as output of the shader.
  87384. * @param channel Name of the output variable.
  87385. * @param texture Texture to bind.
  87386. * @hidden
  87387. */
  87388. _bindTexture(channel: string, texture: InternalTexture): void;
  87389. /**
  87390. * Sets a texture on the engine to be used in the shader.
  87391. * @param channel Name of the sampler variable.
  87392. * @param texture Texture to set.
  87393. */
  87394. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  87395. /**
  87396. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  87397. * @param channel Name of the sampler variable.
  87398. * @param texture Texture to set.
  87399. */
  87400. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  87401. /**
  87402. * Sets an array of textures on the engine to be used in the shader.
  87403. * @param channel Name of the variable.
  87404. * @param textures Textures to set.
  87405. */
  87406. setTextureArray(channel: string, textures: BaseTexture[]): void;
  87407. /**
  87408. * 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)
  87409. * @param channel Name of the sampler variable.
  87410. * @param postProcess Post process to get the input texture from.
  87411. */
  87412. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  87413. /**
  87414. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  87415. * 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)
  87416. * @param channel Name of the sampler variable.
  87417. * @param postProcess Post process to get the output texture from.
  87418. */
  87419. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  87420. /** @hidden */
  87421. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  87422. /** @hidden */
  87423. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  87424. /** @hidden */
  87425. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  87426. /** @hidden */
  87427. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  87428. /**
  87429. * Binds a buffer to a uniform.
  87430. * @param buffer Buffer to bind.
  87431. * @param name Name of the uniform variable to bind to.
  87432. */
  87433. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  87434. /**
  87435. * Binds block to a uniform.
  87436. * @param blockName Name of the block to bind.
  87437. * @param index Index to bind.
  87438. */
  87439. bindUniformBlock(blockName: string, index: number): void;
  87440. /**
  87441. * Sets an interger value on a uniform variable.
  87442. * @param uniformName Name of the variable.
  87443. * @param value Value to be set.
  87444. * @returns this effect.
  87445. */
  87446. setInt(uniformName: string, value: number): Effect;
  87447. /**
  87448. * Sets an int array on a uniform variable.
  87449. * @param uniformName Name of the variable.
  87450. * @param array array to be set.
  87451. * @returns this effect.
  87452. */
  87453. setIntArray(uniformName: string, array: Int32Array): Effect;
  87454. /**
  87455. * 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)
  87456. * @param uniformName Name of the variable.
  87457. * @param array array to be set.
  87458. * @returns this effect.
  87459. */
  87460. setIntArray2(uniformName: string, array: Int32Array): Effect;
  87461. /**
  87462. * 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)
  87463. * @param uniformName Name of the variable.
  87464. * @param array array to be set.
  87465. * @returns this effect.
  87466. */
  87467. setIntArray3(uniformName: string, array: Int32Array): Effect;
  87468. /**
  87469. * 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)
  87470. * @param uniformName Name of the variable.
  87471. * @param array array to be set.
  87472. * @returns this effect.
  87473. */
  87474. setIntArray4(uniformName: string, array: Int32Array): Effect;
  87475. /**
  87476. * Sets an float array on a uniform variable.
  87477. * @param uniformName Name of the variable.
  87478. * @param array array to be set.
  87479. * @returns this effect.
  87480. */
  87481. setFloatArray(uniformName: string, array: Float32Array): Effect;
  87482. /**
  87483. * 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)
  87484. * @param uniformName Name of the variable.
  87485. * @param array array to be set.
  87486. * @returns this effect.
  87487. */
  87488. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  87489. /**
  87490. * 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)
  87491. * @param uniformName Name of the variable.
  87492. * @param array array to be set.
  87493. * @returns this effect.
  87494. */
  87495. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  87496. /**
  87497. * 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)
  87498. * @param uniformName Name of the variable.
  87499. * @param array array to be set.
  87500. * @returns this effect.
  87501. */
  87502. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  87503. /**
  87504. * Sets an array on a uniform variable.
  87505. * @param uniformName Name of the variable.
  87506. * @param array array to be set.
  87507. * @returns this effect.
  87508. */
  87509. setArray(uniformName: string, array: number[]): Effect;
  87510. /**
  87511. * 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)
  87512. * @param uniformName Name of the variable.
  87513. * @param array array to be set.
  87514. * @returns this effect.
  87515. */
  87516. setArray2(uniformName: string, array: number[]): Effect;
  87517. /**
  87518. * 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)
  87519. * @param uniformName Name of the variable.
  87520. * @param array array to be set.
  87521. * @returns this effect.
  87522. */
  87523. setArray3(uniformName: string, array: number[]): Effect;
  87524. /**
  87525. * 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)
  87526. * @param uniformName Name of the variable.
  87527. * @param array array to be set.
  87528. * @returns this effect.
  87529. */
  87530. setArray4(uniformName: string, array: number[]): Effect;
  87531. /**
  87532. * Sets matrices on a uniform variable.
  87533. * @param uniformName Name of the variable.
  87534. * @param matrices matrices to be set.
  87535. * @returns this effect.
  87536. */
  87537. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  87538. /**
  87539. * Sets matrix on a uniform variable.
  87540. * @param uniformName Name of the variable.
  87541. * @param matrix matrix to be set.
  87542. * @returns this effect.
  87543. */
  87544. setMatrix(uniformName: string, matrix: Matrix): Effect;
  87545. /**
  87546. * 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)
  87547. * @param uniformName Name of the variable.
  87548. * @param matrix matrix to be set.
  87549. * @returns this effect.
  87550. */
  87551. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  87552. /**
  87553. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  87554. * @param uniformName Name of the variable.
  87555. * @param matrix matrix to be set.
  87556. * @returns this effect.
  87557. */
  87558. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  87559. /**
  87560. * Sets a float on a uniform variable.
  87561. * @param uniformName Name of the variable.
  87562. * @param value value to be set.
  87563. * @returns this effect.
  87564. */
  87565. setFloat(uniformName: string, value: number): Effect;
  87566. /**
  87567. * Sets a boolean on a uniform variable.
  87568. * @param uniformName Name of the variable.
  87569. * @param bool value to be set.
  87570. * @returns this effect.
  87571. */
  87572. setBool(uniformName: string, bool: boolean): Effect;
  87573. /**
  87574. * Sets a Vector2 on a uniform variable.
  87575. * @param uniformName Name of the variable.
  87576. * @param vector2 vector2 to be set.
  87577. * @returns this effect.
  87578. */
  87579. setVector2(uniformName: string, vector2: Vector2): Effect;
  87580. /**
  87581. * Sets a float2 on a uniform variable.
  87582. * @param uniformName Name of the variable.
  87583. * @param x First float in float2.
  87584. * @param y Second float in float2.
  87585. * @returns this effect.
  87586. */
  87587. setFloat2(uniformName: string, x: number, y: number): Effect;
  87588. /**
  87589. * Sets a Vector3 on a uniform variable.
  87590. * @param uniformName Name of the variable.
  87591. * @param vector3 Value to be set.
  87592. * @returns this effect.
  87593. */
  87594. setVector3(uniformName: string, vector3: Vector3): Effect;
  87595. /**
  87596. * Sets a float3 on a uniform variable.
  87597. * @param uniformName Name of the variable.
  87598. * @param x First float in float3.
  87599. * @param y Second float in float3.
  87600. * @param z Third float in float3.
  87601. * @returns this effect.
  87602. */
  87603. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  87604. /**
  87605. * Sets a Vector4 on a uniform variable.
  87606. * @param uniformName Name of the variable.
  87607. * @param vector4 Value to be set.
  87608. * @returns this effect.
  87609. */
  87610. setVector4(uniformName: string, vector4: Vector4): Effect;
  87611. /**
  87612. * Sets a float4 on a uniform variable.
  87613. * @param uniformName Name of the variable.
  87614. * @param x First float in float4.
  87615. * @param y Second float in float4.
  87616. * @param z Third float in float4.
  87617. * @param w Fourth float in float4.
  87618. * @returns this effect.
  87619. */
  87620. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  87621. /**
  87622. * Sets a Color3 on a uniform variable.
  87623. * @param uniformName Name of the variable.
  87624. * @param color3 Value to be set.
  87625. * @returns this effect.
  87626. */
  87627. setColor3(uniformName: string, color3: Color3): Effect;
  87628. /**
  87629. * Sets a Color4 on a uniform variable.
  87630. * @param uniformName Name of the variable.
  87631. * @param color3 Value to be set.
  87632. * @param alpha Alpha value to be set.
  87633. * @returns this effect.
  87634. */
  87635. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  87636. /**
  87637. * Sets a Color4 on a uniform variable
  87638. * @param uniformName defines the name of the variable
  87639. * @param color4 defines the value to be set
  87640. * @returns this effect.
  87641. */
  87642. setDirectColor4(uniformName: string, color4: Color4): Effect;
  87643. /**
  87644. * This function will add a new shader to the shader store
  87645. * @param name the name of the shader
  87646. * @param pixelShader optional pixel shader content
  87647. * @param vertexShader optional vertex shader content
  87648. */
  87649. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  87650. /**
  87651. * Store of each shader (The can be looked up using effect.key)
  87652. */
  87653. static ShadersStore: {
  87654. [key: string]: string;
  87655. };
  87656. /**
  87657. * Store of each included file for a shader (The can be looked up using effect.key)
  87658. */
  87659. static IncludesShadersStore: {
  87660. [key: string]: string;
  87661. };
  87662. /**
  87663. * Resets the cache of effects.
  87664. */
  87665. static ResetCache(): void;
  87666. }
  87667. }
  87668. declare module BABYLON {
  87669. /**
  87670. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  87671. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  87672. * 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;
  87673. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  87674. */
  87675. export class ColorCurves {
  87676. private _dirty;
  87677. private _tempColor;
  87678. private _globalCurve;
  87679. private _highlightsCurve;
  87680. private _midtonesCurve;
  87681. private _shadowsCurve;
  87682. private _positiveCurve;
  87683. private _negativeCurve;
  87684. private _globalHue;
  87685. private _globalDensity;
  87686. private _globalSaturation;
  87687. private _globalExposure;
  87688. /**
  87689. * Gets the global Hue value.
  87690. * 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).
  87691. */
  87692. /**
  87693. * Sets the global Hue value.
  87694. * 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).
  87695. */
  87696. globalHue: number;
  87697. /**
  87698. * Gets the global Density value.
  87699. * 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.
  87700. * Values less than zero provide a filter of opposite hue.
  87701. */
  87702. /**
  87703. * Sets the global Density value.
  87704. * 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.
  87705. * Values less than zero provide a filter of opposite hue.
  87706. */
  87707. globalDensity: number;
  87708. /**
  87709. * Gets the global Saturation value.
  87710. * 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.
  87711. */
  87712. /**
  87713. * Sets the global Saturation value.
  87714. * 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.
  87715. */
  87716. globalSaturation: number;
  87717. /**
  87718. * Gets the global Exposure value.
  87719. * 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.
  87720. */
  87721. /**
  87722. * Sets the global Exposure value.
  87723. * 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.
  87724. */
  87725. globalExposure: number;
  87726. private _highlightsHue;
  87727. private _highlightsDensity;
  87728. private _highlightsSaturation;
  87729. private _highlightsExposure;
  87730. /**
  87731. * Gets the highlights Hue value.
  87732. * 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).
  87733. */
  87734. /**
  87735. * Sets the highlights Hue value.
  87736. * 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).
  87737. */
  87738. highlightsHue: number;
  87739. /**
  87740. * Gets the highlights Density value.
  87741. * 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.
  87742. * Values less than zero provide a filter of opposite hue.
  87743. */
  87744. /**
  87745. * Sets the highlights Density value.
  87746. * 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.
  87747. * Values less than zero provide a filter of opposite hue.
  87748. */
  87749. highlightsDensity: number;
  87750. /**
  87751. * Gets the highlights Saturation value.
  87752. * 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.
  87753. */
  87754. /**
  87755. * Sets the highlights Saturation value.
  87756. * 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.
  87757. */
  87758. highlightsSaturation: number;
  87759. /**
  87760. * Gets the highlights Exposure value.
  87761. * 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.
  87762. */
  87763. /**
  87764. * Sets the highlights Exposure value.
  87765. * 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.
  87766. */
  87767. highlightsExposure: number;
  87768. private _midtonesHue;
  87769. private _midtonesDensity;
  87770. private _midtonesSaturation;
  87771. private _midtonesExposure;
  87772. /**
  87773. * Gets the midtones Hue value.
  87774. * 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).
  87775. */
  87776. /**
  87777. * Sets the midtones Hue value.
  87778. * 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).
  87779. */
  87780. midtonesHue: number;
  87781. /**
  87782. * Gets the midtones Density value.
  87783. * 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.
  87784. * Values less than zero provide a filter of opposite hue.
  87785. */
  87786. /**
  87787. * Sets the midtones Density value.
  87788. * 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.
  87789. * Values less than zero provide a filter of opposite hue.
  87790. */
  87791. midtonesDensity: number;
  87792. /**
  87793. * Gets the midtones Saturation value.
  87794. * 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.
  87795. */
  87796. /**
  87797. * Sets the midtones Saturation value.
  87798. * 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.
  87799. */
  87800. midtonesSaturation: number;
  87801. /**
  87802. * Gets the midtones Exposure value.
  87803. * 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.
  87804. */
  87805. /**
  87806. * Sets the midtones Exposure value.
  87807. * 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.
  87808. */
  87809. midtonesExposure: number;
  87810. private _shadowsHue;
  87811. private _shadowsDensity;
  87812. private _shadowsSaturation;
  87813. private _shadowsExposure;
  87814. /**
  87815. * Gets the shadows Hue value.
  87816. * 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).
  87817. */
  87818. /**
  87819. * Sets the shadows Hue value.
  87820. * 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).
  87821. */
  87822. shadowsHue: number;
  87823. /**
  87824. * Gets the shadows Density value.
  87825. * 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.
  87826. * Values less than zero provide a filter of opposite hue.
  87827. */
  87828. /**
  87829. * Sets the shadows Density value.
  87830. * 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.
  87831. * Values less than zero provide a filter of opposite hue.
  87832. */
  87833. shadowsDensity: number;
  87834. /**
  87835. * Gets the shadows Saturation value.
  87836. * 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.
  87837. */
  87838. /**
  87839. * Sets the shadows Saturation value.
  87840. * 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.
  87841. */
  87842. shadowsSaturation: number;
  87843. /**
  87844. * Gets the shadows Exposure value.
  87845. * 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.
  87846. */
  87847. /**
  87848. * Sets the shadows Exposure value.
  87849. * 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.
  87850. */
  87851. shadowsExposure: number;
  87852. /**
  87853. * Returns the class name
  87854. * @returns The class name
  87855. */
  87856. getClassName(): string;
  87857. /**
  87858. * Binds the color curves to the shader.
  87859. * @param colorCurves The color curve to bind
  87860. * @param effect The effect to bind to
  87861. * @param positiveUniform The positive uniform shader parameter
  87862. * @param neutralUniform The neutral uniform shader parameter
  87863. * @param negativeUniform The negative uniform shader parameter
  87864. */
  87865. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  87866. /**
  87867. * Prepare the list of uniforms associated with the ColorCurves effects.
  87868. * @param uniformsList The list of uniforms used in the effect
  87869. */
  87870. static PrepareUniforms(uniformsList: string[]): void;
  87871. /**
  87872. * Returns color grading data based on a hue, density, saturation and exposure value.
  87873. * @param filterHue The hue of the color filter.
  87874. * @param filterDensity The density of the color filter.
  87875. * @param saturation The saturation.
  87876. * @param exposure The exposure.
  87877. * @param result The result data container.
  87878. */
  87879. private getColorGradingDataToRef;
  87880. /**
  87881. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  87882. * @param value The input slider value in range [-100,100].
  87883. * @returns Adjusted value.
  87884. */
  87885. private static applyColorGradingSliderNonlinear;
  87886. /**
  87887. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  87888. * @param hue The hue (H) input.
  87889. * @param saturation The saturation (S) input.
  87890. * @param brightness The brightness (B) input.
  87891. * @result An RGBA color represented as Vector4.
  87892. */
  87893. private static fromHSBToRef;
  87894. /**
  87895. * Returns a value clamped between min and max
  87896. * @param value The value to clamp
  87897. * @param min The minimum of value
  87898. * @param max The maximum of value
  87899. * @returns The clamped value.
  87900. */
  87901. private static clamp;
  87902. /**
  87903. * Clones the current color curve instance.
  87904. * @return The cloned curves
  87905. */
  87906. clone(): ColorCurves;
  87907. /**
  87908. * Serializes the current color curve instance to a json representation.
  87909. * @return a JSON representation
  87910. */
  87911. serialize(): any;
  87912. /**
  87913. * Parses the color curve from a json representation.
  87914. * @param source the JSON source to parse
  87915. * @return The parsed curves
  87916. */
  87917. static Parse(source: any): ColorCurves;
  87918. }
  87919. }
  87920. declare module BABYLON {
  87921. /**
  87922. * Interface to follow in your material defines to integrate easily the
  87923. * Image proccessing functions.
  87924. * @hidden
  87925. */
  87926. export interface IImageProcessingConfigurationDefines {
  87927. IMAGEPROCESSING: boolean;
  87928. VIGNETTE: boolean;
  87929. VIGNETTEBLENDMODEMULTIPLY: boolean;
  87930. VIGNETTEBLENDMODEOPAQUE: boolean;
  87931. TONEMAPPING: boolean;
  87932. TONEMAPPING_ACES: boolean;
  87933. CONTRAST: boolean;
  87934. EXPOSURE: boolean;
  87935. COLORCURVES: boolean;
  87936. COLORGRADING: boolean;
  87937. COLORGRADING3D: boolean;
  87938. SAMPLER3DGREENDEPTH: boolean;
  87939. SAMPLER3DBGRMAP: boolean;
  87940. IMAGEPROCESSINGPOSTPROCESS: boolean;
  87941. }
  87942. /**
  87943. * @hidden
  87944. */
  87945. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  87946. IMAGEPROCESSING: boolean;
  87947. VIGNETTE: boolean;
  87948. VIGNETTEBLENDMODEMULTIPLY: boolean;
  87949. VIGNETTEBLENDMODEOPAQUE: boolean;
  87950. TONEMAPPING: boolean;
  87951. TONEMAPPING_ACES: boolean;
  87952. CONTRAST: boolean;
  87953. COLORCURVES: boolean;
  87954. COLORGRADING: boolean;
  87955. COLORGRADING3D: boolean;
  87956. SAMPLER3DGREENDEPTH: boolean;
  87957. SAMPLER3DBGRMAP: boolean;
  87958. IMAGEPROCESSINGPOSTPROCESS: boolean;
  87959. EXPOSURE: boolean;
  87960. constructor();
  87961. }
  87962. /**
  87963. * This groups together the common properties used for image processing either in direct forward pass
  87964. * or through post processing effect depending on the use of the image processing pipeline in your scene
  87965. * or not.
  87966. */
  87967. export class ImageProcessingConfiguration {
  87968. /**
  87969. * Default tone mapping applied in BabylonJS.
  87970. */
  87971. static readonly TONEMAPPING_STANDARD: number;
  87972. /**
  87973. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  87974. * to other engines rendering to increase portability.
  87975. */
  87976. static readonly TONEMAPPING_ACES: number;
  87977. /**
  87978. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  87979. */
  87980. colorCurves: Nullable<ColorCurves>;
  87981. private _colorCurvesEnabled;
  87982. /**
  87983. * Gets wether the color curves effect is enabled.
  87984. */
  87985. /**
  87986. * Sets wether the color curves effect is enabled.
  87987. */
  87988. colorCurvesEnabled: boolean;
  87989. private _colorGradingTexture;
  87990. /**
  87991. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  87992. */
  87993. /**
  87994. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  87995. */
  87996. colorGradingTexture: Nullable<BaseTexture>;
  87997. private _colorGradingEnabled;
  87998. /**
  87999. * Gets wether the color grading effect is enabled.
  88000. */
  88001. /**
  88002. * Sets wether the color grading effect is enabled.
  88003. */
  88004. colorGradingEnabled: boolean;
  88005. private _colorGradingWithGreenDepth;
  88006. /**
  88007. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  88008. */
  88009. /**
  88010. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  88011. */
  88012. colorGradingWithGreenDepth: boolean;
  88013. private _colorGradingBGR;
  88014. /**
  88015. * Gets wether the color grading texture contains BGR values.
  88016. */
  88017. /**
  88018. * Sets wether the color grading texture contains BGR values.
  88019. */
  88020. colorGradingBGR: boolean;
  88021. /** @hidden */
  88022. _exposure: number;
  88023. /**
  88024. * Gets the Exposure used in the effect.
  88025. */
  88026. /**
  88027. * Sets the Exposure used in the effect.
  88028. */
  88029. exposure: number;
  88030. private _toneMappingEnabled;
  88031. /**
  88032. * Gets wether the tone mapping effect is enabled.
  88033. */
  88034. /**
  88035. * Sets wether the tone mapping effect is enabled.
  88036. */
  88037. toneMappingEnabled: boolean;
  88038. private _toneMappingType;
  88039. /**
  88040. * Gets the type of tone mapping effect.
  88041. */
  88042. /**
  88043. * Sets the type of tone mapping effect used in BabylonJS.
  88044. */
  88045. toneMappingType: number;
  88046. protected _contrast: number;
  88047. /**
  88048. * Gets the contrast used in the effect.
  88049. */
  88050. /**
  88051. * Sets the contrast used in the effect.
  88052. */
  88053. contrast: number;
  88054. /**
  88055. * Vignette stretch size.
  88056. */
  88057. vignetteStretch: number;
  88058. /**
  88059. * Vignette centre X Offset.
  88060. */
  88061. vignetteCentreX: number;
  88062. /**
  88063. * Vignette centre Y Offset.
  88064. */
  88065. vignetteCentreY: number;
  88066. /**
  88067. * Vignette weight or intensity of the vignette effect.
  88068. */
  88069. vignetteWeight: number;
  88070. /**
  88071. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  88072. * if vignetteEnabled is set to true.
  88073. */
  88074. vignetteColor: Color4;
  88075. /**
  88076. * Camera field of view used by the Vignette effect.
  88077. */
  88078. vignetteCameraFov: number;
  88079. private _vignetteBlendMode;
  88080. /**
  88081. * Gets the vignette blend mode allowing different kind of effect.
  88082. */
  88083. /**
  88084. * Sets the vignette blend mode allowing different kind of effect.
  88085. */
  88086. vignetteBlendMode: number;
  88087. private _vignetteEnabled;
  88088. /**
  88089. * Gets wether the vignette effect is enabled.
  88090. */
  88091. /**
  88092. * Sets wether the vignette effect is enabled.
  88093. */
  88094. vignetteEnabled: boolean;
  88095. private _applyByPostProcess;
  88096. /**
  88097. * Gets wether the image processing is applied through a post process or not.
  88098. */
  88099. /**
  88100. * Sets wether the image processing is applied through a post process or not.
  88101. */
  88102. applyByPostProcess: boolean;
  88103. private _isEnabled;
  88104. /**
  88105. * Gets wether the image processing is enabled or not.
  88106. */
  88107. /**
  88108. * Sets wether the image processing is enabled or not.
  88109. */
  88110. isEnabled: boolean;
  88111. /**
  88112. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  88113. */
  88114. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  88115. /**
  88116. * Method called each time the image processing information changes requires to recompile the effect.
  88117. */
  88118. protected _updateParameters(): void;
  88119. /**
  88120. * Gets the current class name.
  88121. * @return "ImageProcessingConfiguration"
  88122. */
  88123. getClassName(): string;
  88124. /**
  88125. * Prepare the list of uniforms associated with the Image Processing effects.
  88126. * @param uniforms The list of uniforms used in the effect
  88127. * @param defines the list of defines currently in use
  88128. */
  88129. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  88130. /**
  88131. * Prepare the list of samplers associated with the Image Processing effects.
  88132. * @param samplersList The list of uniforms used in the effect
  88133. * @param defines the list of defines currently in use
  88134. */
  88135. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  88136. /**
  88137. * Prepare the list of defines associated to the shader.
  88138. * @param defines the list of defines to complete
  88139. * @param forPostProcess Define if we are currently in post process mode or not
  88140. */
  88141. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  88142. /**
  88143. * Returns true if all the image processing information are ready.
  88144. * @returns True if ready, otherwise, false
  88145. */
  88146. isReady(): boolean;
  88147. /**
  88148. * Binds the image processing to the shader.
  88149. * @param effect The effect to bind to
  88150. * @param aspectRatio Define the current aspect ratio of the effect
  88151. */
  88152. bind(effect: Effect, aspectRatio?: number): void;
  88153. /**
  88154. * Clones the current image processing instance.
  88155. * @return The cloned image processing
  88156. */
  88157. clone(): ImageProcessingConfiguration;
  88158. /**
  88159. * Serializes the current image processing instance to a json representation.
  88160. * @return a JSON representation
  88161. */
  88162. serialize(): any;
  88163. /**
  88164. * Parses the image processing from a json representation.
  88165. * @param source the JSON source to parse
  88166. * @return The parsed image processing
  88167. */
  88168. static Parse(source: any): ImageProcessingConfiguration;
  88169. private static _VIGNETTEMODE_MULTIPLY;
  88170. private static _VIGNETTEMODE_OPAQUE;
  88171. /**
  88172. * Used to apply the vignette as a mix with the pixel color.
  88173. */
  88174. static readonly VIGNETTEMODE_MULTIPLY: number;
  88175. /**
  88176. * Used to apply the vignette as a replacement of the pixel color.
  88177. */
  88178. static readonly VIGNETTEMODE_OPAQUE: number;
  88179. }
  88180. }
  88181. declare module BABYLON {
  88182. /**
  88183. * This represents all the required information to add a fresnel effect on a material:
  88184. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  88185. */
  88186. export class FresnelParameters {
  88187. private _isEnabled;
  88188. /**
  88189. * Define if the fresnel effect is enable or not.
  88190. */
  88191. isEnabled: boolean;
  88192. /**
  88193. * Define the color used on edges (grazing angle)
  88194. */
  88195. leftColor: Color3;
  88196. /**
  88197. * Define the color used on center
  88198. */
  88199. rightColor: Color3;
  88200. /**
  88201. * Define bias applied to computed fresnel term
  88202. */
  88203. bias: number;
  88204. /**
  88205. * Defined the power exponent applied to fresnel term
  88206. */
  88207. power: number;
  88208. /**
  88209. * Clones the current fresnel and its valuues
  88210. * @returns a clone fresnel configuration
  88211. */
  88212. clone(): FresnelParameters;
  88213. /**
  88214. * Serializes the current fresnel parameters to a JSON representation.
  88215. * @return the JSON serialization
  88216. */
  88217. serialize(): any;
  88218. /**
  88219. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  88220. * @param parsedFresnelParameters Define the JSON representation
  88221. * @returns the parsed parameters
  88222. */
  88223. static Parse(parsedFresnelParameters: any): FresnelParameters;
  88224. }
  88225. }
  88226. declare module BABYLON {
  88227. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  88228. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88229. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88230. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88231. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88232. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88233. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88234. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88235. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88236. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88237. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88238. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88239. /**
  88240. * Decorator used to define property that can be serialized as reference to a camera
  88241. * @param sourceName defines the name of the property to decorate
  88242. */
  88243. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88244. /**
  88245. * Class used to help serialization objects
  88246. */
  88247. export class SerializationHelper {
  88248. /** hidden */
  88249. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  88250. /** hidden */
  88251. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  88252. /** hidden */
  88253. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  88254. /** hidden */
  88255. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  88256. /**
  88257. * Appends the serialized animations from the source animations
  88258. * @param source Source containing the animations
  88259. * @param destination Target to store the animations
  88260. */
  88261. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  88262. /**
  88263. * Static function used to serialized a specific entity
  88264. * @param entity defines the entity to serialize
  88265. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  88266. * @returns a JSON compatible object representing the serialization of the entity
  88267. */
  88268. static Serialize<T>(entity: T, serializationObject?: any): any;
  88269. /**
  88270. * Creates a new entity from a serialization data object
  88271. * @param creationFunction defines a function used to instanciated the new entity
  88272. * @param source defines the source serialization data
  88273. * @param scene defines the hosting scene
  88274. * @param rootUrl defines the root url for resources
  88275. * @returns a new entity
  88276. */
  88277. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  88278. /**
  88279. * Clones an object
  88280. * @param creationFunction defines the function used to instanciate the new object
  88281. * @param source defines the source object
  88282. * @returns the cloned object
  88283. */
  88284. static Clone<T>(creationFunction: () => T, source: T): T;
  88285. /**
  88286. * Instanciates a new object based on a source one (some data will be shared between both object)
  88287. * @param creationFunction defines the function used to instanciate the new object
  88288. * @param source defines the source object
  88289. * @returns the new object
  88290. */
  88291. static Instanciate<T>(creationFunction: () => T, source: T): T;
  88292. }
  88293. }
  88294. declare module BABYLON {
  88295. /**
  88296. * This is the base class of all the camera used in the application.
  88297. * @see http://doc.babylonjs.com/features/cameras
  88298. */
  88299. export class Camera extends Node {
  88300. /** @hidden */
  88301. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  88302. /**
  88303. * This is the default projection mode used by the cameras.
  88304. * It helps recreating a feeling of perspective and better appreciate depth.
  88305. * This is the best way to simulate real life cameras.
  88306. */
  88307. static readonly PERSPECTIVE_CAMERA: number;
  88308. /**
  88309. * This helps creating camera with an orthographic mode.
  88310. * 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.
  88311. */
  88312. static readonly ORTHOGRAPHIC_CAMERA: number;
  88313. /**
  88314. * This is the default FOV mode for perspective cameras.
  88315. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  88316. */
  88317. static readonly FOVMODE_VERTICAL_FIXED: number;
  88318. /**
  88319. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  88320. */
  88321. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  88322. /**
  88323. * This specifies ther is no need for a camera rig.
  88324. * Basically only one eye is rendered corresponding to the camera.
  88325. */
  88326. static readonly RIG_MODE_NONE: number;
  88327. /**
  88328. * Simulates a camera Rig with one blue eye and one red eye.
  88329. * This can be use with 3d blue and red glasses.
  88330. */
  88331. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  88332. /**
  88333. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  88334. */
  88335. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  88336. /**
  88337. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  88338. */
  88339. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  88340. /**
  88341. * Defines that both eyes of the camera will be rendered over under each other.
  88342. */
  88343. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  88344. /**
  88345. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  88346. */
  88347. static readonly RIG_MODE_VR: number;
  88348. /**
  88349. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  88350. */
  88351. static readonly RIG_MODE_WEBVR: number;
  88352. /**
  88353. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  88354. */
  88355. static readonly RIG_MODE_CUSTOM: number;
  88356. /**
  88357. * Defines if by default attaching controls should prevent the default javascript event to continue.
  88358. */
  88359. static ForceAttachControlToAlwaysPreventDefault: boolean;
  88360. /**
  88361. * @hidden
  88362. * Might be removed once multiview will be a thing
  88363. */
  88364. static UseAlternateWebVRRendering: boolean;
  88365. /**
  88366. * Define the input manager associated with the camera.
  88367. */
  88368. inputs: CameraInputsManager<Camera>;
  88369. /** @hidden */
  88370. _position: Vector3;
  88371. /**
  88372. * Define the current local position of the camera in the scene
  88373. */
  88374. position: Vector3;
  88375. /**
  88376. * The vector the camera should consider as up.
  88377. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  88378. */
  88379. upVector: Vector3;
  88380. /**
  88381. * Define the current limit on the left side for an orthographic camera
  88382. * In scene unit
  88383. */
  88384. orthoLeft: Nullable<number>;
  88385. /**
  88386. * Define the current limit on the right side for an orthographic camera
  88387. * In scene unit
  88388. */
  88389. orthoRight: Nullable<number>;
  88390. /**
  88391. * Define the current limit on the bottom side for an orthographic camera
  88392. * In scene unit
  88393. */
  88394. orthoBottom: Nullable<number>;
  88395. /**
  88396. * Define the current limit on the top side for an orthographic camera
  88397. * In scene unit
  88398. */
  88399. orthoTop: Nullable<number>;
  88400. /**
  88401. * Field Of View is set in Radians. (default is 0.8)
  88402. */
  88403. fov: number;
  88404. /**
  88405. * Define the minimum distance the camera can see from.
  88406. * This is important to note that the depth buffer are not infinite and the closer it starts
  88407. * the more your scene might encounter depth fighting issue.
  88408. */
  88409. minZ: number;
  88410. /**
  88411. * Define the maximum distance the camera can see to.
  88412. * This is important to note that the depth buffer are not infinite and the further it end
  88413. * the more your scene might encounter depth fighting issue.
  88414. */
  88415. maxZ: number;
  88416. /**
  88417. * Define the default inertia of the camera.
  88418. * This helps giving a smooth feeling to the camera movement.
  88419. */
  88420. inertia: number;
  88421. /**
  88422. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  88423. */
  88424. mode: number;
  88425. /**
  88426. * Define wether the camera is intermediate.
  88427. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  88428. */
  88429. isIntermediate: boolean;
  88430. /**
  88431. * Define the viewport of the camera.
  88432. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  88433. */
  88434. viewport: Viewport;
  88435. /**
  88436. * Restricts the camera to viewing objects with the same layerMask.
  88437. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  88438. */
  88439. layerMask: number;
  88440. /**
  88441. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  88442. */
  88443. fovMode: number;
  88444. /**
  88445. * Rig mode of the camera.
  88446. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  88447. * This is normally controlled byt the camera themselves as internal use.
  88448. */
  88449. cameraRigMode: number;
  88450. /**
  88451. * Defines the distance between both "eyes" in case of a RIG
  88452. */
  88453. interaxialDistance: number;
  88454. /**
  88455. * Defines if stereoscopic rendering is done side by side or over under.
  88456. */
  88457. isStereoscopicSideBySide: boolean;
  88458. /**
  88459. * 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
  88460. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  88461. * else in the scene.
  88462. */
  88463. customRenderTargets: RenderTargetTexture[];
  88464. /**
  88465. * When set, the camera will render to this render target instead of the default canvas
  88466. */
  88467. outputRenderTarget: Nullable<RenderTargetTexture>;
  88468. /**
  88469. * Observable triggered when the camera view matrix has changed.
  88470. */
  88471. onViewMatrixChangedObservable: Observable<Camera>;
  88472. /**
  88473. * Observable triggered when the camera Projection matrix has changed.
  88474. */
  88475. onProjectionMatrixChangedObservable: Observable<Camera>;
  88476. /**
  88477. * Observable triggered when the inputs have been processed.
  88478. */
  88479. onAfterCheckInputsObservable: Observable<Camera>;
  88480. /**
  88481. * Observable triggered when reset has been called and applied to the camera.
  88482. */
  88483. onRestoreStateObservable: Observable<Camera>;
  88484. /** @hidden */
  88485. _cameraRigParams: any;
  88486. /** @hidden */
  88487. _rigCameras: Camera[];
  88488. /** @hidden */
  88489. _rigPostProcess: Nullable<PostProcess>;
  88490. protected _webvrViewMatrix: Matrix;
  88491. /** @hidden */
  88492. _skipRendering: boolean;
  88493. /** @hidden */
  88494. _alternateCamera: Camera;
  88495. /** @hidden */
  88496. _projectionMatrix: Matrix;
  88497. /** @hidden */
  88498. _postProcesses: Nullable<PostProcess>[];
  88499. /** @hidden */
  88500. _activeMeshes: SmartArray<AbstractMesh>;
  88501. protected _globalPosition: Vector3;
  88502. /** hidden */
  88503. _computedViewMatrix: Matrix;
  88504. private _doNotComputeProjectionMatrix;
  88505. private _transformMatrix;
  88506. private _frustumPlanes;
  88507. private _refreshFrustumPlanes;
  88508. private _storedFov;
  88509. private _stateStored;
  88510. /**
  88511. * Instantiates a new camera object.
  88512. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  88513. * @see http://doc.babylonjs.com/features/cameras
  88514. * @param name Defines the name of the camera in the scene
  88515. * @param position Defines the position of the camera
  88516. * @param scene Defines the scene the camera belongs too
  88517. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  88518. */
  88519. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  88520. /**
  88521. * Store current camera state (fov, position, etc..)
  88522. * @returns the camera
  88523. */
  88524. storeState(): Camera;
  88525. /**
  88526. * Restores the camera state values if it has been stored. You must call storeState() first
  88527. */
  88528. protected _restoreStateValues(): boolean;
  88529. /**
  88530. * Restored camera state. You must call storeState() first.
  88531. * @returns true if restored and false otherwise
  88532. */
  88533. restoreState(): boolean;
  88534. /**
  88535. * Gets the class name of the camera.
  88536. * @returns the class name
  88537. */
  88538. getClassName(): string;
  88539. /** @hidden */
  88540. readonly _isCamera: boolean;
  88541. /**
  88542. * Gets a string representation of the camera useful for debug purpose.
  88543. * @param fullDetails Defines that a more verboe level of logging is required
  88544. * @returns the string representation
  88545. */
  88546. toString(fullDetails?: boolean): string;
  88547. /**
  88548. * Gets the current world space position of the camera.
  88549. */
  88550. readonly globalPosition: Vector3;
  88551. /**
  88552. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  88553. * @returns the active meshe list
  88554. */
  88555. getActiveMeshes(): SmartArray<AbstractMesh>;
  88556. /**
  88557. * Check wether a mesh is part of the current active mesh list of the camera
  88558. * @param mesh Defines the mesh to check
  88559. * @returns true if active, false otherwise
  88560. */
  88561. isActiveMesh(mesh: Mesh): boolean;
  88562. /**
  88563. * Is this camera ready to be used/rendered
  88564. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  88565. * @return true if the camera is ready
  88566. */
  88567. isReady(completeCheck?: boolean): boolean;
  88568. /** @hidden */
  88569. _initCache(): void;
  88570. /** @hidden */
  88571. _updateCache(ignoreParentClass?: boolean): void;
  88572. /** @hidden */
  88573. _isSynchronized(): boolean;
  88574. /** @hidden */
  88575. _isSynchronizedViewMatrix(): boolean;
  88576. /** @hidden */
  88577. _isSynchronizedProjectionMatrix(): boolean;
  88578. /**
  88579. * Attach the input controls to a specific dom element to get the input from.
  88580. * @param element Defines the element the controls should be listened from
  88581. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  88582. */
  88583. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  88584. /**
  88585. * Detach the current controls from the specified dom element.
  88586. * @param element Defines the element to stop listening the inputs from
  88587. */
  88588. detachControl(element: HTMLElement): void;
  88589. /**
  88590. * Update the camera state according to the different inputs gathered during the frame.
  88591. */
  88592. update(): void;
  88593. /** @hidden */
  88594. _checkInputs(): void;
  88595. /** @hidden */
  88596. readonly rigCameras: Camera[];
  88597. /**
  88598. * Gets the post process used by the rig cameras
  88599. */
  88600. readonly rigPostProcess: Nullable<PostProcess>;
  88601. /**
  88602. * Internal, gets the first post proces.
  88603. * @returns the first post process to be run on this camera.
  88604. */
  88605. _getFirstPostProcess(): Nullable<PostProcess>;
  88606. private _cascadePostProcessesToRigCams;
  88607. /**
  88608. * Attach a post process to the camera.
  88609. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  88610. * @param postProcess The post process to attach to the camera
  88611. * @param insertAt The position of the post process in case several of them are in use in the scene
  88612. * @returns the position the post process has been inserted at
  88613. */
  88614. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  88615. /**
  88616. * Detach a post process to the camera.
  88617. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  88618. * @param postProcess The post process to detach from the camera
  88619. */
  88620. detachPostProcess(postProcess: PostProcess): void;
  88621. /**
  88622. * Gets the current world matrix of the camera
  88623. */
  88624. getWorldMatrix(): Matrix;
  88625. /** @hidden */
  88626. _getViewMatrix(): Matrix;
  88627. /**
  88628. * Gets the current view matrix of the camera.
  88629. * @param force forces the camera to recompute the matrix without looking at the cached state
  88630. * @returns the view matrix
  88631. */
  88632. getViewMatrix(force?: boolean): Matrix;
  88633. /**
  88634. * Freeze the projection matrix.
  88635. * It will prevent the cache check of the camera projection compute and can speed up perf
  88636. * if no parameter of the camera are meant to change
  88637. * @param projection Defines manually a projection if necessary
  88638. */
  88639. freezeProjectionMatrix(projection?: Matrix): void;
  88640. /**
  88641. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  88642. */
  88643. unfreezeProjectionMatrix(): void;
  88644. /**
  88645. * Gets the current projection matrix of the camera.
  88646. * @param force forces the camera to recompute the matrix without looking at the cached state
  88647. * @returns the projection matrix
  88648. */
  88649. getProjectionMatrix(force?: boolean): Matrix;
  88650. /**
  88651. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  88652. * @returns a Matrix
  88653. */
  88654. getTransformationMatrix(): Matrix;
  88655. private _updateFrustumPlanes;
  88656. /**
  88657. * Checks if a cullable object (mesh...) is in the camera frustum
  88658. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  88659. * @param target The object to check
  88660. * @returns true if the object is in frustum otherwise false
  88661. */
  88662. isInFrustum(target: ICullable): boolean;
  88663. /**
  88664. * Checks if a cullable object (mesh...) is in the camera frustum
  88665. * Unlike isInFrustum this cheks the full bounding box
  88666. * @param target The object to check
  88667. * @returns true if the object is in frustum otherwise false
  88668. */
  88669. isCompletelyInFrustum(target: ICullable): boolean;
  88670. /**
  88671. * Gets a ray in the forward direction from the camera.
  88672. * @param length Defines the length of the ray to create
  88673. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  88674. * @param origin Defines the start point of the ray which defaults to the camera position
  88675. * @returns the forward ray
  88676. */
  88677. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  88678. /**
  88679. * Releases resources associated with this node.
  88680. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88681. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88682. */
  88683. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88684. /** @hidden */
  88685. _isLeftCamera: boolean;
  88686. /**
  88687. * Gets the left camera of a rig setup in case of Rigged Camera
  88688. */
  88689. readonly isLeftCamera: boolean;
  88690. /** @hidden */
  88691. _isRightCamera: boolean;
  88692. /**
  88693. * Gets the right camera of a rig setup in case of Rigged Camera
  88694. */
  88695. readonly isRightCamera: boolean;
  88696. /**
  88697. * Gets the left camera of a rig setup in case of Rigged Camera
  88698. */
  88699. readonly leftCamera: Nullable<FreeCamera>;
  88700. /**
  88701. * Gets the right camera of a rig setup in case of Rigged Camera
  88702. */
  88703. readonly rightCamera: Nullable<FreeCamera>;
  88704. /**
  88705. * Gets the left camera target of a rig setup in case of Rigged Camera
  88706. * @returns the target position
  88707. */
  88708. getLeftTarget(): Nullable<Vector3>;
  88709. /**
  88710. * Gets the right camera target of a rig setup in case of Rigged Camera
  88711. * @returns the target position
  88712. */
  88713. getRightTarget(): Nullable<Vector3>;
  88714. /**
  88715. * @hidden
  88716. */
  88717. setCameraRigMode(mode: number, rigParams: any): void;
  88718. /** @hidden */
  88719. static _setStereoscopicRigMode(camera: Camera): void;
  88720. /** @hidden */
  88721. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  88722. /** @hidden */
  88723. static _setVRRigMode(camera: Camera, rigParams: any): void;
  88724. /** @hidden */
  88725. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  88726. /** @hidden */
  88727. _getVRProjectionMatrix(): Matrix;
  88728. protected _updateCameraRotationMatrix(): void;
  88729. protected _updateWebVRCameraRotationMatrix(): void;
  88730. /**
  88731. * This function MUST be overwritten by the different WebVR cameras available.
  88732. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  88733. * @hidden
  88734. */
  88735. _getWebVRProjectionMatrix(): Matrix;
  88736. /**
  88737. * This function MUST be overwritten by the different WebVR cameras available.
  88738. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  88739. * @hidden
  88740. */
  88741. _getWebVRViewMatrix(): Matrix;
  88742. /** @hidden */
  88743. setCameraRigParameter(name: string, value: any): void;
  88744. /**
  88745. * needs to be overridden by children so sub has required properties to be copied
  88746. * @hidden
  88747. */
  88748. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  88749. /**
  88750. * May need to be overridden by children
  88751. * @hidden
  88752. */
  88753. _updateRigCameras(): void;
  88754. /** @hidden */
  88755. _setupInputs(): void;
  88756. /**
  88757. * Serialiaze the camera setup to a json represention
  88758. * @returns the JSON representation
  88759. */
  88760. serialize(): any;
  88761. /**
  88762. * Clones the current camera.
  88763. * @param name The cloned camera name
  88764. * @returns the cloned camera
  88765. */
  88766. clone(name: string): Camera;
  88767. /**
  88768. * Gets the direction of the camera relative to a given local axis.
  88769. * @param localAxis Defines the reference axis to provide a relative direction.
  88770. * @return the direction
  88771. */
  88772. getDirection(localAxis: Vector3): Vector3;
  88773. /**
  88774. * Gets the direction of the camera relative to a given local axis into a passed vector.
  88775. * @param localAxis Defines the reference axis to provide a relative direction.
  88776. * @param result Defines the vector to store the result in
  88777. */
  88778. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  88779. /**
  88780. * Gets a camera constructor for a given camera type
  88781. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  88782. * @param name The name of the camera the result will be able to instantiate
  88783. * @param scene The scene the result will construct the camera in
  88784. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  88785. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  88786. * @returns a factory method to construc the camera
  88787. */
  88788. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  88789. /**
  88790. * Compute the world matrix of the camera.
  88791. * @returns the camera workd matrix
  88792. */
  88793. computeWorldMatrix(): Matrix;
  88794. /**
  88795. * Parse a JSON and creates the camera from the parsed information
  88796. * @param parsedCamera The JSON to parse
  88797. * @param scene The scene to instantiate the camera in
  88798. * @returns the newly constructed camera
  88799. */
  88800. static Parse(parsedCamera: any, scene: Scene): Camera;
  88801. }
  88802. }
  88803. declare module BABYLON {
  88804. /**
  88805. * Interface for any object that can request an animation frame
  88806. */
  88807. export interface ICustomAnimationFrameRequester {
  88808. /**
  88809. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  88810. */
  88811. renderFunction?: Function;
  88812. /**
  88813. * Called to request the next frame to render to
  88814. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  88815. */
  88816. requestAnimationFrame: Function;
  88817. /**
  88818. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  88819. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  88820. */
  88821. requestID?: number;
  88822. }
  88823. /**
  88824. * Interface containing an array of animations
  88825. */
  88826. export interface IAnimatable {
  88827. /**
  88828. * Array of animations
  88829. */
  88830. animations: Array<Animation>;
  88831. }
  88832. /** Interface used by value gradients (color, factor, ...) */
  88833. export interface IValueGradient {
  88834. /**
  88835. * Gets or sets the gradient value (between 0 and 1)
  88836. */
  88837. gradient: number;
  88838. }
  88839. /** Class used to store color4 gradient */
  88840. export class ColorGradient implements IValueGradient {
  88841. /**
  88842. * Gets or sets the gradient value (between 0 and 1)
  88843. */
  88844. gradient: number;
  88845. /**
  88846. * Gets or sets first associated color
  88847. */
  88848. color1: Color4;
  88849. /**
  88850. * Gets or sets second associated color
  88851. */
  88852. color2?: Color4;
  88853. /**
  88854. * Will get a color picked randomly between color1 and color2.
  88855. * If color2 is undefined then color1 will be used
  88856. * @param result defines the target Color4 to store the result in
  88857. */
  88858. getColorToRef(result: Color4): void;
  88859. }
  88860. /** Class used to store color 3 gradient */
  88861. export class Color3Gradient implements IValueGradient {
  88862. /**
  88863. * Gets or sets the gradient value (between 0 and 1)
  88864. */
  88865. gradient: number;
  88866. /**
  88867. * Gets or sets the associated color
  88868. */
  88869. color: Color3;
  88870. }
  88871. /** Class used to store factor gradient */
  88872. export class FactorGradient implements IValueGradient {
  88873. /**
  88874. * Gets or sets the gradient value (between 0 and 1)
  88875. */
  88876. gradient: number;
  88877. /**
  88878. * Gets or sets first associated factor
  88879. */
  88880. factor1: number;
  88881. /**
  88882. * Gets or sets second associated factor
  88883. */
  88884. factor2?: number;
  88885. /**
  88886. * Will get a number picked randomly between factor1 and factor2.
  88887. * If factor2 is undefined then factor1 will be used
  88888. * @returns the picked number
  88889. */
  88890. getFactor(): number;
  88891. }
  88892. /**
  88893. * @ignore
  88894. * Application error to support additional information when loading a file
  88895. */
  88896. export class LoadFileError extends Error {
  88897. /** defines the optional web request */
  88898. request?: WebRequest | undefined;
  88899. private static _setPrototypeOf;
  88900. /**
  88901. * Creates a new LoadFileError
  88902. * @param message defines the message of the error
  88903. * @param request defines the optional web request
  88904. */
  88905. constructor(message: string,
  88906. /** defines the optional web request */
  88907. request?: WebRequest | undefined);
  88908. }
  88909. /**
  88910. * Class used to define a retry strategy when error happens while loading assets
  88911. */
  88912. export class RetryStrategy {
  88913. /**
  88914. * Function used to defines an exponential back off strategy
  88915. * @param maxRetries defines the maximum number of retries (3 by default)
  88916. * @param baseInterval defines the interval between retries
  88917. * @returns the strategy function to use
  88918. */
  88919. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  88920. }
  88921. /**
  88922. * File request interface
  88923. */
  88924. export interface IFileRequest {
  88925. /**
  88926. * Raised when the request is complete (success or error).
  88927. */
  88928. onCompleteObservable: Observable<IFileRequest>;
  88929. /**
  88930. * Aborts the request for a file.
  88931. */
  88932. abort: () => void;
  88933. }
  88934. /**
  88935. * Class containing a set of static utilities functions
  88936. */
  88937. export class Tools {
  88938. /**
  88939. * Gets or sets the base URL to use to load assets
  88940. */
  88941. static BaseUrl: string;
  88942. /**
  88943. * Enable/Disable Custom HTTP Request Headers globally.
  88944. * default = false
  88945. * @see CustomRequestHeaders
  88946. */
  88947. static UseCustomRequestHeaders: boolean;
  88948. /**
  88949. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  88950. * i.e. when loading files, where the server/service expects an Authorization header
  88951. */
  88952. static CustomRequestHeaders: {
  88953. [key: string]: string;
  88954. };
  88955. /**
  88956. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  88957. */
  88958. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  88959. /**
  88960. * Default behaviour for cors in the application.
  88961. * It can be a string if the expected behavior is identical in the entire app.
  88962. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  88963. */
  88964. static CorsBehavior: string | ((url: string | string[]) => string);
  88965. /**
  88966. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  88967. * @ignorenaming
  88968. */
  88969. static UseFallbackTexture: boolean;
  88970. /**
  88971. * Use this object to register external classes like custom textures or material
  88972. * to allow the laoders to instantiate them
  88973. */
  88974. static RegisteredExternalClasses: {
  88975. [key: string]: Object;
  88976. };
  88977. /**
  88978. * Texture content used if a texture cannot loaded
  88979. * @ignorenaming
  88980. */
  88981. static fallbackTexture: string;
  88982. /**
  88983. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  88984. * @param u defines the coordinate on X axis
  88985. * @param v defines the coordinate on Y axis
  88986. * @param width defines the width of the source data
  88987. * @param height defines the height of the source data
  88988. * @param pixels defines the source byte array
  88989. * @param color defines the output color
  88990. */
  88991. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  88992. /**
  88993. * Interpolates between a and b via alpha
  88994. * @param a The lower value (returned when alpha = 0)
  88995. * @param b The upper value (returned when alpha = 1)
  88996. * @param alpha The interpolation-factor
  88997. * @return The mixed value
  88998. */
  88999. static Mix(a: number, b: number, alpha: number): number;
  89000. /**
  89001. * Tries to instantiate a new object from a given class name
  89002. * @param className defines the class name to instantiate
  89003. * @returns the new object or null if the system was not able to do the instantiation
  89004. */
  89005. static Instantiate(className: string): any;
  89006. /**
  89007. * Provides a slice function that will work even on IE
  89008. * @param data defines the array to slice
  89009. * @param start defines the start of the data (optional)
  89010. * @param end defines the end of the data (optional)
  89011. * @returns the new sliced array
  89012. */
  89013. static Slice<T>(data: T, start?: number, end?: number): T;
  89014. /**
  89015. * Polyfill for setImmediate
  89016. * @param action defines the action to execute after the current execution block
  89017. */
  89018. static SetImmediate(action: () => void): void;
  89019. /**
  89020. * Function indicating if a number is an exponent of 2
  89021. * @param value defines the value to test
  89022. * @returns true if the value is an exponent of 2
  89023. */
  89024. static IsExponentOfTwo(value: number): boolean;
  89025. private static _tmpFloatArray;
  89026. /**
  89027. * Returns the nearest 32-bit single precision float representation of a Number
  89028. * @param value A Number. If the parameter is of a different type, it will get converted
  89029. * to a number or to NaN if it cannot be converted
  89030. * @returns number
  89031. */
  89032. static FloatRound(value: number): number;
  89033. /**
  89034. * Find the next highest power of two.
  89035. * @param x Number to start search from.
  89036. * @return Next highest power of two.
  89037. */
  89038. static CeilingPOT(x: number): number;
  89039. /**
  89040. * Find the next lowest power of two.
  89041. * @param x Number to start search from.
  89042. * @return Next lowest power of two.
  89043. */
  89044. static FloorPOT(x: number): number;
  89045. /**
  89046. * Find the nearest power of two.
  89047. * @param x Number to start search from.
  89048. * @return Next nearest power of two.
  89049. */
  89050. static NearestPOT(x: number): number;
  89051. /**
  89052. * Get the closest exponent of two
  89053. * @param value defines the value to approximate
  89054. * @param max defines the maximum value to return
  89055. * @param mode defines how to define the closest value
  89056. * @returns closest exponent of two of the given value
  89057. */
  89058. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  89059. /**
  89060. * Extracts the filename from a path
  89061. * @param path defines the path to use
  89062. * @returns the filename
  89063. */
  89064. static GetFilename(path: string): string;
  89065. /**
  89066. * Extracts the "folder" part of a path (everything before the filename).
  89067. * @param uri The URI to extract the info from
  89068. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  89069. * @returns The "folder" part of the path
  89070. */
  89071. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  89072. /**
  89073. * Extracts text content from a DOM element hierarchy
  89074. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  89075. */
  89076. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  89077. /**
  89078. * Convert an angle in radians to degrees
  89079. * @param angle defines the angle to convert
  89080. * @returns the angle in degrees
  89081. */
  89082. static ToDegrees(angle: number): number;
  89083. /**
  89084. * Convert an angle in degrees to radians
  89085. * @param angle defines the angle to convert
  89086. * @returns the angle in radians
  89087. */
  89088. static ToRadians(angle: number): number;
  89089. /**
  89090. * Encode a buffer to a base64 string
  89091. * @param buffer defines the buffer to encode
  89092. * @returns the encoded string
  89093. */
  89094. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  89095. /**
  89096. * Extracts minimum and maximum values from a list of indexed positions
  89097. * @param positions defines the positions to use
  89098. * @param indices defines the indices to the positions
  89099. * @param indexStart defines the start index
  89100. * @param indexCount defines the end index
  89101. * @param bias defines bias value to add to the result
  89102. * @return minimum and maximum values
  89103. */
  89104. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  89105. minimum: Vector3;
  89106. maximum: Vector3;
  89107. };
  89108. /**
  89109. * Extracts minimum and maximum values from a list of positions
  89110. * @param positions defines the positions to use
  89111. * @param start defines the start index in the positions array
  89112. * @param count defines the number of positions to handle
  89113. * @param bias defines bias value to add to the result
  89114. * @param stride defines the stride size to use (distance between two positions in the positions array)
  89115. * @return minimum and maximum values
  89116. */
  89117. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  89118. minimum: Vector3;
  89119. maximum: Vector3;
  89120. };
  89121. /**
  89122. * Returns an array if obj is not an array
  89123. * @param obj defines the object to evaluate as an array
  89124. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  89125. * @returns either obj directly if obj is an array or a new array containing obj
  89126. */
  89127. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  89128. /**
  89129. * Gets the pointer prefix to use
  89130. * @returns "pointer" if touch is enabled. Else returns "mouse"
  89131. */
  89132. static GetPointerPrefix(): string;
  89133. /**
  89134. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  89135. * @param func - the function to be called
  89136. * @param requester - the object that will request the next frame. Falls back to window.
  89137. * @returns frame number
  89138. */
  89139. static QueueNewFrame(func: () => void, requester?: any): number;
  89140. /**
  89141. * Ask the browser to promote the current element to fullscreen rendering mode
  89142. * @param element defines the DOM element to promote
  89143. */
  89144. static RequestFullscreen(element: HTMLElement): void;
  89145. /**
  89146. * Asks the browser to exit fullscreen mode
  89147. */
  89148. static ExitFullscreen(): void;
  89149. /**
  89150. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  89151. * @param url define the url we are trying
  89152. * @param element define the dom element where to configure the cors policy
  89153. */
  89154. static SetCorsBehavior(url: string | string[], element: {
  89155. crossOrigin: string | null;
  89156. }): void;
  89157. /**
  89158. * Removes unwanted characters from an url
  89159. * @param url defines the url to clean
  89160. * @returns the cleaned url
  89161. */
  89162. static CleanUrl(url: string): string;
  89163. /**
  89164. * Gets or sets a function used to pre-process url before using them to load assets
  89165. */
  89166. static PreprocessUrl: (url: string) => string;
  89167. /**
  89168. * Loads an image as an HTMLImageElement.
  89169. * @param input url string, ArrayBuffer, or Blob to load
  89170. * @param onLoad callback called when the image successfully loads
  89171. * @param onError callback called when the image fails to load
  89172. * @param offlineProvider offline provider for caching
  89173. * @returns the HTMLImageElement of the loaded image
  89174. */
  89175. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  89176. /**
  89177. * Loads a file
  89178. * @param url url string, ArrayBuffer, or Blob to load
  89179. * @param onSuccess callback called when the file successfully loads
  89180. * @param onProgress callback called while file is loading (if the server supports this mode)
  89181. * @param offlineProvider defines the offline provider for caching
  89182. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  89183. * @param onError callback called when the file fails to load
  89184. * @returns a file request object
  89185. */
  89186. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  89187. /**
  89188. * Load a script (identified by an url). When the url returns, the
  89189. * content of this file is added into a new script element, attached to the DOM (body element)
  89190. * @param scriptUrl defines the url of the script to laod
  89191. * @param onSuccess defines the callback called when the script is loaded
  89192. * @param onError defines the callback to call if an error occurs
  89193. */
  89194. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  89195. /**
  89196. * Loads a file from a blob
  89197. * @param fileToLoad defines the blob to use
  89198. * @param callback defines the callback to call when data is loaded
  89199. * @param progressCallback defines the callback to call during loading process
  89200. * @returns a file request object
  89201. */
  89202. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  89203. /**
  89204. * Loads a file
  89205. * @param fileToLoad defines the file to load
  89206. * @param callback defines the callback to call when data is loaded
  89207. * @param progressCallBack defines the callback to call during loading process
  89208. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  89209. * @returns a file request object
  89210. */
  89211. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  89212. /**
  89213. * Creates a data url from a given string content
  89214. * @param content defines the content to convert
  89215. * @returns the new data url link
  89216. */
  89217. static FileAsURL(content: string): string;
  89218. /**
  89219. * Format the given number to a specific decimal format
  89220. * @param value defines the number to format
  89221. * @param decimals defines the number of decimals to use
  89222. * @returns the formatted string
  89223. */
  89224. static Format(value: number, decimals?: number): string;
  89225. /**
  89226. * Checks if a given vector is inside a specific range
  89227. * @param v defines the vector to test
  89228. * @param min defines the minimum range
  89229. * @param max defines the maximum range
  89230. */
  89231. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  89232. /**
  89233. * Tries to copy an object by duplicating every property
  89234. * @param source defines the source object
  89235. * @param destination defines the target object
  89236. * @param doNotCopyList defines a list of properties to avoid
  89237. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  89238. */
  89239. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  89240. /**
  89241. * Gets a boolean indicating if the given object has no own property
  89242. * @param obj defines the object to test
  89243. * @returns true if object has no own property
  89244. */
  89245. static IsEmpty(obj: any): boolean;
  89246. /**
  89247. * Function used to register events at window level
  89248. * @param events defines the events to register
  89249. */
  89250. static RegisterTopRootEvents(events: {
  89251. name: string;
  89252. handler: Nullable<(e: FocusEvent) => any>;
  89253. }[]): void;
  89254. /**
  89255. * Function used to unregister events from window level
  89256. * @param events defines the events to unregister
  89257. */
  89258. static UnregisterTopRootEvents(events: {
  89259. name: string;
  89260. handler: Nullable<(e: FocusEvent) => any>;
  89261. }[]): void;
  89262. /**
  89263. * @ignore
  89264. */
  89265. static _ScreenshotCanvas: HTMLCanvasElement;
  89266. /**
  89267. * Dumps the current bound framebuffer
  89268. * @param width defines the rendering width
  89269. * @param height defines the rendering height
  89270. * @param engine defines the hosting engine
  89271. * @param successCallback defines the callback triggered once the data are available
  89272. * @param mimeType defines the mime type of the result
  89273. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  89274. */
  89275. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  89276. /**
  89277. * Converts the canvas data to blob.
  89278. * This acts as a polyfill for browsers not supporting the to blob function.
  89279. * @param canvas Defines the canvas to extract the data from
  89280. * @param successCallback Defines the callback triggered once the data are available
  89281. * @param mimeType Defines the mime type of the result
  89282. */
  89283. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  89284. /**
  89285. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  89286. * @param successCallback defines the callback triggered once the data are available
  89287. * @param mimeType defines the mime type of the result
  89288. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  89289. */
  89290. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  89291. /**
  89292. * Downloads a blob in the browser
  89293. * @param blob defines the blob to download
  89294. * @param fileName defines the name of the downloaded file
  89295. */
  89296. static Download(blob: Blob, fileName: string): void;
  89297. /**
  89298. * Captures a screenshot of the current rendering
  89299. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  89300. * @param engine defines the rendering engine
  89301. * @param camera defines the source camera
  89302. * @param size This parameter can be set to a single number or to an object with the
  89303. * following (optional) properties: precision, width, height. If a single number is passed,
  89304. * it will be used for both width and height. If an object is passed, the screenshot size
  89305. * will be derived from the parameters. The precision property is a multiplier allowing
  89306. * rendering at a higher or lower resolution
  89307. * @param successCallback defines the callback receives a single parameter which contains the
  89308. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  89309. * src parameter of an <img> to display it
  89310. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  89311. * Check your browser for supported MIME types
  89312. */
  89313. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  89314. /**
  89315. * Generates an image screenshot from the specified camera.
  89316. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  89317. * @param engine The engine to use for rendering
  89318. * @param camera The camera to use for rendering
  89319. * @param size This parameter can be set to a single number or to an object with the
  89320. * following (optional) properties: precision, width, height. If a single number is passed,
  89321. * it will be used for both width and height. If an object is passed, the screenshot size
  89322. * will be derived from the parameters. The precision property is a multiplier allowing
  89323. * rendering at a higher or lower resolution
  89324. * @param successCallback The callback receives a single parameter which contains the
  89325. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  89326. * src parameter of an <img> to display it
  89327. * @param mimeType The MIME type of the screenshot image (default: image/png).
  89328. * Check your browser for supported MIME types
  89329. * @param samples Texture samples (default: 1)
  89330. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  89331. * @param fileName A name for for the downloaded file.
  89332. */
  89333. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  89334. /**
  89335. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  89336. * Be aware Math.random() could cause collisions, but:
  89337. * "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"
  89338. * @returns a pseudo random id
  89339. */
  89340. static RandomId(): string;
  89341. /**
  89342. * Test if the given uri is a base64 string
  89343. * @param uri The uri to test
  89344. * @return True if the uri is a base64 string or false otherwise
  89345. */
  89346. static IsBase64(uri: string): boolean;
  89347. /**
  89348. * Decode the given base64 uri.
  89349. * @param uri The uri to decode
  89350. * @return The decoded base64 data.
  89351. */
  89352. static DecodeBase64(uri: string): ArrayBuffer;
  89353. /**
  89354. * No log
  89355. */
  89356. static readonly NoneLogLevel: number;
  89357. /**
  89358. * Only message logs
  89359. */
  89360. static readonly MessageLogLevel: number;
  89361. /**
  89362. * Only warning logs
  89363. */
  89364. static readonly WarningLogLevel: number;
  89365. /**
  89366. * Only error logs
  89367. */
  89368. static readonly ErrorLogLevel: number;
  89369. /**
  89370. * All logs
  89371. */
  89372. static readonly AllLogLevel: number;
  89373. /**
  89374. * Gets a value indicating the number of loading errors
  89375. * @ignorenaming
  89376. */
  89377. static readonly errorsCount: number;
  89378. /**
  89379. * Callback called when a new log is added
  89380. */
  89381. static OnNewCacheEntry: (entry: string) => void;
  89382. /**
  89383. * Log a message to the console
  89384. * @param message defines the message to log
  89385. */
  89386. static Log(message: string): void;
  89387. /**
  89388. * Write a warning message to the console
  89389. * @param message defines the message to log
  89390. */
  89391. static Warn(message: string): void;
  89392. /**
  89393. * Write an error message to the console
  89394. * @param message defines the message to log
  89395. */
  89396. static Error(message: string): void;
  89397. /**
  89398. * Gets current log cache (list of logs)
  89399. */
  89400. static readonly LogCache: string;
  89401. /**
  89402. * Clears the log cache
  89403. */
  89404. static ClearLogCache(): void;
  89405. /**
  89406. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  89407. */
  89408. static LogLevels: number;
  89409. /**
  89410. * Checks if the loaded document was accessed via `file:`-Protocol.
  89411. * @returns boolean
  89412. */
  89413. static IsFileURL(): boolean;
  89414. /**
  89415. * Checks if the window object exists
  89416. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  89417. */
  89418. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  89419. /**
  89420. * No performance log
  89421. */
  89422. static readonly PerformanceNoneLogLevel: number;
  89423. /**
  89424. * Use user marks to log performance
  89425. */
  89426. static readonly PerformanceUserMarkLogLevel: number;
  89427. /**
  89428. * Log performance to the console
  89429. */
  89430. static readonly PerformanceConsoleLogLevel: number;
  89431. private static _performance;
  89432. /**
  89433. * Sets the current performance log level
  89434. */
  89435. static PerformanceLogLevel: number;
  89436. private static _StartPerformanceCounterDisabled;
  89437. private static _EndPerformanceCounterDisabled;
  89438. private static _StartUserMark;
  89439. private static _EndUserMark;
  89440. private static _StartPerformanceConsole;
  89441. private static _EndPerformanceConsole;
  89442. /**
  89443. * Starts a performance counter
  89444. */
  89445. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  89446. /**
  89447. * Ends a specific performance coutner
  89448. */
  89449. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  89450. /**
  89451. * Gets either window.performance.now() if supported or Date.now() else
  89452. */
  89453. static readonly Now: number;
  89454. /**
  89455. * This method will return the name of the class used to create the instance of the given object.
  89456. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  89457. * @param object the object to get the class name from
  89458. * @param isType defines if the object is actually a type
  89459. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  89460. */
  89461. static GetClassName(object: any, isType?: boolean): string;
  89462. /**
  89463. * Gets the first element of an array satisfying a given predicate
  89464. * @param array defines the array to browse
  89465. * @param predicate defines the predicate to use
  89466. * @returns null if not found or the element
  89467. */
  89468. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  89469. /**
  89470. * This method will return the name of the full name of the class, including its owning module (if any).
  89471. * 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).
  89472. * @param object the object to get the class name from
  89473. * @param isType defines if the object is actually a type
  89474. * @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.
  89475. * @ignorenaming
  89476. */
  89477. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  89478. /**
  89479. * Returns a promise that resolves after the given amount of time.
  89480. * @param delay Number of milliseconds to delay
  89481. * @returns Promise that resolves after the given amount of time
  89482. */
  89483. static DelayAsync(delay: number): Promise<void>;
  89484. /**
  89485. * Gets the current gradient from an array of IValueGradient
  89486. * @param ratio defines the current ratio to get
  89487. * @param gradients defines the array of IValueGradient
  89488. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  89489. */
  89490. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  89491. }
  89492. /**
  89493. * This class is used to track a performance counter which is number based.
  89494. * The user has access to many properties which give statistics of different nature.
  89495. *
  89496. * The implementer can track two kinds of Performance Counter: time and count.
  89497. * 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.
  89498. * 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.
  89499. */
  89500. export class PerfCounter {
  89501. /**
  89502. * Gets or sets a global boolean to turn on and off all the counters
  89503. */
  89504. static Enabled: boolean;
  89505. /**
  89506. * Returns the smallest value ever
  89507. */
  89508. readonly min: number;
  89509. /**
  89510. * Returns the biggest value ever
  89511. */
  89512. readonly max: number;
  89513. /**
  89514. * Returns the average value since the performance counter is running
  89515. */
  89516. readonly average: number;
  89517. /**
  89518. * Returns the average value of the last second the counter was monitored
  89519. */
  89520. readonly lastSecAverage: number;
  89521. /**
  89522. * Returns the current value
  89523. */
  89524. readonly current: number;
  89525. /**
  89526. * Gets the accumulated total
  89527. */
  89528. readonly total: number;
  89529. /**
  89530. * Gets the total value count
  89531. */
  89532. readonly count: number;
  89533. /**
  89534. * Creates a new counter
  89535. */
  89536. constructor();
  89537. /**
  89538. * Call this method to start monitoring a new frame.
  89539. * 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.
  89540. */
  89541. fetchNewFrame(): void;
  89542. /**
  89543. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  89544. * @param newCount the count value to add to the monitored count
  89545. * @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.
  89546. */
  89547. addCount(newCount: number, fetchResult: boolean): void;
  89548. /**
  89549. * Start monitoring this performance counter
  89550. */
  89551. beginMonitoring(): void;
  89552. /**
  89553. * Compute the time lapsed since the previous beginMonitoring() call.
  89554. * @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
  89555. */
  89556. endMonitoring(newFrame?: boolean): void;
  89557. private _fetchResult;
  89558. private _startMonitoringTime;
  89559. private _min;
  89560. private _max;
  89561. private _average;
  89562. private _current;
  89563. private _totalValueCount;
  89564. private _totalAccumulated;
  89565. private _lastSecAverage;
  89566. private _lastSecAccumulated;
  89567. private _lastSecTime;
  89568. private _lastSecValueCount;
  89569. }
  89570. /**
  89571. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  89572. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  89573. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  89574. * @param name The name of the class, case should be preserved
  89575. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  89576. */
  89577. export function className(name: string, module?: string): (target: Object) => void;
  89578. /**
  89579. * An implementation of a loop for asynchronous functions.
  89580. */
  89581. export class AsyncLoop {
  89582. /**
  89583. * Defines the number of iterations for the loop
  89584. */
  89585. iterations: number;
  89586. /**
  89587. * Defines the current index of the loop.
  89588. */
  89589. index: number;
  89590. private _done;
  89591. private _fn;
  89592. private _successCallback;
  89593. /**
  89594. * Constructor.
  89595. * @param iterations the number of iterations.
  89596. * @param func the function to run each iteration
  89597. * @param successCallback the callback that will be called upon succesful execution
  89598. * @param offset starting offset.
  89599. */
  89600. constructor(
  89601. /**
  89602. * Defines the number of iterations for the loop
  89603. */
  89604. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  89605. /**
  89606. * Execute the next iteration. Must be called after the last iteration was finished.
  89607. */
  89608. executeNext(): void;
  89609. /**
  89610. * Break the loop and run the success callback.
  89611. */
  89612. breakLoop(): void;
  89613. /**
  89614. * Create and run an async loop.
  89615. * @param iterations the number of iterations.
  89616. * @param fn the function to run each iteration
  89617. * @param successCallback the callback that will be called upon succesful execution
  89618. * @param offset starting offset.
  89619. * @returns the created async loop object
  89620. */
  89621. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  89622. /**
  89623. * A for-loop that will run a given number of iterations synchronous and the rest async.
  89624. * @param iterations total number of iterations
  89625. * @param syncedIterations number of synchronous iterations in each async iteration.
  89626. * @param fn the function to call each iteration.
  89627. * @param callback a success call back that will be called when iterating stops.
  89628. * @param breakFunction a break condition (optional)
  89629. * @param timeout timeout settings for the setTimeout function. default - 0.
  89630. * @returns the created async loop object
  89631. */
  89632. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  89633. }
  89634. }
  89635. declare module BABYLON {
  89636. /** @hidden */
  89637. export interface ICollisionCoordinator {
  89638. createCollider(): Collider;
  89639. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  89640. init(scene: Scene): void;
  89641. }
  89642. /** @hidden */
  89643. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  89644. private _scene;
  89645. private _scaledPosition;
  89646. private _scaledVelocity;
  89647. private _finalPosition;
  89648. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  89649. createCollider(): Collider;
  89650. init(scene: Scene): void;
  89651. private _collideWithWorld;
  89652. }
  89653. }
  89654. declare module BABYLON {
  89655. /**
  89656. * This class defines the direct association between an animation and a target
  89657. */
  89658. export class TargetedAnimation {
  89659. /**
  89660. * Animation to perform
  89661. */
  89662. animation: Animation;
  89663. /**
  89664. * Target to animate
  89665. */
  89666. target: any;
  89667. }
  89668. /**
  89669. * Use this class to create coordinated animations on multiple targets
  89670. */
  89671. export class AnimationGroup implements IDisposable {
  89672. /** The name of the animation group */
  89673. name: string;
  89674. private _scene;
  89675. private _targetedAnimations;
  89676. private _animatables;
  89677. private _from;
  89678. private _to;
  89679. private _isStarted;
  89680. private _isPaused;
  89681. private _speedRatio;
  89682. /**
  89683. * Gets or sets the unique id of the node
  89684. */
  89685. uniqueId: number;
  89686. /**
  89687. * This observable will notify when one animation have ended
  89688. */
  89689. onAnimationEndObservable: Observable<TargetedAnimation>;
  89690. /**
  89691. * Observer raised when one animation loops
  89692. */
  89693. onAnimationLoopObservable: Observable<TargetedAnimation>;
  89694. /**
  89695. * This observable will notify when all animations have ended.
  89696. */
  89697. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  89698. /**
  89699. * This observable will notify when all animations have paused.
  89700. */
  89701. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  89702. /**
  89703. * This observable will notify when all animations are playing.
  89704. */
  89705. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  89706. /**
  89707. * Gets the first frame
  89708. */
  89709. readonly from: number;
  89710. /**
  89711. * Gets the last frame
  89712. */
  89713. readonly to: number;
  89714. /**
  89715. * Define if the animations are started
  89716. */
  89717. readonly isStarted: boolean;
  89718. /**
  89719. * Gets a value indicating that the current group is playing
  89720. */
  89721. readonly isPlaying: boolean;
  89722. /**
  89723. * Gets or sets the speed ratio to use for all animations
  89724. */
  89725. /**
  89726. * Gets or sets the speed ratio to use for all animations
  89727. */
  89728. speedRatio: number;
  89729. /**
  89730. * Gets the targeted animations for this animation group
  89731. */
  89732. readonly targetedAnimations: Array<TargetedAnimation>;
  89733. /**
  89734. * returning the list of animatables controlled by this animation group.
  89735. */
  89736. readonly animatables: Array<Animatable>;
  89737. /**
  89738. * Instantiates a new Animation Group.
  89739. * This helps managing several animations at once.
  89740. * @see http://doc.babylonjs.com/how_to/group
  89741. * @param name Defines the name of the group
  89742. * @param scene Defines the scene the group belongs to
  89743. */
  89744. constructor(
  89745. /** The name of the animation group */
  89746. name: string, scene?: Nullable<Scene>);
  89747. /**
  89748. * Add an animation (with its target) in the group
  89749. * @param animation defines the animation we want to add
  89750. * @param target defines the target of the animation
  89751. * @returns the TargetedAnimation object
  89752. */
  89753. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  89754. /**
  89755. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  89756. * It can add constant keys at begin or end
  89757. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  89758. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  89759. * @returns the animation group
  89760. */
  89761. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  89762. /**
  89763. * Start all animations on given targets
  89764. * @param loop defines if animations must loop
  89765. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  89766. * @param from defines the from key (optional)
  89767. * @param to defines the to key (optional)
  89768. * @returns the current animation group
  89769. */
  89770. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  89771. /**
  89772. * Pause all animations
  89773. * @returns the animation group
  89774. */
  89775. pause(): AnimationGroup;
  89776. /**
  89777. * Play all animations to initial state
  89778. * This function will start() the animations if they were not started or will restart() them if they were paused
  89779. * @param loop defines if animations must loop
  89780. * @returns the animation group
  89781. */
  89782. play(loop?: boolean): AnimationGroup;
  89783. /**
  89784. * Reset all animations to initial state
  89785. * @returns the animation group
  89786. */
  89787. reset(): AnimationGroup;
  89788. /**
  89789. * Restart animations from key 0
  89790. * @returns the animation group
  89791. */
  89792. restart(): AnimationGroup;
  89793. /**
  89794. * Stop all animations
  89795. * @returns the animation group
  89796. */
  89797. stop(): AnimationGroup;
  89798. /**
  89799. * Set animation weight for all animatables
  89800. * @param weight defines the weight to use
  89801. * @return the animationGroup
  89802. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  89803. */
  89804. setWeightForAllAnimatables(weight: number): AnimationGroup;
  89805. /**
  89806. * Synchronize and normalize all animatables with a source animatable
  89807. * @param root defines the root animatable to synchronize with
  89808. * @return the animationGroup
  89809. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  89810. */
  89811. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  89812. /**
  89813. * Goes to a specific frame in this animation group
  89814. * @param frame the frame number to go to
  89815. * @return the animationGroup
  89816. */
  89817. goToFrame(frame: number): AnimationGroup;
  89818. /**
  89819. * Dispose all associated resources
  89820. */
  89821. dispose(): void;
  89822. private _checkAnimationGroupEnded;
  89823. /**
  89824. * Clone the current animation group and returns a copy
  89825. * @param newName defines the name of the new group
  89826. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  89827. * @returns the new aniamtion group
  89828. */
  89829. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  89830. /**
  89831. * Returns a new AnimationGroup object parsed from the source provided.
  89832. * @param parsedAnimationGroup defines the source
  89833. * @param scene defines the scene that will receive the animationGroup
  89834. * @returns a new AnimationGroup
  89835. */
  89836. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  89837. /**
  89838. * Returns the string "AnimationGroup"
  89839. * @returns "AnimationGroup"
  89840. */
  89841. getClassName(): string;
  89842. /**
  89843. * Creates a detailled string about the object
  89844. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  89845. * @returns a string representing the object
  89846. */
  89847. toString(fullDetails?: boolean): string;
  89848. }
  89849. }
  89850. declare module BABYLON {
  89851. /**
  89852. * Define an interface for all classes that will hold resources
  89853. */
  89854. export interface IDisposable {
  89855. /**
  89856. * Releases all held resources
  89857. */
  89858. dispose(): void;
  89859. }
  89860. /** Interface defining initialization parameters for Scene class */
  89861. export interface SceneOptions {
  89862. /**
  89863. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  89864. * It will improve performance when the number of geometries becomes important.
  89865. */
  89866. useGeometryUniqueIdsMap?: boolean;
  89867. /**
  89868. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  89869. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  89870. */
  89871. useMaterialMeshMap?: boolean;
  89872. /**
  89873. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  89874. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  89875. */
  89876. useClonedMeshhMap?: boolean;
  89877. }
  89878. /**
  89879. * Represents a scene to be rendered by the engine.
  89880. * @see http://doc.babylonjs.com/features/scene
  89881. */
  89882. export class Scene extends AbstractScene implements IAnimatable {
  89883. private static _uniqueIdCounter;
  89884. /** The fog is deactivated */
  89885. static readonly FOGMODE_NONE: number;
  89886. /** The fog density is following an exponential function */
  89887. static readonly FOGMODE_EXP: number;
  89888. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  89889. static readonly FOGMODE_EXP2: number;
  89890. /** The fog density is following a linear function. */
  89891. static readonly FOGMODE_LINEAR: number;
  89892. /**
  89893. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  89894. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89895. */
  89896. static MinDeltaTime: number;
  89897. /**
  89898. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  89899. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89900. */
  89901. static MaxDeltaTime: number;
  89902. /**
  89903. * Factory used to create the default material.
  89904. * @param name The name of the material to create
  89905. * @param scene The scene to create the material for
  89906. * @returns The default material
  89907. */
  89908. static DefaultMaterialFactory(scene: Scene): Material;
  89909. /**
  89910. * Factory used to create the a collision coordinator.
  89911. * @returns The collision coordinator
  89912. */
  89913. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  89914. /** @hidden */
  89915. readonly _isScene: boolean;
  89916. /**
  89917. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  89918. */
  89919. autoClear: boolean;
  89920. /**
  89921. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  89922. */
  89923. autoClearDepthAndStencil: boolean;
  89924. /**
  89925. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  89926. */
  89927. clearColor: Color4;
  89928. /**
  89929. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  89930. */
  89931. ambientColor: Color3;
  89932. /** @hidden */
  89933. _environmentBRDFTexture: BaseTexture;
  89934. /** @hidden */
  89935. protected _environmentTexture: Nullable<BaseTexture>;
  89936. /**
  89937. * Texture used in all pbr material as the reflection texture.
  89938. * As in the majority of the scene they are the same (exception for multi room and so on),
  89939. * this is easier to reference from here than from all the materials.
  89940. */
  89941. /**
  89942. * Texture used in all pbr material as the reflection texture.
  89943. * As in the majority of the scene they are the same (exception for multi room and so on),
  89944. * this is easier to set here than in all the materials.
  89945. */
  89946. environmentTexture: Nullable<BaseTexture>;
  89947. /** @hidden */
  89948. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  89949. /**
  89950. * Default image processing configuration used either in the rendering
  89951. * Forward main pass or through the imageProcessingPostProcess if present.
  89952. * As in the majority of the scene they are the same (exception for multi camera),
  89953. * this is easier to reference from here than from all the materials and post process.
  89954. *
  89955. * No setter as we it is a shared configuration, you can set the values instead.
  89956. */
  89957. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  89958. private _forceWireframe;
  89959. /**
  89960. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  89961. */
  89962. forceWireframe: boolean;
  89963. private _forcePointsCloud;
  89964. /**
  89965. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  89966. */
  89967. forcePointsCloud: boolean;
  89968. /**
  89969. * Gets or sets the active clipplane 1
  89970. */
  89971. clipPlane: Nullable<Plane>;
  89972. /**
  89973. * Gets or sets the active clipplane 2
  89974. */
  89975. clipPlane2: Nullable<Plane>;
  89976. /**
  89977. * Gets or sets the active clipplane 3
  89978. */
  89979. clipPlane3: Nullable<Plane>;
  89980. /**
  89981. * Gets or sets the active clipplane 4
  89982. */
  89983. clipPlane4: Nullable<Plane>;
  89984. /**
  89985. * Gets or sets a boolean indicating if animations are enabled
  89986. */
  89987. animationsEnabled: boolean;
  89988. private _animationPropertiesOverride;
  89989. /**
  89990. * Gets or sets the animation properties override
  89991. */
  89992. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  89993. /**
  89994. * Gets or sets a boolean indicating if a constant deltatime has to be used
  89995. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  89996. */
  89997. useConstantAnimationDeltaTime: boolean;
  89998. /**
  89999. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  90000. * Please note that it requires to run a ray cast through the scene on every frame
  90001. */
  90002. constantlyUpdateMeshUnderPointer: boolean;
  90003. /**
  90004. * Defines the HTML cursor to use when hovering over interactive elements
  90005. */
  90006. hoverCursor: string;
  90007. /**
  90008. * Defines the HTML default cursor to use (empty by default)
  90009. */
  90010. defaultCursor: string;
  90011. /**
  90012. * This is used to call preventDefault() on pointer down
  90013. * in order to block unwanted artifacts like system double clicks
  90014. */
  90015. preventDefaultOnPointerDown: boolean;
  90016. /**
  90017. * This is used to call preventDefault() on pointer up
  90018. * in order to block unwanted artifacts like system double clicks
  90019. */
  90020. preventDefaultOnPointerUp: boolean;
  90021. /**
  90022. * Gets or sets user defined metadata
  90023. */
  90024. metadata: any;
  90025. /**
  90026. * For internal use only. Please do not use.
  90027. */
  90028. reservedDataStore: any;
  90029. /**
  90030. * Gets the name of the plugin used to load this scene (null by default)
  90031. */
  90032. loadingPluginName: string;
  90033. /**
  90034. * Use this array to add regular expressions used to disable offline support for specific urls
  90035. */
  90036. disableOfflineSupportExceptionRules: RegExp[];
  90037. /**
  90038. * An event triggered when the scene is disposed.
  90039. */
  90040. onDisposeObservable: Observable<Scene>;
  90041. private _onDisposeObserver;
  90042. /** Sets a function to be executed when this scene is disposed. */
  90043. onDispose: () => void;
  90044. /**
  90045. * An event triggered before rendering the scene (right after animations and physics)
  90046. */
  90047. onBeforeRenderObservable: Observable<Scene>;
  90048. private _onBeforeRenderObserver;
  90049. /** Sets a function to be executed before rendering this scene */
  90050. beforeRender: Nullable<() => void>;
  90051. /**
  90052. * An event triggered after rendering the scene
  90053. */
  90054. onAfterRenderObservable: Observable<Scene>;
  90055. private _onAfterRenderObserver;
  90056. /** Sets a function to be executed after rendering this scene */
  90057. afterRender: Nullable<() => void>;
  90058. /**
  90059. * An event triggered before animating the scene
  90060. */
  90061. onBeforeAnimationsObservable: Observable<Scene>;
  90062. /**
  90063. * An event triggered after animations processing
  90064. */
  90065. onAfterAnimationsObservable: Observable<Scene>;
  90066. /**
  90067. * An event triggered before draw calls are ready to be sent
  90068. */
  90069. onBeforeDrawPhaseObservable: Observable<Scene>;
  90070. /**
  90071. * An event triggered after draw calls have been sent
  90072. */
  90073. onAfterDrawPhaseObservable: Observable<Scene>;
  90074. /**
  90075. * An event triggered when the scene is ready
  90076. */
  90077. onReadyObservable: Observable<Scene>;
  90078. /**
  90079. * An event triggered before rendering a camera
  90080. */
  90081. onBeforeCameraRenderObservable: Observable<Camera>;
  90082. private _onBeforeCameraRenderObserver;
  90083. /** Sets a function to be executed before rendering a camera*/
  90084. beforeCameraRender: () => void;
  90085. /**
  90086. * An event triggered after rendering a camera
  90087. */
  90088. onAfterCameraRenderObservable: Observable<Camera>;
  90089. private _onAfterCameraRenderObserver;
  90090. /** Sets a function to be executed after rendering a camera*/
  90091. afterCameraRender: () => void;
  90092. /**
  90093. * An event triggered when active meshes evaluation is about to start
  90094. */
  90095. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  90096. /**
  90097. * An event triggered when active meshes evaluation is done
  90098. */
  90099. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  90100. /**
  90101. * An event triggered when particles rendering is about to start
  90102. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  90103. */
  90104. onBeforeParticlesRenderingObservable: Observable<Scene>;
  90105. /**
  90106. * An event triggered when particles rendering is done
  90107. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  90108. */
  90109. onAfterParticlesRenderingObservable: Observable<Scene>;
  90110. /**
  90111. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  90112. */
  90113. onDataLoadedObservable: Observable<Scene>;
  90114. /**
  90115. * An event triggered when a camera is created
  90116. */
  90117. onNewCameraAddedObservable: Observable<Camera>;
  90118. /**
  90119. * An event triggered when a camera is removed
  90120. */
  90121. onCameraRemovedObservable: Observable<Camera>;
  90122. /**
  90123. * An event triggered when a light is created
  90124. */
  90125. onNewLightAddedObservable: Observable<Light>;
  90126. /**
  90127. * An event triggered when a light is removed
  90128. */
  90129. onLightRemovedObservable: Observable<Light>;
  90130. /**
  90131. * An event triggered when a geometry is created
  90132. */
  90133. onNewGeometryAddedObservable: Observable<Geometry>;
  90134. /**
  90135. * An event triggered when a geometry is removed
  90136. */
  90137. onGeometryRemovedObservable: Observable<Geometry>;
  90138. /**
  90139. * An event triggered when a transform node is created
  90140. */
  90141. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  90142. /**
  90143. * An event triggered when a transform node is removed
  90144. */
  90145. onTransformNodeRemovedObservable: Observable<TransformNode>;
  90146. /**
  90147. * An event triggered when a mesh is created
  90148. */
  90149. onNewMeshAddedObservable: Observable<AbstractMesh>;
  90150. /**
  90151. * An event triggered when a mesh is removed
  90152. */
  90153. onMeshRemovedObservable: Observable<AbstractMesh>;
  90154. /**
  90155. * An event triggered when a skeleton is created
  90156. */
  90157. onNewSkeletonAddedObservable: Observable<Skeleton>;
  90158. /**
  90159. * An event triggered when a skeleton is removed
  90160. */
  90161. onSkeletonRemovedObservable: Observable<Skeleton>;
  90162. /**
  90163. * An event triggered when a material is created
  90164. */
  90165. onNewMaterialAddedObservable: Observable<Material>;
  90166. /**
  90167. * An event triggered when a material is removed
  90168. */
  90169. onMaterialRemovedObservable: Observable<Material>;
  90170. /**
  90171. * An event triggered when a texture is created
  90172. */
  90173. onNewTextureAddedObservable: Observable<BaseTexture>;
  90174. /**
  90175. * An event triggered when a texture is removed
  90176. */
  90177. onTextureRemovedObservable: Observable<BaseTexture>;
  90178. /**
  90179. * An event triggered when render targets are about to be rendered
  90180. * Can happen multiple times per frame.
  90181. */
  90182. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  90183. /**
  90184. * An event triggered when render targets were rendered.
  90185. * Can happen multiple times per frame.
  90186. */
  90187. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  90188. /**
  90189. * An event triggered before calculating deterministic simulation step
  90190. */
  90191. onBeforeStepObservable: Observable<Scene>;
  90192. /**
  90193. * An event triggered after calculating deterministic simulation step
  90194. */
  90195. onAfterStepObservable: Observable<Scene>;
  90196. /**
  90197. * An event triggered when the activeCamera property is updated
  90198. */
  90199. onActiveCameraChanged: Observable<Scene>;
  90200. /**
  90201. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  90202. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  90203. * 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)
  90204. */
  90205. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  90206. /**
  90207. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  90208. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  90209. * 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)
  90210. */
  90211. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  90212. /**
  90213. * This Observable will when a mesh has been imported into the scene.
  90214. */
  90215. onMeshImportedObservable: Observable<AbstractMesh>;
  90216. /**
  90217. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  90218. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  90219. */
  90220. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  90221. /** @hidden */
  90222. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  90223. /**
  90224. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  90225. */
  90226. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  90227. /**
  90228. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  90229. */
  90230. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  90231. /**
  90232. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  90233. */
  90234. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  90235. private _onPointerMove;
  90236. private _onPointerDown;
  90237. private _onPointerUp;
  90238. /** Callback called when a pointer move is detected */
  90239. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  90240. /** Callback called when a pointer down is detected */
  90241. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  90242. /** Callback called when a pointer up is detected */
  90243. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  90244. /** Callback called when a pointer pick is detected */
  90245. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  90246. /**
  90247. * 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).
  90248. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  90249. */
  90250. onPrePointerObservable: Observable<PointerInfoPre>;
  90251. /**
  90252. * Observable event triggered each time an input event is received from the rendering canvas
  90253. */
  90254. onPointerObservable: Observable<PointerInfo>;
  90255. /**
  90256. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  90257. */
  90258. readonly unTranslatedPointer: Vector2;
  90259. /** The distance in pixel that you have to move to prevent some events */
  90260. static DragMovementThreshold: number;
  90261. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  90262. static LongPressDelay: number;
  90263. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  90264. static DoubleClickDelay: number;
  90265. /** If you need to check double click without raising a single click at first click, enable this flag */
  90266. static ExclusiveDoubleClickMode: boolean;
  90267. private _initClickEvent;
  90268. private _initActionManager;
  90269. private _delayedSimpleClick;
  90270. private _delayedSimpleClickTimeout;
  90271. private _previousDelayedSimpleClickTimeout;
  90272. private _meshPickProceed;
  90273. private _previousButtonPressed;
  90274. private _currentPickResult;
  90275. private _previousPickResult;
  90276. private _totalPointersPressed;
  90277. private _doubleClickOccured;
  90278. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  90279. cameraToUseForPointers: Nullable<Camera>;
  90280. private _pointerX;
  90281. private _pointerY;
  90282. private _unTranslatedPointerX;
  90283. private _unTranslatedPointerY;
  90284. private _startingPointerPosition;
  90285. private _previousStartingPointerPosition;
  90286. private _startingPointerTime;
  90287. private _previousStartingPointerTime;
  90288. private _pointerCaptures;
  90289. private _timeAccumulator;
  90290. private _currentStepId;
  90291. private _currentInternalStep;
  90292. /** @hidden */
  90293. _mirroredCameraPosition: Nullable<Vector3>;
  90294. /**
  90295. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  90296. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  90297. */
  90298. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  90299. /**
  90300. * Observable event triggered each time an keyboard event is received from the hosting window
  90301. */
  90302. onKeyboardObservable: Observable<KeyboardInfo>;
  90303. private _onKeyDown;
  90304. private _onKeyUp;
  90305. private _onCanvasFocusObserver;
  90306. private _onCanvasBlurObserver;
  90307. private _useRightHandedSystem;
  90308. /**
  90309. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  90310. */
  90311. useRightHandedSystem: boolean;
  90312. /**
  90313. * Sets the step Id used by deterministic lock step
  90314. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90315. * @param newStepId defines the step Id
  90316. */
  90317. setStepId(newStepId: number): void;
  90318. /**
  90319. * Gets the step Id used by deterministic lock step
  90320. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90321. * @returns the step Id
  90322. */
  90323. getStepId(): number;
  90324. /**
  90325. * Gets the internal step used by deterministic lock step
  90326. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90327. * @returns the internal step
  90328. */
  90329. getInternalStep(): number;
  90330. private _fogEnabled;
  90331. /**
  90332. * Gets or sets a boolean indicating if fog is enabled on this scene
  90333. * @see http://doc.babylonjs.com/babylon101/environment#fog
  90334. * (Default is true)
  90335. */
  90336. fogEnabled: boolean;
  90337. private _fogMode;
  90338. /**
  90339. * Gets or sets the fog mode to use
  90340. * @see http://doc.babylonjs.com/babylon101/environment#fog
  90341. * | mode | value |
  90342. * | --- | --- |
  90343. * | FOGMODE_NONE | 0 |
  90344. * | FOGMODE_EXP | 1 |
  90345. * | FOGMODE_EXP2 | 2 |
  90346. * | FOGMODE_LINEAR | 3 |
  90347. */
  90348. fogMode: number;
  90349. /**
  90350. * Gets or sets the fog color to use
  90351. * @see http://doc.babylonjs.com/babylon101/environment#fog
  90352. * (Default is Color3(0.2, 0.2, 0.3))
  90353. */
  90354. fogColor: Color3;
  90355. /**
  90356. * Gets or sets the fog density to use
  90357. * @see http://doc.babylonjs.com/babylon101/environment#fog
  90358. * (Default is 0.1)
  90359. */
  90360. fogDensity: number;
  90361. /**
  90362. * Gets or sets the fog start distance to use
  90363. * @see http://doc.babylonjs.com/babylon101/environment#fog
  90364. * (Default is 0)
  90365. */
  90366. fogStart: number;
  90367. /**
  90368. * Gets or sets the fog end distance to use
  90369. * @see http://doc.babylonjs.com/babylon101/environment#fog
  90370. * (Default is 1000)
  90371. */
  90372. fogEnd: number;
  90373. private _shadowsEnabled;
  90374. /**
  90375. * Gets or sets a boolean indicating if shadows are enabled on this scene
  90376. */
  90377. shadowsEnabled: boolean;
  90378. private _lightsEnabled;
  90379. /**
  90380. * Gets or sets a boolean indicating if lights are enabled on this scene
  90381. */
  90382. lightsEnabled: boolean;
  90383. /** All of the active cameras added to this scene. */
  90384. activeCameras: Camera[];
  90385. private _activeCamera;
  90386. /** Gets or sets the current active camera */
  90387. activeCamera: Nullable<Camera>;
  90388. private _defaultMaterial;
  90389. /** The default material used on meshes when no material is affected */
  90390. /** The default material used on meshes when no material is affected */
  90391. defaultMaterial: Material;
  90392. private _texturesEnabled;
  90393. /**
  90394. * Gets or sets a boolean indicating if textures are enabled on this scene
  90395. */
  90396. texturesEnabled: boolean;
  90397. /**
  90398. * Gets or sets a boolean indicating if particles are enabled on this scene
  90399. */
  90400. particlesEnabled: boolean;
  90401. /**
  90402. * Gets or sets a boolean indicating if sprites are enabled on this scene
  90403. */
  90404. spritesEnabled: boolean;
  90405. private _skeletonsEnabled;
  90406. /**
  90407. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  90408. */
  90409. skeletonsEnabled: boolean;
  90410. /**
  90411. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  90412. */
  90413. lensFlaresEnabled: boolean;
  90414. /**
  90415. * Gets or sets a boolean indicating if collisions are enabled on this scene
  90416. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90417. */
  90418. collisionsEnabled: boolean;
  90419. private _collisionCoordinator;
  90420. /** @hidden */
  90421. readonly collisionCoordinator: ICollisionCoordinator;
  90422. /**
  90423. * Defines the gravity applied to this scene (used only for collisions)
  90424. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90425. */
  90426. gravity: Vector3;
  90427. /**
  90428. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  90429. */
  90430. postProcessesEnabled: boolean;
  90431. /**
  90432. * The list of postprocesses added to the scene
  90433. */
  90434. postProcesses: PostProcess[];
  90435. /**
  90436. * Gets the current postprocess manager
  90437. */
  90438. postProcessManager: PostProcessManager;
  90439. /**
  90440. * Gets or sets a boolean indicating if render targets are enabled on this scene
  90441. */
  90442. renderTargetsEnabled: boolean;
  90443. /**
  90444. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  90445. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  90446. */
  90447. dumpNextRenderTargets: boolean;
  90448. /**
  90449. * The list of user defined render targets added to the scene
  90450. */
  90451. customRenderTargets: RenderTargetTexture[];
  90452. /**
  90453. * Defines if texture loading must be delayed
  90454. * If true, textures will only be loaded when they need to be rendered
  90455. */
  90456. useDelayedTextureLoading: boolean;
  90457. /**
  90458. * Gets the list of meshes imported to the scene through SceneLoader
  90459. */
  90460. importedMeshesFiles: String[];
  90461. /**
  90462. * Gets or sets a boolean indicating if probes are enabled on this scene
  90463. */
  90464. probesEnabled: boolean;
  90465. /**
  90466. * Gets or sets the current offline provider to use to store scene data
  90467. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  90468. */
  90469. offlineProvider: IOfflineProvider;
  90470. /**
  90471. * Gets or sets the action manager associated with the scene
  90472. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90473. */
  90474. actionManager: AbstractActionManager;
  90475. private _meshesForIntersections;
  90476. /**
  90477. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  90478. */
  90479. proceduralTexturesEnabled: boolean;
  90480. private _engine;
  90481. private _totalVertices;
  90482. /** @hidden */
  90483. _activeIndices: PerfCounter;
  90484. /** @hidden */
  90485. _activeParticles: PerfCounter;
  90486. /** @hidden */
  90487. _activeBones: PerfCounter;
  90488. private _animationRatio;
  90489. /** @hidden */
  90490. _animationTimeLast: number;
  90491. /** @hidden */
  90492. _animationTime: number;
  90493. /**
  90494. * Gets or sets a general scale for animation speed
  90495. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  90496. */
  90497. animationTimeScale: number;
  90498. /** @hidden */
  90499. _cachedMaterial: Nullable<Material>;
  90500. /** @hidden */
  90501. _cachedEffect: Nullable<Effect>;
  90502. /** @hidden */
  90503. _cachedVisibility: Nullable<number>;
  90504. private _renderId;
  90505. private _frameId;
  90506. private _executeWhenReadyTimeoutId;
  90507. private _intermediateRendering;
  90508. private _viewUpdateFlag;
  90509. private _projectionUpdateFlag;
  90510. private _alternateViewUpdateFlag;
  90511. private _alternateProjectionUpdateFlag;
  90512. /** @hidden */
  90513. _toBeDisposed: Nullable<IDisposable>[];
  90514. private _activeRequests;
  90515. /** @hidden */
  90516. _pendingData: any[];
  90517. private _isDisposed;
  90518. /**
  90519. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  90520. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  90521. */
  90522. dispatchAllSubMeshesOfActiveMeshes: boolean;
  90523. private _activeMeshes;
  90524. private _processedMaterials;
  90525. private _renderTargets;
  90526. /** @hidden */
  90527. _activeParticleSystems: SmartArray<IParticleSystem>;
  90528. private _activeSkeletons;
  90529. private _softwareSkinnedMeshes;
  90530. private _renderingManager;
  90531. /** @hidden */
  90532. _activeAnimatables: Animatable[];
  90533. private _transformMatrix;
  90534. private _sceneUbo;
  90535. private _alternateSceneUbo;
  90536. private _viewMatrix;
  90537. private _projectionMatrix;
  90538. private _alternateViewMatrix;
  90539. private _alternateProjectionMatrix;
  90540. private _alternateTransformMatrix;
  90541. private _useAlternateCameraConfiguration;
  90542. private _alternateRendering;
  90543. private _wheelEventName;
  90544. /** @hidden */
  90545. _forcedViewPosition: Nullable<Vector3>;
  90546. /** @hidden */
  90547. readonly _isAlternateRenderingEnabled: boolean;
  90548. private _frustumPlanes;
  90549. /**
  90550. * Gets the list of frustum planes (built from the active camera)
  90551. */
  90552. readonly frustumPlanes: Plane[];
  90553. /**
  90554. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  90555. * This is useful if there are more lights that the maximum simulteanous authorized
  90556. */
  90557. requireLightSorting: boolean;
  90558. /** @hidden */
  90559. readonly useMaterialMeshMap: boolean;
  90560. /** @hidden */
  90561. readonly useClonedMeshhMap: boolean;
  90562. private _pointerOverMesh;
  90563. private _pickedDownMesh;
  90564. private _pickedUpMesh;
  90565. private _externalData;
  90566. private _uid;
  90567. /**
  90568. * @hidden
  90569. * Backing store of defined scene components.
  90570. */
  90571. _components: ISceneComponent[];
  90572. /**
  90573. * @hidden
  90574. * Backing store of defined scene components.
  90575. */
  90576. _serializableComponents: ISceneSerializableComponent[];
  90577. /**
  90578. * List of components to register on the next registration step.
  90579. */
  90580. private _transientComponents;
  90581. /**
  90582. * Registers the transient components if needed.
  90583. */
  90584. private _registerTransientComponents;
  90585. /**
  90586. * @hidden
  90587. * Add a component to the scene.
  90588. * Note that the ccomponent could be registered on th next frame if this is called after
  90589. * the register component stage.
  90590. * @param component Defines the component to add to the scene
  90591. */
  90592. _addComponent(component: ISceneComponent): void;
  90593. /**
  90594. * @hidden
  90595. * Gets a component from the scene.
  90596. * @param name defines the name of the component to retrieve
  90597. * @returns the component or null if not present
  90598. */
  90599. _getComponent(name: string): Nullable<ISceneComponent>;
  90600. /**
  90601. * @hidden
  90602. * Defines the actions happening before camera updates.
  90603. */
  90604. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  90605. /**
  90606. * @hidden
  90607. * Defines the actions happening before clear the canvas.
  90608. */
  90609. _beforeClearStage: Stage<SimpleStageAction>;
  90610. /**
  90611. * @hidden
  90612. * Defines the actions when collecting render targets for the frame.
  90613. */
  90614. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  90615. /**
  90616. * @hidden
  90617. * Defines the actions happening for one camera in the frame.
  90618. */
  90619. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  90620. /**
  90621. * @hidden
  90622. * Defines the actions happening during the per mesh ready checks.
  90623. */
  90624. _isReadyForMeshStage: Stage<MeshStageAction>;
  90625. /**
  90626. * @hidden
  90627. * Defines the actions happening before evaluate active mesh checks.
  90628. */
  90629. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  90630. /**
  90631. * @hidden
  90632. * Defines the actions happening during the evaluate sub mesh checks.
  90633. */
  90634. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  90635. /**
  90636. * @hidden
  90637. * Defines the actions happening during the active mesh stage.
  90638. */
  90639. _activeMeshStage: Stage<ActiveMeshStageAction>;
  90640. /**
  90641. * @hidden
  90642. * Defines the actions happening during the per camera render target step.
  90643. */
  90644. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  90645. /**
  90646. * @hidden
  90647. * Defines the actions happening just before the active camera is drawing.
  90648. */
  90649. _beforeCameraDrawStage: Stage<CameraStageAction>;
  90650. /**
  90651. * @hidden
  90652. * Defines the actions happening just before a render target is drawing.
  90653. */
  90654. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  90655. /**
  90656. * @hidden
  90657. * Defines the actions happening just before a rendering group is drawing.
  90658. */
  90659. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  90660. /**
  90661. * @hidden
  90662. * Defines the actions happening just before a mesh is drawing.
  90663. */
  90664. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  90665. /**
  90666. * @hidden
  90667. * Defines the actions happening just after a mesh has been drawn.
  90668. */
  90669. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  90670. /**
  90671. * @hidden
  90672. * Defines the actions happening just after a rendering group has been drawn.
  90673. */
  90674. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  90675. /**
  90676. * @hidden
  90677. * Defines the actions happening just after the active camera has been drawn.
  90678. */
  90679. _afterCameraDrawStage: Stage<CameraStageAction>;
  90680. /**
  90681. * @hidden
  90682. * Defines the actions happening just after a render target has been drawn.
  90683. */
  90684. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  90685. /**
  90686. * @hidden
  90687. * Defines the actions happening just after rendering all cameras and computing intersections.
  90688. */
  90689. _afterRenderStage: Stage<SimpleStageAction>;
  90690. /**
  90691. * @hidden
  90692. * Defines the actions happening when a pointer move event happens.
  90693. */
  90694. _pointerMoveStage: Stage<PointerMoveStageAction>;
  90695. /**
  90696. * @hidden
  90697. * Defines the actions happening when a pointer down event happens.
  90698. */
  90699. _pointerDownStage: Stage<PointerUpDownStageAction>;
  90700. /**
  90701. * @hidden
  90702. * Defines the actions happening when a pointer up event happens.
  90703. */
  90704. _pointerUpStage: Stage<PointerUpDownStageAction>;
  90705. /**
  90706. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  90707. */
  90708. private geometriesByUniqueId;
  90709. /**
  90710. * Creates a new Scene
  90711. * @param engine defines the engine to use to render this scene
  90712. * @param options defines the scene options
  90713. */
  90714. constructor(engine: Engine, options?: SceneOptions);
  90715. private _defaultMeshCandidates;
  90716. /**
  90717. * @hidden
  90718. */
  90719. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  90720. private _defaultSubMeshCandidates;
  90721. /**
  90722. * @hidden
  90723. */
  90724. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  90725. /**
  90726. * Sets the default candidate providers for the scene.
  90727. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  90728. * and getCollidingSubMeshCandidates to their default function
  90729. */
  90730. setDefaultCandidateProviders(): void;
  90731. /**
  90732. * Gets the mesh that is currently under the pointer
  90733. */
  90734. readonly meshUnderPointer: Nullable<AbstractMesh>;
  90735. /**
  90736. * Gets or sets the current on-screen X position of the pointer
  90737. */
  90738. pointerX: number;
  90739. /**
  90740. * Gets or sets the current on-screen Y position of the pointer
  90741. */
  90742. pointerY: number;
  90743. /**
  90744. * Gets the cached material (ie. the latest rendered one)
  90745. * @returns the cached material
  90746. */
  90747. getCachedMaterial(): Nullable<Material>;
  90748. /**
  90749. * Gets the cached effect (ie. the latest rendered one)
  90750. * @returns the cached effect
  90751. */
  90752. getCachedEffect(): Nullable<Effect>;
  90753. /**
  90754. * Gets the cached visibility state (ie. the latest rendered one)
  90755. * @returns the cached visibility state
  90756. */
  90757. getCachedVisibility(): Nullable<number>;
  90758. /**
  90759. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  90760. * @param material defines the current material
  90761. * @param effect defines the current effect
  90762. * @param visibility defines the current visibility state
  90763. * @returns true if one parameter is not cached
  90764. */
  90765. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  90766. /**
  90767. * Gets the engine associated with the scene
  90768. * @returns an Engine
  90769. */
  90770. getEngine(): Engine;
  90771. /**
  90772. * Gets the total number of vertices rendered per frame
  90773. * @returns the total number of vertices rendered per frame
  90774. */
  90775. getTotalVertices(): number;
  90776. /**
  90777. * Gets the performance counter for total vertices
  90778. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  90779. */
  90780. readonly totalVerticesPerfCounter: PerfCounter;
  90781. /**
  90782. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  90783. * @returns the total number of active indices rendered per frame
  90784. */
  90785. getActiveIndices(): number;
  90786. /**
  90787. * Gets the performance counter for active indices
  90788. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  90789. */
  90790. readonly totalActiveIndicesPerfCounter: PerfCounter;
  90791. /**
  90792. * Gets the total number of active particles rendered per frame
  90793. * @returns the total number of active particles rendered per frame
  90794. */
  90795. getActiveParticles(): number;
  90796. /**
  90797. * Gets the performance counter for active particles
  90798. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  90799. */
  90800. readonly activeParticlesPerfCounter: PerfCounter;
  90801. /**
  90802. * Gets the total number of active bones rendered per frame
  90803. * @returns the total number of active bones rendered per frame
  90804. */
  90805. getActiveBones(): number;
  90806. /**
  90807. * Gets the performance counter for active bones
  90808. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  90809. */
  90810. readonly activeBonesPerfCounter: PerfCounter;
  90811. /**
  90812. * Gets the array of active meshes
  90813. * @returns an array of AbstractMesh
  90814. */
  90815. getActiveMeshes(): SmartArray<AbstractMesh>;
  90816. /**
  90817. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  90818. * @returns a number
  90819. */
  90820. getAnimationRatio(): number;
  90821. /**
  90822. * Gets an unique Id for the current render phase
  90823. * @returns a number
  90824. */
  90825. getRenderId(): number;
  90826. /**
  90827. * Gets an unique Id for the current frame
  90828. * @returns a number
  90829. */
  90830. getFrameId(): number;
  90831. /** Call this function if you want to manually increment the render Id*/
  90832. incrementRenderId(): void;
  90833. private _updatePointerPosition;
  90834. private _createUbo;
  90835. private _createAlternateUbo;
  90836. private _setRayOnPointerInfo;
  90837. /**
  90838. * Use this method to simulate a pointer move on a mesh
  90839. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  90840. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  90841. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  90842. * @returns the current scene
  90843. */
  90844. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  90845. private _processPointerMove;
  90846. private _checkPrePointerObservable;
  90847. /**
  90848. * Use this method to simulate a pointer down on a mesh
  90849. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  90850. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  90851. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  90852. * @returns the current scene
  90853. */
  90854. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  90855. private _processPointerDown;
  90856. /**
  90857. * Use this method to simulate a pointer up on a mesh
  90858. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  90859. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  90860. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  90861. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  90862. * @returns the current scene
  90863. */
  90864. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  90865. private _processPointerUp;
  90866. /**
  90867. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  90868. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  90869. * @returns true if the pointer was captured
  90870. */
  90871. isPointerCaptured(pointerId?: number): boolean;
  90872. /** @hidden */
  90873. _isPointerSwiping(): boolean;
  90874. /**
  90875. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  90876. * @param attachUp defines if you want to attach events to pointerup
  90877. * @param attachDown defines if you want to attach events to pointerdown
  90878. * @param attachMove defines if you want to attach events to pointermove
  90879. */
  90880. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  90881. /** Detaches all event handlers*/
  90882. detachControl(): void;
  90883. /**
  90884. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  90885. * Delay loaded resources are not taking in account
  90886. * @return true if all required resources are ready
  90887. */
  90888. isReady(): boolean;
  90889. /** Resets all cached information relative to material (including effect and visibility) */
  90890. resetCachedMaterial(): void;
  90891. /**
  90892. * Registers a function to be called before every frame render
  90893. * @param func defines the function to register
  90894. */
  90895. registerBeforeRender(func: () => void): void;
  90896. /**
  90897. * Unregisters a function called before every frame render
  90898. * @param func defines the function to unregister
  90899. */
  90900. unregisterBeforeRender(func: () => void): void;
  90901. /**
  90902. * Registers a function to be called after every frame render
  90903. * @param func defines the function to register
  90904. */
  90905. registerAfterRender(func: () => void): void;
  90906. /**
  90907. * Unregisters a function called after every frame render
  90908. * @param func defines the function to unregister
  90909. */
  90910. unregisterAfterRender(func: () => void): void;
  90911. private _executeOnceBeforeRender;
  90912. /**
  90913. * The provided function will run before render once and will be disposed afterwards.
  90914. * A timeout delay can be provided so that the function will be executed in N ms.
  90915. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  90916. * @param func The function to be executed.
  90917. * @param timeout optional delay in ms
  90918. */
  90919. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  90920. /** @hidden */
  90921. _addPendingData(data: any): void;
  90922. /** @hidden */
  90923. _removePendingData(data: any): void;
  90924. /**
  90925. * Returns the number of items waiting to be loaded
  90926. * @returns the number of items waiting to be loaded
  90927. */
  90928. getWaitingItemsCount(): number;
  90929. /**
  90930. * Returns a boolean indicating if the scene is still loading data
  90931. */
  90932. readonly isLoading: boolean;
  90933. /**
  90934. * Registers a function to be executed when the scene is ready
  90935. * @param {Function} func - the function to be executed
  90936. */
  90937. executeWhenReady(func: () => void): void;
  90938. /**
  90939. * Returns a promise that resolves when the scene is ready
  90940. * @returns A promise that resolves when the scene is ready
  90941. */
  90942. whenReadyAsync(): Promise<void>;
  90943. /** @hidden */
  90944. _checkIsReady(): void;
  90945. /**
  90946. * Gets all animatable attached to the scene
  90947. */
  90948. readonly animatables: Animatable[];
  90949. /**
  90950. * Resets the last animation time frame.
  90951. * Useful to override when animations start running when loading a scene for the first time.
  90952. */
  90953. resetLastAnimationTimeFrame(): void;
  90954. /** @hidden */
  90955. _switchToAlternateCameraConfiguration(active: boolean): void;
  90956. /**
  90957. * Gets the current view matrix
  90958. * @returns a Matrix
  90959. */
  90960. getViewMatrix(): Matrix;
  90961. /**
  90962. * Gets the current projection matrix
  90963. * @returns a Matrix
  90964. */
  90965. getProjectionMatrix(): Matrix;
  90966. /**
  90967. * Gets the current transform matrix
  90968. * @returns a Matrix made of View * Projection
  90969. */
  90970. getTransformMatrix(): Matrix;
  90971. /**
  90972. * Sets the current transform matrix
  90973. * @param view defines the View matrix to use
  90974. * @param projection defines the Projection matrix to use
  90975. */
  90976. setTransformMatrix(view: Matrix, projection: Matrix): void;
  90977. /** @hidden */
  90978. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  90979. /**
  90980. * Gets the uniform buffer used to store scene data
  90981. * @returns a UniformBuffer
  90982. */
  90983. getSceneUniformBuffer(): UniformBuffer;
  90984. /**
  90985. * Gets an unique (relatively to the current scene) Id
  90986. * @returns an unique number for the scene
  90987. */
  90988. getUniqueId(): number;
  90989. /**
  90990. * Add a mesh to the list of scene's meshes
  90991. * @param newMesh defines the mesh to add
  90992. * @param recursive if all child meshes should also be added to the scene
  90993. */
  90994. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  90995. /**
  90996. * Remove a mesh for the list of scene's meshes
  90997. * @param toRemove defines the mesh to remove
  90998. * @param recursive if all child meshes should also be removed from the scene
  90999. * @returns the index where the mesh was in the mesh list
  91000. */
  91001. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  91002. /**
  91003. * Add a transform node to the list of scene's transform nodes
  91004. * @param newTransformNode defines the transform node to add
  91005. */
  91006. addTransformNode(newTransformNode: TransformNode): void;
  91007. /**
  91008. * Remove a transform node for the list of scene's transform nodes
  91009. * @param toRemove defines the transform node to remove
  91010. * @returns the index where the transform node was in the transform node list
  91011. */
  91012. removeTransformNode(toRemove: TransformNode): number;
  91013. /**
  91014. * Remove a skeleton for the list of scene's skeletons
  91015. * @param toRemove defines the skeleton to remove
  91016. * @returns the index where the skeleton was in the skeleton list
  91017. */
  91018. removeSkeleton(toRemove: Skeleton): number;
  91019. /**
  91020. * Remove a morph target for the list of scene's morph targets
  91021. * @param toRemove defines the morph target to remove
  91022. * @returns the index where the morph target was in the morph target list
  91023. */
  91024. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  91025. /**
  91026. * Remove a light for the list of scene's lights
  91027. * @param toRemove defines the light to remove
  91028. * @returns the index where the light was in the light list
  91029. */
  91030. removeLight(toRemove: Light): number;
  91031. /**
  91032. * Remove a camera for the list of scene's cameras
  91033. * @param toRemove defines the camera to remove
  91034. * @returns the index where the camera was in the camera list
  91035. */
  91036. removeCamera(toRemove: Camera): number;
  91037. /**
  91038. * Remove a particle system for the list of scene's particle systems
  91039. * @param toRemove defines the particle system to remove
  91040. * @returns the index where the particle system was in the particle system list
  91041. */
  91042. removeParticleSystem(toRemove: IParticleSystem): number;
  91043. /**
  91044. * Remove a animation for the list of scene's animations
  91045. * @param toRemove defines the animation to remove
  91046. * @returns the index where the animation was in the animation list
  91047. */
  91048. removeAnimation(toRemove: Animation): number;
  91049. /**
  91050. * Removes the given animation group from this scene.
  91051. * @param toRemove The animation group to remove
  91052. * @returns The index of the removed animation group
  91053. */
  91054. removeAnimationGroup(toRemove: AnimationGroup): number;
  91055. /**
  91056. * Removes the given multi-material from this scene.
  91057. * @param toRemove The multi-material to remove
  91058. * @returns The index of the removed multi-material
  91059. */
  91060. removeMultiMaterial(toRemove: MultiMaterial): number;
  91061. /**
  91062. * Removes the given material from this scene.
  91063. * @param toRemove The material to remove
  91064. * @returns The index of the removed material
  91065. */
  91066. removeMaterial(toRemove: Material): number;
  91067. /**
  91068. * Removes the given action manager from this scene.
  91069. * @param toRemove The action manager to remove
  91070. * @returns The index of the removed action manager
  91071. */
  91072. removeActionManager(toRemove: AbstractActionManager): number;
  91073. /**
  91074. * Removes the given texture from this scene.
  91075. * @param toRemove The texture to remove
  91076. * @returns The index of the removed texture
  91077. */
  91078. removeTexture(toRemove: BaseTexture): number;
  91079. /**
  91080. * Adds the given light to this scene
  91081. * @param newLight The light to add
  91082. */
  91083. addLight(newLight: Light): void;
  91084. /**
  91085. * Sorts the list list based on light priorities
  91086. */
  91087. sortLightsByPriority(): void;
  91088. /**
  91089. * Adds the given camera to this scene
  91090. * @param newCamera The camera to add
  91091. */
  91092. addCamera(newCamera: Camera): void;
  91093. /**
  91094. * Adds the given skeleton to this scene
  91095. * @param newSkeleton The skeleton to add
  91096. */
  91097. addSkeleton(newSkeleton: Skeleton): void;
  91098. /**
  91099. * Adds the given particle system to this scene
  91100. * @param newParticleSystem The particle system to add
  91101. */
  91102. addParticleSystem(newParticleSystem: IParticleSystem): void;
  91103. /**
  91104. * Adds the given animation to this scene
  91105. * @param newAnimation The animation to add
  91106. */
  91107. addAnimation(newAnimation: Animation): void;
  91108. /**
  91109. * Adds the given animation group to this scene.
  91110. * @param newAnimationGroup The animation group to add
  91111. */
  91112. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  91113. /**
  91114. * Adds the given multi-material to this scene
  91115. * @param newMultiMaterial The multi-material to add
  91116. */
  91117. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  91118. /**
  91119. * Adds the given material to this scene
  91120. * @param newMaterial The material to add
  91121. */
  91122. addMaterial(newMaterial: Material): void;
  91123. /**
  91124. * Adds the given morph target to this scene
  91125. * @param newMorphTargetManager The morph target to add
  91126. */
  91127. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  91128. /**
  91129. * Adds the given geometry to this scene
  91130. * @param newGeometry The geometry to add
  91131. */
  91132. addGeometry(newGeometry: Geometry): void;
  91133. /**
  91134. * Adds the given action manager to this scene
  91135. * @param newActionManager The action manager to add
  91136. */
  91137. addActionManager(newActionManager: AbstractActionManager): void;
  91138. /**
  91139. * Adds the given texture to this scene.
  91140. * @param newTexture The texture to add
  91141. */
  91142. addTexture(newTexture: BaseTexture): void;
  91143. /**
  91144. * Switch active camera
  91145. * @param newCamera defines the new active camera
  91146. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  91147. */
  91148. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  91149. /**
  91150. * sets the active camera of the scene using its ID
  91151. * @param id defines the camera's ID
  91152. * @return the new active camera or null if none found.
  91153. */
  91154. setActiveCameraByID(id: string): Nullable<Camera>;
  91155. /**
  91156. * sets the active camera of the scene using its name
  91157. * @param name defines the camera's name
  91158. * @returns the new active camera or null if none found.
  91159. */
  91160. setActiveCameraByName(name: string): Nullable<Camera>;
  91161. /**
  91162. * get an animation group using its name
  91163. * @param name defines the material's name
  91164. * @return the animation group or null if none found.
  91165. */
  91166. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  91167. /**
  91168. * Get a material using its unique id
  91169. * @param uniqueId defines the material's unique id
  91170. * @return the material or null if none found.
  91171. */
  91172. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  91173. /**
  91174. * get a material using its id
  91175. * @param id defines the material's ID
  91176. * @return the material or null if none found.
  91177. */
  91178. getMaterialByID(id: string): Nullable<Material>;
  91179. /**
  91180. * Gets a material using its name
  91181. * @param name defines the material's name
  91182. * @return the material or null if none found.
  91183. */
  91184. getMaterialByName(name: string): Nullable<Material>;
  91185. /**
  91186. * Gets a camera using its id
  91187. * @param id defines the id to look for
  91188. * @returns the camera or null if not found
  91189. */
  91190. getCameraByID(id: string): Nullable<Camera>;
  91191. /**
  91192. * Gets a camera using its unique id
  91193. * @param uniqueId defines the unique id to look for
  91194. * @returns the camera or null if not found
  91195. */
  91196. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  91197. /**
  91198. * Gets a camera using its name
  91199. * @param name defines the camera's name
  91200. * @return the camera or null if none found.
  91201. */
  91202. getCameraByName(name: string): Nullable<Camera>;
  91203. /**
  91204. * Gets a bone using its id
  91205. * @param id defines the bone's id
  91206. * @return the bone or null if not found
  91207. */
  91208. getBoneByID(id: string): Nullable<Bone>;
  91209. /**
  91210. * Gets a bone using its id
  91211. * @param name defines the bone's name
  91212. * @return the bone or null if not found
  91213. */
  91214. getBoneByName(name: string): Nullable<Bone>;
  91215. /**
  91216. * Gets a light node using its name
  91217. * @param name defines the the light's name
  91218. * @return the light or null if none found.
  91219. */
  91220. getLightByName(name: string): Nullable<Light>;
  91221. /**
  91222. * Gets a light node using its id
  91223. * @param id defines the light's id
  91224. * @return the light or null if none found.
  91225. */
  91226. getLightByID(id: string): Nullable<Light>;
  91227. /**
  91228. * Gets a light node using its scene-generated unique ID
  91229. * @param uniqueId defines the light's unique id
  91230. * @return the light or null if none found.
  91231. */
  91232. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  91233. /**
  91234. * Gets a particle system by id
  91235. * @param id defines the particle system id
  91236. * @return the corresponding system or null if none found
  91237. */
  91238. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  91239. /**
  91240. * Gets a geometry using its ID
  91241. * @param id defines the geometry's id
  91242. * @return the geometry or null if none found.
  91243. */
  91244. getGeometryByID(id: string): Nullable<Geometry>;
  91245. private _getGeometryByUniqueID;
  91246. /**
  91247. * Add a new geometry to this scene
  91248. * @param geometry defines the geometry to be added to the scene.
  91249. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  91250. * @return a boolean defining if the geometry was added or not
  91251. */
  91252. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  91253. /**
  91254. * Removes an existing geometry
  91255. * @param geometry defines the geometry to be removed from the scene
  91256. * @return a boolean defining if the geometry was removed or not
  91257. */
  91258. removeGeometry(geometry: Geometry): boolean;
  91259. /**
  91260. * Gets the list of geometries attached to the scene
  91261. * @returns an array of Geometry
  91262. */
  91263. getGeometries(): Geometry[];
  91264. /**
  91265. * Gets the first added mesh found of a given ID
  91266. * @param id defines the id to search for
  91267. * @return the mesh found or null if not found at all
  91268. */
  91269. getMeshByID(id: string): Nullable<AbstractMesh>;
  91270. /**
  91271. * Gets a list of meshes using their id
  91272. * @param id defines the id to search for
  91273. * @returns a list of meshes
  91274. */
  91275. getMeshesByID(id: string): Array<AbstractMesh>;
  91276. /**
  91277. * Gets the first added transform node found of a given ID
  91278. * @param id defines the id to search for
  91279. * @return the found transform node or null if not found at all.
  91280. */
  91281. getTransformNodeByID(id: string): Nullable<TransformNode>;
  91282. /**
  91283. * Gets a transform node with its auto-generated unique id
  91284. * @param uniqueId efines the unique id to search for
  91285. * @return the found transform node or null if not found at all.
  91286. */
  91287. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  91288. /**
  91289. * Gets a list of transform nodes using their id
  91290. * @param id defines the id to search for
  91291. * @returns a list of transform nodes
  91292. */
  91293. getTransformNodesByID(id: string): Array<TransformNode>;
  91294. /**
  91295. * Gets a mesh with its auto-generated unique id
  91296. * @param uniqueId defines the unique id to search for
  91297. * @return the found mesh or null if not found at all.
  91298. */
  91299. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  91300. /**
  91301. * Gets a the last added mesh using a given id
  91302. * @param id defines the id to search for
  91303. * @return the found mesh or null if not found at all.
  91304. */
  91305. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  91306. /**
  91307. * Gets a the last added node (Mesh, Camera, Light) using a given id
  91308. * @param id defines the id to search for
  91309. * @return the found node or null if not found at all
  91310. */
  91311. getLastEntryByID(id: string): Nullable<Node>;
  91312. /**
  91313. * Gets a node (Mesh, Camera, Light) using a given id
  91314. * @param id defines the id to search for
  91315. * @return the found node or null if not found at all
  91316. */
  91317. getNodeByID(id: string): Nullable<Node>;
  91318. /**
  91319. * Gets a node (Mesh, Camera, Light) using a given name
  91320. * @param name defines the name to search for
  91321. * @return the found node or null if not found at all.
  91322. */
  91323. getNodeByName(name: string): Nullable<Node>;
  91324. /**
  91325. * Gets a mesh using a given name
  91326. * @param name defines the name to search for
  91327. * @return the found mesh or null if not found at all.
  91328. */
  91329. getMeshByName(name: string): Nullable<AbstractMesh>;
  91330. /**
  91331. * Gets a transform node using a given name
  91332. * @param name defines the name to search for
  91333. * @return the found transform node or null if not found at all.
  91334. */
  91335. getTransformNodeByName(name: string): Nullable<TransformNode>;
  91336. /**
  91337. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  91338. * @param id defines the id to search for
  91339. * @return the found skeleton or null if not found at all.
  91340. */
  91341. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  91342. /**
  91343. * Gets a skeleton using a given auto generated unique id
  91344. * @param uniqueId defines the unique id to search for
  91345. * @return the found skeleton or null if not found at all.
  91346. */
  91347. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  91348. /**
  91349. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  91350. * @param id defines the id to search for
  91351. * @return the found skeleton or null if not found at all.
  91352. */
  91353. getSkeletonById(id: string): Nullable<Skeleton>;
  91354. /**
  91355. * Gets a skeleton using a given name
  91356. * @param name defines the name to search for
  91357. * @return the found skeleton or null if not found at all.
  91358. */
  91359. getSkeletonByName(name: string): Nullable<Skeleton>;
  91360. /**
  91361. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  91362. * @param id defines the id to search for
  91363. * @return the found morph target manager or null if not found at all.
  91364. */
  91365. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  91366. /**
  91367. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  91368. * @param id defines the id to search for
  91369. * @return the found morph target or null if not found at all.
  91370. */
  91371. getMorphTargetById(id: string): Nullable<MorphTarget>;
  91372. /**
  91373. * Gets a boolean indicating if the given mesh is active
  91374. * @param mesh defines the mesh to look for
  91375. * @returns true if the mesh is in the active list
  91376. */
  91377. isActiveMesh(mesh: AbstractMesh): boolean;
  91378. /**
  91379. * Return a unique id as a string which can serve as an identifier for the scene
  91380. */
  91381. readonly uid: string;
  91382. /**
  91383. * Add an externaly attached data from its key.
  91384. * This method call will fail and return false, if such key already exists.
  91385. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  91386. * @param key the unique key that identifies the data
  91387. * @param data the data object to associate to the key for this Engine instance
  91388. * @return true if no such key were already present and the data was added successfully, false otherwise
  91389. */
  91390. addExternalData<T>(key: string, data: T): boolean;
  91391. /**
  91392. * Get an externaly attached data from its key
  91393. * @param key the unique key that identifies the data
  91394. * @return the associated data, if present (can be null), or undefined if not present
  91395. */
  91396. getExternalData<T>(key: string): Nullable<T>;
  91397. /**
  91398. * Get an externaly attached data from its key, create it using a factory if it's not already present
  91399. * @param key the unique key that identifies the data
  91400. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  91401. * @return the associated data, can be null if the factory returned null.
  91402. */
  91403. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  91404. /**
  91405. * Remove an externaly attached data from the Engine instance
  91406. * @param key the unique key that identifies the data
  91407. * @return true if the data was successfully removed, false if it doesn't exist
  91408. */
  91409. removeExternalData(key: string): boolean;
  91410. private _evaluateSubMesh;
  91411. /**
  91412. * Clear the processed materials smart array preventing retention point in material dispose.
  91413. */
  91414. freeProcessedMaterials(): void;
  91415. private _preventFreeActiveMeshesAndRenderingGroups;
  91416. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  91417. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  91418. * when disposing several meshes in a row or a hierarchy of meshes.
  91419. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  91420. */
  91421. blockfreeActiveMeshesAndRenderingGroups: boolean;
  91422. /**
  91423. * Clear the active meshes smart array preventing retention point in mesh dispose.
  91424. */
  91425. freeActiveMeshes(): void;
  91426. /**
  91427. * Clear the info related to rendering groups preventing retention points during dispose.
  91428. */
  91429. freeRenderingGroups(): void;
  91430. /** @hidden */
  91431. _isInIntermediateRendering(): boolean;
  91432. /**
  91433. * Lambda returning the list of potentially active meshes.
  91434. */
  91435. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  91436. /**
  91437. * Lambda returning the list of potentially active sub meshes.
  91438. */
  91439. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  91440. /**
  91441. * Lambda returning the list of potentially intersecting sub meshes.
  91442. */
  91443. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  91444. /**
  91445. * Lambda returning the list of potentially colliding sub meshes.
  91446. */
  91447. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  91448. private _activeMeshesFrozen;
  91449. /**
  91450. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  91451. * @returns the current scene
  91452. */
  91453. freezeActiveMeshes(): Scene;
  91454. /**
  91455. * Use this function to restart evaluating active meshes on every frame
  91456. * @returns the current scene
  91457. */
  91458. unfreezeActiveMeshes(): Scene;
  91459. private _evaluateActiveMeshes;
  91460. private _activeMesh;
  91461. /**
  91462. * Update the transform matrix to update from the current active camera
  91463. * @param force defines a boolean used to force the update even if cache is up to date
  91464. */
  91465. updateTransformMatrix(force?: boolean): void;
  91466. /**
  91467. * 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)
  91468. * @param alternateCamera defines the camera to use
  91469. */
  91470. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  91471. /** @hidden */
  91472. _allowPostProcessClearColor: boolean;
  91473. private _renderForCamera;
  91474. private _processSubCameras;
  91475. private _checkIntersections;
  91476. /** @hidden */
  91477. _advancePhysicsEngineStep(step: number): void;
  91478. /**
  91479. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  91480. */
  91481. getDeterministicFrameTime: () => number;
  91482. /** @hidden */
  91483. _animate(): void;
  91484. /**
  91485. * Render the scene
  91486. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  91487. */
  91488. render(updateCameras?: boolean): void;
  91489. /**
  91490. * Freeze all materials
  91491. * A frozen material will not be updatable but should be faster to render
  91492. */
  91493. freezeMaterials(): void;
  91494. /**
  91495. * Unfreeze all materials
  91496. * A frozen material will not be updatable but should be faster to render
  91497. */
  91498. unfreezeMaterials(): void;
  91499. /**
  91500. * Releases all held ressources
  91501. */
  91502. dispose(): void;
  91503. /**
  91504. * Gets if the scene is already disposed
  91505. */
  91506. readonly isDisposed: boolean;
  91507. /**
  91508. * Call this function to reduce memory footprint of the scene.
  91509. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  91510. */
  91511. clearCachedVertexData(): void;
  91512. /**
  91513. * This function will remove the local cached buffer data from texture.
  91514. * It will save memory but will prevent the texture from being rebuilt
  91515. */
  91516. cleanCachedTextureBuffer(): void;
  91517. /**
  91518. * Get the world extend vectors with an optional filter
  91519. *
  91520. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  91521. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  91522. */
  91523. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  91524. min: Vector3;
  91525. max: Vector3;
  91526. };
  91527. /**
  91528. * Creates a ray that can be used to pick in the scene
  91529. * @param x defines the x coordinate of the origin (on-screen)
  91530. * @param y defines the y coordinate of the origin (on-screen)
  91531. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  91532. * @param camera defines the camera to use for the picking
  91533. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  91534. * @returns a Ray
  91535. */
  91536. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  91537. /**
  91538. * Creates a ray that can be used to pick in the scene
  91539. * @param x defines the x coordinate of the origin (on-screen)
  91540. * @param y defines the y coordinate of the origin (on-screen)
  91541. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  91542. * @param result defines the ray where to store the picking ray
  91543. * @param camera defines the camera to use for the picking
  91544. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  91545. * @returns the current scene
  91546. */
  91547. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  91548. /**
  91549. * Creates a ray that can be used to pick in the scene
  91550. * @param x defines the x coordinate of the origin (on-screen)
  91551. * @param y defines the y coordinate of the origin (on-screen)
  91552. * @param camera defines the camera to use for the picking
  91553. * @returns a Ray
  91554. */
  91555. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  91556. /**
  91557. * Creates a ray that can be used to pick in the scene
  91558. * @param x defines the x coordinate of the origin (on-screen)
  91559. * @param y defines the y coordinate of the origin (on-screen)
  91560. * @param result defines the ray where to store the picking ray
  91561. * @param camera defines the camera to use for the picking
  91562. * @returns the current scene
  91563. */
  91564. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  91565. /** Launch a ray to try to pick a mesh in the scene
  91566. * @param x position on screen
  91567. * @param y position on screen
  91568. * @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
  91569. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  91570. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91571. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  91572. * @returns a PickingInfo
  91573. */
  91574. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  91575. /** Use the given ray to pick a mesh in the scene
  91576. * @param ray The ray to use to pick meshes
  91577. * @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
  91578. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  91579. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  91580. * @returns a PickingInfo
  91581. */
  91582. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  91583. /**
  91584. * Launch a ray to try to pick a mesh in the scene
  91585. * @param x X position on screen
  91586. * @param y Y position on screen
  91587. * @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
  91588. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91589. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  91590. * @returns an array of PickingInfo
  91591. */
  91592. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  91593. /**
  91594. * Launch a ray to try to pick a mesh in the scene
  91595. * @param ray Ray to use
  91596. * @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
  91597. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  91598. * @returns an array of PickingInfo
  91599. */
  91600. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  91601. /**
  91602. * Force the value of meshUnderPointer
  91603. * @param mesh defines the mesh to use
  91604. */
  91605. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  91606. /**
  91607. * Gets the mesh under the pointer
  91608. * @returns a Mesh or null if no mesh is under the pointer
  91609. */
  91610. getPointerOverMesh(): Nullable<AbstractMesh>;
  91611. /** @hidden */
  91612. _rebuildGeometries(): void;
  91613. /** @hidden */
  91614. _rebuildTextures(): void;
  91615. private _getByTags;
  91616. /**
  91617. * Get a list of meshes by tags
  91618. * @param tagsQuery defines the tags query to use
  91619. * @param forEach defines a predicate used to filter results
  91620. * @returns an array of Mesh
  91621. */
  91622. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  91623. /**
  91624. * Get a list of cameras by tags
  91625. * @param tagsQuery defines the tags query to use
  91626. * @param forEach defines a predicate used to filter results
  91627. * @returns an array of Camera
  91628. */
  91629. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  91630. /**
  91631. * Get a list of lights by tags
  91632. * @param tagsQuery defines the tags query to use
  91633. * @param forEach defines a predicate used to filter results
  91634. * @returns an array of Light
  91635. */
  91636. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  91637. /**
  91638. * Get a list of materials by tags
  91639. * @param tagsQuery defines the tags query to use
  91640. * @param forEach defines a predicate used to filter results
  91641. * @returns an array of Material
  91642. */
  91643. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  91644. /**
  91645. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  91646. * This allowed control for front to back rendering or reversly depending of the special needs.
  91647. *
  91648. * @param renderingGroupId The rendering group id corresponding to its index
  91649. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  91650. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  91651. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  91652. */
  91653. 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;
  91654. /**
  91655. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  91656. *
  91657. * @param renderingGroupId The rendering group id corresponding to its index
  91658. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  91659. * @param depth Automatically clears depth between groups if true and autoClear is true.
  91660. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  91661. */
  91662. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  91663. /**
  91664. * Gets the current auto clear configuration for one rendering group of the rendering
  91665. * manager.
  91666. * @param index the rendering group index to get the information for
  91667. * @returns The auto clear setup for the requested rendering group
  91668. */
  91669. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  91670. private _blockMaterialDirtyMechanism;
  91671. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  91672. blockMaterialDirtyMechanism: boolean;
  91673. /**
  91674. * Will flag all materials as dirty to trigger new shader compilation
  91675. * @param flag defines the flag used to specify which material part must be marked as dirty
  91676. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  91677. */
  91678. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  91679. /** @hidden */
  91680. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  91681. /** @hidden */
  91682. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  91683. }
  91684. }
  91685. declare module BABYLON {
  91686. /**
  91687. * Set of assets to keep when moving a scene into an asset container.
  91688. */
  91689. export class KeepAssets extends AbstractScene {
  91690. }
  91691. /**
  91692. * Container with a set of assets that can be added or removed from a scene.
  91693. */
  91694. export class AssetContainer extends AbstractScene {
  91695. /**
  91696. * The scene the AssetContainer belongs to.
  91697. */
  91698. scene: Scene;
  91699. /**
  91700. * Instantiates an AssetContainer.
  91701. * @param scene The scene the AssetContainer belongs to.
  91702. */
  91703. constructor(scene: Scene);
  91704. /**
  91705. * Adds all the assets from the container to the scene.
  91706. */
  91707. addAllToScene(): void;
  91708. /**
  91709. * Removes all the assets in the container from the scene
  91710. */
  91711. removeAllFromScene(): void;
  91712. /**
  91713. * Disposes all the assets in the container
  91714. */
  91715. dispose(): void;
  91716. private _moveAssets;
  91717. /**
  91718. * Removes all the assets contained in the scene and adds them to the container.
  91719. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  91720. */
  91721. moveAllFromScene(keepAssets?: KeepAssets): void;
  91722. /**
  91723. * 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.
  91724. * @returns the root mesh
  91725. */
  91726. createRootMesh(): Mesh;
  91727. }
  91728. }
  91729. declare module BABYLON {
  91730. /**
  91731. * Defines how the parser contract is defined.
  91732. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  91733. */
  91734. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  91735. /**
  91736. * Defines how the individual parser contract is defined.
  91737. * These parser can parse an individual asset
  91738. */
  91739. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  91740. /**
  91741. * Base class of the scene acting as a container for the different elements composing a scene.
  91742. * This class is dynamically extended by the different components of the scene increasing
  91743. * flexibility and reducing coupling
  91744. */
  91745. export abstract class AbstractScene {
  91746. /**
  91747. * Stores the list of available parsers in the application.
  91748. */
  91749. private static _BabylonFileParsers;
  91750. /**
  91751. * Stores the list of available individual parsers in the application.
  91752. */
  91753. private static _IndividualBabylonFileParsers;
  91754. /**
  91755. * Adds a parser in the list of available ones
  91756. * @param name Defines the name of the parser
  91757. * @param parser Defines the parser to add
  91758. */
  91759. static AddParser(name: string, parser: BabylonFileParser): void;
  91760. /**
  91761. * Gets a general parser from the list of avaialble ones
  91762. * @param name Defines the name of the parser
  91763. * @returns the requested parser or null
  91764. */
  91765. static GetParser(name: string): Nullable<BabylonFileParser>;
  91766. /**
  91767. * Adds n individual parser in the list of available ones
  91768. * @param name Defines the name of the parser
  91769. * @param parser Defines the parser to add
  91770. */
  91771. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  91772. /**
  91773. * Gets an individual parser from the list of avaialble ones
  91774. * @param name Defines the name of the parser
  91775. * @returns the requested parser or null
  91776. */
  91777. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  91778. /**
  91779. * Parser json data and populate both a scene and its associated container object
  91780. * @param jsonData Defines the data to parse
  91781. * @param scene Defines the scene to parse the data for
  91782. * @param container Defines the container attached to the parsing sequence
  91783. * @param rootUrl Defines the root url of the data
  91784. */
  91785. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  91786. /**
  91787. * Gets the list of root nodes (ie. nodes with no parent)
  91788. */
  91789. rootNodes: Node[];
  91790. /** All of the cameras added to this scene
  91791. * @see http://doc.babylonjs.com/babylon101/cameras
  91792. */
  91793. cameras: Camera[];
  91794. /**
  91795. * All of the lights added to this scene
  91796. * @see http://doc.babylonjs.com/babylon101/lights
  91797. */
  91798. lights: Light[];
  91799. /**
  91800. * All of the (abstract) meshes added to this scene
  91801. */
  91802. meshes: AbstractMesh[];
  91803. /**
  91804. * The list of skeletons added to the scene
  91805. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  91806. */
  91807. skeletons: Skeleton[];
  91808. /**
  91809. * All of the particle systems added to this scene
  91810. * @see http://doc.babylonjs.com/babylon101/particles
  91811. */
  91812. particleSystems: IParticleSystem[];
  91813. /**
  91814. * Gets a list of Animations associated with the scene
  91815. */
  91816. animations: Animation[];
  91817. /**
  91818. * All of the animation groups added to this scene
  91819. * @see http://doc.babylonjs.com/how_to/group
  91820. */
  91821. animationGroups: AnimationGroup[];
  91822. /**
  91823. * All of the multi-materials added to this scene
  91824. * @see http://doc.babylonjs.com/how_to/multi_materials
  91825. */
  91826. multiMaterials: MultiMaterial[];
  91827. /**
  91828. * All of the materials added to this scene
  91829. * In the context of a Scene, it is not supposed to be modified manually.
  91830. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  91831. * Note also that the order of the Material wihin the array is not significant and might change.
  91832. * @see http://doc.babylonjs.com/babylon101/materials
  91833. */
  91834. materials: Material[];
  91835. /**
  91836. * The list of morph target managers added to the scene
  91837. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  91838. */
  91839. morphTargetManagers: MorphTargetManager[];
  91840. /**
  91841. * The list of geometries used in the scene.
  91842. */
  91843. geometries: Geometry[];
  91844. /**
  91845. * All of the tranform nodes added to this scene
  91846. * In the context of a Scene, it is not supposed to be modified manually.
  91847. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  91848. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  91849. * @see http://doc.babylonjs.com/how_to/transformnode
  91850. */
  91851. transformNodes: TransformNode[];
  91852. /**
  91853. * ActionManagers available on the scene.
  91854. */
  91855. actionManagers: AbstractActionManager[];
  91856. /**
  91857. * Textures to keep.
  91858. */
  91859. textures: BaseTexture[];
  91860. }
  91861. }
  91862. declare module BABYLON {
  91863. /**
  91864. * Defines a sound that can be played in the application.
  91865. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  91866. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  91867. */
  91868. export class Sound {
  91869. /**
  91870. * The name of the sound in the scene.
  91871. */
  91872. name: string;
  91873. /**
  91874. * Does the sound autoplay once loaded.
  91875. */
  91876. autoplay: boolean;
  91877. /**
  91878. * Does the sound loop after it finishes playing once.
  91879. */
  91880. loop: boolean;
  91881. /**
  91882. * Does the sound use a custom attenuation curve to simulate the falloff
  91883. * happening when the source gets further away from the camera.
  91884. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  91885. */
  91886. useCustomAttenuation: boolean;
  91887. /**
  91888. * The sound track id this sound belongs to.
  91889. */
  91890. soundTrackId: number;
  91891. /**
  91892. * Is this sound currently played.
  91893. */
  91894. isPlaying: boolean;
  91895. /**
  91896. * Is this sound currently paused.
  91897. */
  91898. isPaused: boolean;
  91899. /**
  91900. * Does this sound enables spatial sound.
  91901. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91902. */
  91903. spatialSound: boolean;
  91904. /**
  91905. * Define the reference distance the sound should be heard perfectly.
  91906. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91907. */
  91908. refDistance: number;
  91909. /**
  91910. * Define the roll off factor of spatial sounds.
  91911. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91912. */
  91913. rolloffFactor: number;
  91914. /**
  91915. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  91916. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91917. */
  91918. maxDistance: number;
  91919. /**
  91920. * Define the distance attenuation model the sound will follow.
  91921. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91922. */
  91923. distanceModel: string;
  91924. /**
  91925. * @hidden
  91926. * Back Compat
  91927. **/
  91928. onended: () => any;
  91929. /**
  91930. * Observable event when the current playing sound finishes.
  91931. */
  91932. onEndedObservable: Observable<Sound>;
  91933. private _panningModel;
  91934. private _playbackRate;
  91935. private _streaming;
  91936. private _startTime;
  91937. private _startOffset;
  91938. private _position;
  91939. /** @hidden */
  91940. _positionInEmitterSpace: boolean;
  91941. private _localDirection;
  91942. private _volume;
  91943. private _isReadyToPlay;
  91944. private _isDirectional;
  91945. private _readyToPlayCallback;
  91946. private _audioBuffer;
  91947. private _soundSource;
  91948. private _streamingSource;
  91949. private _soundPanner;
  91950. private _soundGain;
  91951. private _inputAudioNode;
  91952. private _outputAudioNode;
  91953. private _coneInnerAngle;
  91954. private _coneOuterAngle;
  91955. private _coneOuterGain;
  91956. private _scene;
  91957. private _connectedTransformNode;
  91958. private _customAttenuationFunction;
  91959. private _registerFunc;
  91960. private _isOutputConnected;
  91961. private _htmlAudioElement;
  91962. private _urlType;
  91963. /** @hidden */
  91964. static _SceneComponentInitialization: (scene: Scene) => void;
  91965. /**
  91966. * Create a sound and attach it to a scene
  91967. * @param name Name of your sound
  91968. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  91969. * @param scene defines the scene the sound belongs to
  91970. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  91971. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  91972. */
  91973. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  91974. /**
  91975. * Release the sound and its associated resources
  91976. */
  91977. dispose(): void;
  91978. /**
  91979. * Gets if the sounds is ready to be played or not.
  91980. * @returns true if ready, otherwise false
  91981. */
  91982. isReady(): boolean;
  91983. private _soundLoaded;
  91984. /**
  91985. * Sets the data of the sound from an audiobuffer
  91986. * @param audioBuffer The audioBuffer containing the data
  91987. */
  91988. setAudioBuffer(audioBuffer: AudioBuffer): void;
  91989. /**
  91990. * Updates the current sounds options such as maxdistance, loop...
  91991. * @param options A JSON object containing values named as the object properties
  91992. */
  91993. updateOptions(options: any): void;
  91994. private _createSpatialParameters;
  91995. private _updateSpatialParameters;
  91996. /**
  91997. * Switch the panning model to HRTF:
  91998. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  91999. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92000. */
  92001. switchPanningModelToHRTF(): void;
  92002. /**
  92003. * Switch the panning model to Equal Power:
  92004. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  92005. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92006. */
  92007. switchPanningModelToEqualPower(): void;
  92008. private _switchPanningModel;
  92009. /**
  92010. * Connect this sound to a sound track audio node like gain...
  92011. * @param soundTrackAudioNode the sound track audio node to connect to
  92012. */
  92013. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  92014. /**
  92015. * Transform this sound into a directional source
  92016. * @param coneInnerAngle Size of the inner cone in degree
  92017. * @param coneOuterAngle Size of the outer cone in degree
  92018. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  92019. */
  92020. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  92021. /**
  92022. * Gets or sets the inner angle for the directional cone.
  92023. */
  92024. /**
  92025. * Gets or sets the inner angle for the directional cone.
  92026. */
  92027. directionalConeInnerAngle: number;
  92028. /**
  92029. * Gets or sets the outer angle for the directional cone.
  92030. */
  92031. /**
  92032. * Gets or sets the outer angle for the directional cone.
  92033. */
  92034. directionalConeOuterAngle: number;
  92035. /**
  92036. * Sets the position of the emitter if spatial sound is enabled
  92037. * @param newPosition Defines the new posisiton
  92038. */
  92039. setPosition(newPosition: Vector3): void;
  92040. /**
  92041. * Sets the local direction of the emitter if spatial sound is enabled
  92042. * @param newLocalDirection Defines the new local direction
  92043. */
  92044. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  92045. private _updateDirection;
  92046. /** @hidden */
  92047. updateDistanceFromListener(): void;
  92048. /**
  92049. * Sets a new custom attenuation function for the sound.
  92050. * @param callback Defines the function used for the attenuation
  92051. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  92052. */
  92053. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  92054. /**
  92055. * Play the sound
  92056. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  92057. * @param offset (optional) Start the sound setting it at a specific time
  92058. */
  92059. play(time?: number, offset?: number): void;
  92060. private _onended;
  92061. /**
  92062. * Stop the sound
  92063. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  92064. */
  92065. stop(time?: number): void;
  92066. /**
  92067. * Put the sound in pause
  92068. */
  92069. pause(): void;
  92070. /**
  92071. * Sets a dedicated volume for this sounds
  92072. * @param newVolume Define the new volume of the sound
  92073. * @param time Define in how long the sound should be at this value
  92074. */
  92075. setVolume(newVolume: number, time?: number): void;
  92076. /**
  92077. * Set the sound play back rate
  92078. * @param newPlaybackRate Define the playback rate the sound should be played at
  92079. */
  92080. setPlaybackRate(newPlaybackRate: number): void;
  92081. /**
  92082. * Gets the volume of the sound.
  92083. * @returns the volume of the sound
  92084. */
  92085. getVolume(): number;
  92086. /**
  92087. * Attach the sound to a dedicated mesh
  92088. * @param transformNode The transform node to connect the sound with
  92089. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  92090. */
  92091. attachToMesh(transformNode: TransformNode): void;
  92092. /**
  92093. * Detach the sound from the previously attached mesh
  92094. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  92095. */
  92096. detachFromMesh(): void;
  92097. private _onRegisterAfterWorldMatrixUpdate;
  92098. /**
  92099. * Clone the current sound in the scene.
  92100. * @returns the new sound clone
  92101. */
  92102. clone(): Nullable<Sound>;
  92103. /**
  92104. * Gets the current underlying audio buffer containing the data
  92105. * @returns the audio buffer
  92106. */
  92107. getAudioBuffer(): Nullable<AudioBuffer>;
  92108. /**
  92109. * Serializes the Sound in a JSON representation
  92110. * @returns the JSON representation of the sound
  92111. */
  92112. serialize(): any;
  92113. /**
  92114. * Parse a JSON representation of a sound to innstantiate in a given scene
  92115. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  92116. * @param scene Define the scene the new parsed sound should be created in
  92117. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  92118. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  92119. * @returns the newly parsed sound
  92120. */
  92121. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  92122. }
  92123. }
  92124. declare module BABYLON {
  92125. /**
  92126. * This defines an action helpful to play a defined sound on a triggered action.
  92127. */
  92128. export class PlaySoundAction extends Action {
  92129. private _sound;
  92130. /**
  92131. * Instantiate the action
  92132. * @param triggerOptions defines the trigger options
  92133. * @param sound defines the sound to play
  92134. * @param condition defines the trigger related conditions
  92135. */
  92136. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  92137. /** @hidden */
  92138. _prepare(): void;
  92139. /**
  92140. * Execute the action and play the sound.
  92141. */
  92142. execute(): void;
  92143. /**
  92144. * Serializes the actions and its related information.
  92145. * @param parent defines the object to serialize in
  92146. * @returns the serialized object
  92147. */
  92148. serialize(parent: any): any;
  92149. }
  92150. /**
  92151. * This defines an action helpful to stop a defined sound on a triggered action.
  92152. */
  92153. export class StopSoundAction extends Action {
  92154. private _sound;
  92155. /**
  92156. * Instantiate the action
  92157. * @param triggerOptions defines the trigger options
  92158. * @param sound defines the sound to stop
  92159. * @param condition defines the trigger related conditions
  92160. */
  92161. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  92162. /** @hidden */
  92163. _prepare(): void;
  92164. /**
  92165. * Execute the action and stop the sound.
  92166. */
  92167. execute(): void;
  92168. /**
  92169. * Serializes the actions and its related information.
  92170. * @param parent defines the object to serialize in
  92171. * @returns the serialized object
  92172. */
  92173. serialize(parent: any): any;
  92174. }
  92175. }
  92176. declare module BABYLON {
  92177. /**
  92178. * This defines an action responsible to change the value of a property
  92179. * by interpolating between its current value and the newly set one once triggered.
  92180. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92181. */
  92182. export class InterpolateValueAction extends Action {
  92183. /**
  92184. * Defines the path of the property where the value should be interpolated
  92185. */
  92186. propertyPath: string;
  92187. /**
  92188. * Defines the target value at the end of the interpolation.
  92189. */
  92190. value: any;
  92191. /**
  92192. * Defines the time it will take for the property to interpolate to the value.
  92193. */
  92194. duration: number;
  92195. /**
  92196. * Defines if the other scene animations should be stopped when the action has been triggered
  92197. */
  92198. stopOtherAnimations?: boolean;
  92199. /**
  92200. * Defines a callback raised once the interpolation animation has been done.
  92201. */
  92202. onInterpolationDone?: () => void;
  92203. /**
  92204. * Observable triggered once the interpolation animation has been done.
  92205. */
  92206. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  92207. private _target;
  92208. private _effectiveTarget;
  92209. private _property;
  92210. /**
  92211. * Instantiate the action
  92212. * @param triggerOptions defines the trigger options
  92213. * @param target defines the object containing the value to interpolate
  92214. * @param propertyPath defines the path to the property in the target object
  92215. * @param value defines the target value at the end of the interpolation
  92216. * @param duration deines the time it will take for the property to interpolate to the value.
  92217. * @param condition defines the trigger related conditions
  92218. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  92219. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  92220. */
  92221. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  92222. /** @hidden */
  92223. _prepare(): void;
  92224. /**
  92225. * Execute the action starts the value interpolation.
  92226. */
  92227. execute(): void;
  92228. /**
  92229. * Serializes the actions and its related information.
  92230. * @param parent defines the object to serialize in
  92231. * @returns the serialized object
  92232. */
  92233. serialize(parent: any): any;
  92234. }
  92235. }
  92236. declare module BABYLON {
  92237. /**
  92238. * Options allowed during the creation of a sound track.
  92239. */
  92240. export interface ISoundTrackOptions {
  92241. /**
  92242. * The volume the sound track should take during creation
  92243. */
  92244. volume?: number;
  92245. /**
  92246. * Define if the sound track is the main sound track of the scene
  92247. */
  92248. mainTrack?: boolean;
  92249. }
  92250. /**
  92251. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  92252. * It will be also used in a future release to apply effects on a specific track.
  92253. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  92254. */
  92255. export class SoundTrack {
  92256. /**
  92257. * The unique identifier of the sound track in the scene.
  92258. */
  92259. id: number;
  92260. /**
  92261. * The list of sounds included in the sound track.
  92262. */
  92263. soundCollection: Array<Sound>;
  92264. private _outputAudioNode;
  92265. private _scene;
  92266. private _isMainTrack;
  92267. private _connectedAnalyser;
  92268. private _options;
  92269. private _isInitialized;
  92270. /**
  92271. * Creates a new sound track.
  92272. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  92273. * @param scene Define the scene the sound track belongs to
  92274. * @param options
  92275. */
  92276. constructor(scene: Scene, options?: ISoundTrackOptions);
  92277. private _initializeSoundTrackAudioGraph;
  92278. /**
  92279. * Release the sound track and its associated resources
  92280. */
  92281. dispose(): void;
  92282. /**
  92283. * Adds a sound to this sound track
  92284. * @param sound define the cound to add
  92285. * @ignoreNaming
  92286. */
  92287. AddSound(sound: Sound): void;
  92288. /**
  92289. * Removes a sound to this sound track
  92290. * @param sound define the cound to remove
  92291. * @ignoreNaming
  92292. */
  92293. RemoveSound(sound: Sound): void;
  92294. /**
  92295. * Set a global volume for the full sound track.
  92296. * @param newVolume Define the new volume of the sound track
  92297. */
  92298. setVolume(newVolume: number): void;
  92299. /**
  92300. * Switch the panning model to HRTF:
  92301. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  92302. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92303. */
  92304. switchPanningModelToHRTF(): void;
  92305. /**
  92306. * Switch the panning model to Equal Power:
  92307. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  92308. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92309. */
  92310. switchPanningModelToEqualPower(): void;
  92311. /**
  92312. * Connect the sound track to an audio analyser allowing some amazing
  92313. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  92314. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  92315. * @param analyser The analyser to connect to the engine
  92316. */
  92317. connectToAnalyser(analyser: Analyser): void;
  92318. }
  92319. }
  92320. declare module BABYLON {
  92321. interface AbstractScene {
  92322. /**
  92323. * The list of sounds used in the scene.
  92324. */
  92325. sounds: Nullable<Array<Sound>>;
  92326. }
  92327. interface Scene {
  92328. /**
  92329. * @hidden
  92330. * Backing field
  92331. */
  92332. _mainSoundTrack: SoundTrack;
  92333. /**
  92334. * The main sound track played by the scene.
  92335. * It cotains your primary collection of sounds.
  92336. */
  92337. mainSoundTrack: SoundTrack;
  92338. /**
  92339. * The list of sound tracks added to the scene
  92340. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92341. */
  92342. soundTracks: Nullable<Array<SoundTrack>>;
  92343. /**
  92344. * Gets a sound using a given name
  92345. * @param name defines the name to search for
  92346. * @return the found sound or null if not found at all.
  92347. */
  92348. getSoundByName(name: string): Nullable<Sound>;
  92349. /**
  92350. * Gets or sets if audio support is enabled
  92351. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92352. */
  92353. audioEnabled: boolean;
  92354. /**
  92355. * Gets or sets if audio will be output to headphones
  92356. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92357. */
  92358. headphone: boolean;
  92359. }
  92360. /**
  92361. * Defines the sound scene component responsible to manage any sounds
  92362. * in a given scene.
  92363. */
  92364. export class AudioSceneComponent implements ISceneSerializableComponent {
  92365. /**
  92366. * The component name helpfull to identify the component in the list of scene components.
  92367. */
  92368. readonly name: string;
  92369. /**
  92370. * The scene the component belongs to.
  92371. */
  92372. scene: Scene;
  92373. private _audioEnabled;
  92374. /**
  92375. * Gets whether audio is enabled or not.
  92376. * Please use related enable/disable method to switch state.
  92377. */
  92378. readonly audioEnabled: boolean;
  92379. private _headphone;
  92380. /**
  92381. * Gets whether audio is outputing to headphone or not.
  92382. * Please use the according Switch methods to change output.
  92383. */
  92384. readonly headphone: boolean;
  92385. /**
  92386. * Creates a new instance of the component for the given scene
  92387. * @param scene Defines the scene to register the component in
  92388. */
  92389. constructor(scene: Scene);
  92390. /**
  92391. * Registers the component in a given scene
  92392. */
  92393. register(): void;
  92394. /**
  92395. * Rebuilds the elements related to this component in case of
  92396. * context lost for instance.
  92397. */
  92398. rebuild(): void;
  92399. /**
  92400. * Serializes the component data to the specified json object
  92401. * @param serializationObject The object to serialize to
  92402. */
  92403. serialize(serializationObject: any): void;
  92404. /**
  92405. * Adds all the element from the container to the scene
  92406. * @param container the container holding the elements
  92407. */
  92408. addFromContainer(container: AbstractScene): void;
  92409. /**
  92410. * Removes all the elements in the container from the scene
  92411. * @param container contains the elements to remove
  92412. */
  92413. removeFromContainer(container: AbstractScene): void;
  92414. /**
  92415. * Disposes the component and the associated ressources.
  92416. */
  92417. dispose(): void;
  92418. /**
  92419. * Disables audio in the associated scene.
  92420. */
  92421. disableAudio(): void;
  92422. /**
  92423. * Enables audio in the associated scene.
  92424. */
  92425. enableAudio(): void;
  92426. /**
  92427. * Switch audio to headphone output.
  92428. */
  92429. switchAudioModeForHeadphones(): void;
  92430. /**
  92431. * Switch audio to normal speakers.
  92432. */
  92433. switchAudioModeForNormalSpeakers(): void;
  92434. private _afterRender;
  92435. }
  92436. }
  92437. declare module BABYLON {
  92438. /**
  92439. * Wraps one or more Sound objects and selects one with random weight for playback.
  92440. */
  92441. export class WeightedSound {
  92442. /** When true a Sound will be selected and played when the current playing Sound completes. */
  92443. loop: boolean;
  92444. private _coneInnerAngle;
  92445. private _coneOuterAngle;
  92446. private _volume;
  92447. /** A Sound is currently playing. */
  92448. isPlaying: boolean;
  92449. /** A Sound is currently paused. */
  92450. isPaused: boolean;
  92451. private _sounds;
  92452. private _weights;
  92453. private _currentIndex?;
  92454. /**
  92455. * Creates a new WeightedSound from the list of sounds given.
  92456. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  92457. * @param sounds Array of Sounds that will be selected from.
  92458. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  92459. */
  92460. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  92461. /**
  92462. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  92463. */
  92464. /**
  92465. * The size of cone in degress for a directional sound in which there will be no attenuation.
  92466. */
  92467. directionalConeInnerAngle: number;
  92468. /**
  92469. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  92470. * Listener angles between innerAngle and outerAngle will falloff linearly.
  92471. */
  92472. /**
  92473. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  92474. * Listener angles between innerAngle and outerAngle will falloff linearly.
  92475. */
  92476. directionalConeOuterAngle: number;
  92477. /**
  92478. * Playback volume.
  92479. */
  92480. /**
  92481. * Playback volume.
  92482. */
  92483. volume: number;
  92484. private _onended;
  92485. /**
  92486. * Suspend playback
  92487. */
  92488. pause(): void;
  92489. /**
  92490. * Stop playback
  92491. */
  92492. stop(): void;
  92493. /**
  92494. * Start playback.
  92495. * @param startOffset Position the clip head at a specific time in seconds.
  92496. */
  92497. play(startOffset?: number): void;
  92498. }
  92499. }
  92500. declare module BABYLON {
  92501. /**
  92502. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  92503. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  92504. */
  92505. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  92506. /**
  92507. * Gets the name of the behavior.
  92508. */
  92509. readonly name: string;
  92510. /**
  92511. * The easing function used by animations
  92512. */
  92513. static EasingFunction: BackEase;
  92514. /**
  92515. * The easing mode used by animations
  92516. */
  92517. static EasingMode: number;
  92518. /**
  92519. * The duration of the animation, in milliseconds
  92520. */
  92521. transitionDuration: number;
  92522. /**
  92523. * Length of the distance animated by the transition when lower radius is reached
  92524. */
  92525. lowerRadiusTransitionRange: number;
  92526. /**
  92527. * Length of the distance animated by the transition when upper radius is reached
  92528. */
  92529. upperRadiusTransitionRange: number;
  92530. private _autoTransitionRange;
  92531. /**
  92532. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  92533. */
  92534. /**
  92535. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  92536. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  92537. */
  92538. autoTransitionRange: boolean;
  92539. private _attachedCamera;
  92540. private _onAfterCheckInputsObserver;
  92541. private _onMeshTargetChangedObserver;
  92542. /**
  92543. * Initializes the behavior.
  92544. */
  92545. init(): void;
  92546. /**
  92547. * Attaches the behavior to its arc rotate camera.
  92548. * @param camera Defines the camera to attach the behavior to
  92549. */
  92550. attach(camera: ArcRotateCamera): void;
  92551. /**
  92552. * Detaches the behavior from its current arc rotate camera.
  92553. */
  92554. detach(): void;
  92555. private _radiusIsAnimating;
  92556. private _radiusBounceTransition;
  92557. private _animatables;
  92558. private _cachedWheelPrecision;
  92559. /**
  92560. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  92561. * @param radiusLimit The limit to check against.
  92562. * @return Bool to indicate if at limit.
  92563. */
  92564. private _isRadiusAtLimit;
  92565. /**
  92566. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  92567. * @param radiusDelta The delta by which to animate to. Can be negative.
  92568. */
  92569. private _applyBoundRadiusAnimation;
  92570. /**
  92571. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  92572. */
  92573. protected _clearAnimationLocks(): void;
  92574. /**
  92575. * Stops and removes all animations that have been applied to the camera
  92576. */
  92577. stopAllAnimations(): void;
  92578. }
  92579. }
  92580. declare module BABYLON {
  92581. /**
  92582. * 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.
  92583. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  92584. */
  92585. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  92586. /**
  92587. * Gets the name of the behavior.
  92588. */
  92589. readonly name: string;
  92590. private _mode;
  92591. private _radiusScale;
  92592. private _positionScale;
  92593. private _defaultElevation;
  92594. private _elevationReturnTime;
  92595. private _elevationReturnWaitTime;
  92596. private _zoomStopsAnimation;
  92597. private _framingTime;
  92598. /**
  92599. * The easing function used by animations
  92600. */
  92601. static EasingFunction: ExponentialEase;
  92602. /**
  92603. * The easing mode used by animations
  92604. */
  92605. static EasingMode: number;
  92606. /**
  92607. * Sets the current mode used by the behavior
  92608. */
  92609. /**
  92610. * Gets current mode used by the behavior.
  92611. */
  92612. mode: number;
  92613. /**
  92614. * Sets the scale applied to the radius (1 by default)
  92615. */
  92616. /**
  92617. * Gets the scale applied to the radius
  92618. */
  92619. radiusScale: number;
  92620. /**
  92621. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  92622. */
  92623. /**
  92624. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  92625. */
  92626. positionScale: number;
  92627. /**
  92628. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  92629. * behaviour is triggered, in radians.
  92630. */
  92631. /**
  92632. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  92633. * behaviour is triggered, in radians.
  92634. */
  92635. defaultElevation: number;
  92636. /**
  92637. * Sets the time (in milliseconds) taken to return to the default beta position.
  92638. * Negative value indicates camera should not return to default.
  92639. */
  92640. /**
  92641. * Gets the time (in milliseconds) taken to return to the default beta position.
  92642. * Negative value indicates camera should not return to default.
  92643. */
  92644. elevationReturnTime: number;
  92645. /**
  92646. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  92647. */
  92648. /**
  92649. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  92650. */
  92651. elevationReturnWaitTime: number;
  92652. /**
  92653. * Sets the flag that indicates if user zooming should stop animation.
  92654. */
  92655. /**
  92656. * Gets the flag that indicates if user zooming should stop animation.
  92657. */
  92658. zoomStopsAnimation: boolean;
  92659. /**
  92660. * Sets the transition time when framing the mesh, in milliseconds
  92661. */
  92662. /**
  92663. * Gets the transition time when framing the mesh, in milliseconds
  92664. */
  92665. framingTime: number;
  92666. /**
  92667. * Define if the behavior should automatically change the configured
  92668. * camera limits and sensibilities.
  92669. */
  92670. autoCorrectCameraLimitsAndSensibility: boolean;
  92671. private _onPrePointerObservableObserver;
  92672. private _onAfterCheckInputsObserver;
  92673. private _onMeshTargetChangedObserver;
  92674. private _attachedCamera;
  92675. private _isPointerDown;
  92676. private _lastInteractionTime;
  92677. /**
  92678. * Initializes the behavior.
  92679. */
  92680. init(): void;
  92681. /**
  92682. * Attaches the behavior to its arc rotate camera.
  92683. * @param camera Defines the camera to attach the behavior to
  92684. */
  92685. attach(camera: ArcRotateCamera): void;
  92686. /**
  92687. * Detaches the behavior from its current arc rotate camera.
  92688. */
  92689. detach(): void;
  92690. private _animatables;
  92691. private _betaIsAnimating;
  92692. private _betaTransition;
  92693. private _radiusTransition;
  92694. private _vectorTransition;
  92695. /**
  92696. * Targets the given mesh and updates zoom level accordingly.
  92697. * @param mesh The mesh to target.
  92698. * @param radius Optional. If a cached radius position already exists, overrides default.
  92699. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  92700. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  92701. * @param onAnimationEnd Callback triggered at the end of the framing animation
  92702. */
  92703. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  92704. /**
  92705. * Targets the given mesh with its children and updates zoom level accordingly.
  92706. * @param mesh The mesh to target.
  92707. * @param radius Optional. If a cached radius position already exists, overrides default.
  92708. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  92709. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  92710. * @param onAnimationEnd Callback triggered at the end of the framing animation
  92711. */
  92712. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  92713. /**
  92714. * Targets the given meshes with their children and updates zoom level accordingly.
  92715. * @param meshes The mesh to target.
  92716. * @param radius Optional. If a cached radius position already exists, overrides default.
  92717. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  92718. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  92719. * @param onAnimationEnd Callback triggered at the end of the framing animation
  92720. */
  92721. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  92722. /**
  92723. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  92724. * @param minimumWorld Determines the smaller position of the bounding box extend
  92725. * @param maximumWorld Determines the bigger position of the bounding box extend
  92726. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  92727. * @param onAnimationEnd Callback triggered at the end of the framing animation
  92728. */
  92729. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  92730. /**
  92731. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  92732. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  92733. * frustum width.
  92734. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  92735. * to fully enclose the mesh in the viewing frustum.
  92736. */
  92737. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  92738. /**
  92739. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  92740. * is automatically returned to its default position (expected to be above ground plane).
  92741. */
  92742. private _maintainCameraAboveGround;
  92743. /**
  92744. * Returns the frustum slope based on the canvas ratio and camera FOV
  92745. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  92746. */
  92747. private _getFrustumSlope;
  92748. /**
  92749. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  92750. */
  92751. private _clearAnimationLocks;
  92752. /**
  92753. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  92754. */
  92755. private _applyUserInteraction;
  92756. /**
  92757. * Stops and removes all animations that have been applied to the camera
  92758. */
  92759. stopAllAnimations(): void;
  92760. /**
  92761. * Gets a value indicating if the user is moving the camera
  92762. */
  92763. readonly isUserIsMoving: boolean;
  92764. /**
  92765. * The camera can move all the way towards the mesh.
  92766. */
  92767. static IgnoreBoundsSizeMode: number;
  92768. /**
  92769. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  92770. */
  92771. static FitFrustumSidesMode: number;
  92772. }
  92773. }
  92774. declare module BABYLON {
  92775. /**
  92776. * Base class for Camera Pointer Inputs.
  92777. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  92778. * for example usage.
  92779. */
  92780. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  92781. /**
  92782. * Defines the camera the input is attached to.
  92783. */
  92784. abstract camera: Camera;
  92785. /**
  92786. * Whether keyboard modifier keys are pressed at time of last mouse event.
  92787. */
  92788. protected _altKey: boolean;
  92789. protected _ctrlKey: boolean;
  92790. protected _metaKey: boolean;
  92791. protected _shiftKey: boolean;
  92792. /**
  92793. * Which mouse buttons were pressed at time of last mouse event.
  92794. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  92795. */
  92796. protected _buttonsPressed: number;
  92797. /**
  92798. * Defines the buttons associated with the input to handle camera move.
  92799. */
  92800. buttons: number[];
  92801. /**
  92802. * Attach the input controls to a specific dom element to get the input from.
  92803. * @param element Defines the element the controls should be listened from
  92804. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92805. */
  92806. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92807. /**
  92808. * Detach the current controls from the specified dom element.
  92809. * @param element Defines the element to stop listening the inputs from
  92810. */
  92811. detachControl(element: Nullable<HTMLElement>): void;
  92812. /**
  92813. * Gets the class name of the current input.
  92814. * @returns the class name
  92815. */
  92816. getClassName(): string;
  92817. /**
  92818. * Get the friendly name associated with the input class.
  92819. * @returns the input friendly name
  92820. */
  92821. getSimpleName(): string;
  92822. /**
  92823. * Called on pointer POINTERDOUBLETAP event.
  92824. * Override this method to provide functionality on POINTERDOUBLETAP event.
  92825. */
  92826. protected onDoubleTap(type: string): void;
  92827. /**
  92828. * Called on pointer POINTERMOVE event if only a single touch is active.
  92829. * Override this method to provide functionality.
  92830. */
  92831. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  92832. /**
  92833. * Called on pointer POINTERMOVE event if multiple touches are active.
  92834. * Override this method to provide functionality.
  92835. */
  92836. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  92837. /**
  92838. * Called on JS contextmenu event.
  92839. * Override this method to provide functionality.
  92840. */
  92841. protected onContextMenu(evt: PointerEvent): void;
  92842. /**
  92843. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  92844. * press.
  92845. * Override this method to provide functionality.
  92846. */
  92847. protected onButtonDown(evt: PointerEvent): void;
  92848. /**
  92849. * Called each time a new POINTERUP event occurs. Ie, for each button
  92850. * release.
  92851. * Override this method to provide functionality.
  92852. */
  92853. protected onButtonUp(evt: PointerEvent): void;
  92854. /**
  92855. * Called when window becomes inactive.
  92856. * Override this method to provide functionality.
  92857. */
  92858. protected onLostFocus(): void;
  92859. private _pointerInput;
  92860. private _observer;
  92861. private _onLostFocus;
  92862. private pointA;
  92863. private pointB;
  92864. }
  92865. }
  92866. declare module BABYLON {
  92867. /**
  92868. * Manage the pointers inputs to control an arc rotate camera.
  92869. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92870. */
  92871. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  92872. /**
  92873. * Defines the camera the input is attached to.
  92874. */
  92875. camera: ArcRotateCamera;
  92876. /**
  92877. * Gets the class name of the current input.
  92878. * @returns the class name
  92879. */
  92880. getClassName(): string;
  92881. /**
  92882. * Defines the buttons associated with the input to handle camera move.
  92883. */
  92884. buttons: number[];
  92885. /**
  92886. * Defines the pointer angular sensibility along the X axis or how fast is
  92887. * the camera rotating.
  92888. */
  92889. angularSensibilityX: number;
  92890. /**
  92891. * Defines the pointer angular sensibility along the Y axis or how fast is
  92892. * the camera rotating.
  92893. */
  92894. angularSensibilityY: number;
  92895. /**
  92896. * Defines the pointer pinch precision or how fast is the camera zooming.
  92897. */
  92898. pinchPrecision: number;
  92899. /**
  92900. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  92901. * from 0.
  92902. * It defines the percentage of current camera.radius to use as delta when
  92903. * pinch zoom is used.
  92904. */
  92905. pinchDeltaPercentage: number;
  92906. /**
  92907. * Defines the pointer panning sensibility or how fast is the camera moving.
  92908. */
  92909. panningSensibility: number;
  92910. /**
  92911. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  92912. */
  92913. multiTouchPanning: boolean;
  92914. /**
  92915. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  92916. * zoom (pinch) through multitouch.
  92917. */
  92918. multiTouchPanAndZoom: boolean;
  92919. /**
  92920. * Revers pinch action direction.
  92921. */
  92922. pinchInwards: boolean;
  92923. private _isPanClick;
  92924. private _twoFingerActivityCount;
  92925. private _isPinching;
  92926. /**
  92927. * Called on pointer POINTERMOVE event if only a single touch is active.
  92928. */
  92929. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  92930. /**
  92931. * Called on pointer POINTERDOUBLETAP event.
  92932. */
  92933. protected onDoubleTap(type: string): void;
  92934. /**
  92935. * Called on pointer POINTERMOVE event if multiple touches are active.
  92936. */
  92937. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  92938. /**
  92939. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  92940. * press.
  92941. */
  92942. protected onButtonDown(evt: PointerEvent): void;
  92943. /**
  92944. * Called each time a new POINTERUP event occurs. Ie, for each button
  92945. * release.
  92946. */
  92947. protected onButtonUp(evt: PointerEvent): void;
  92948. /**
  92949. * Called when window becomes inactive.
  92950. */
  92951. protected onLostFocus(): void;
  92952. }
  92953. }
  92954. declare module BABYLON {
  92955. /**
  92956. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  92957. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92958. */
  92959. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  92960. /**
  92961. * Defines the camera the input is attached to.
  92962. */
  92963. camera: ArcRotateCamera;
  92964. /**
  92965. * Defines the list of key codes associated with the up action (increase alpha)
  92966. */
  92967. keysUp: number[];
  92968. /**
  92969. * Defines the list of key codes associated with the down action (decrease alpha)
  92970. */
  92971. keysDown: number[];
  92972. /**
  92973. * Defines the list of key codes associated with the left action (increase beta)
  92974. */
  92975. keysLeft: number[];
  92976. /**
  92977. * Defines the list of key codes associated with the right action (decrease beta)
  92978. */
  92979. keysRight: number[];
  92980. /**
  92981. * Defines the list of key codes associated with the reset action.
  92982. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  92983. */
  92984. keysReset: number[];
  92985. /**
  92986. * Defines the panning sensibility of the inputs.
  92987. * (How fast is the camera paning)
  92988. */
  92989. panningSensibility: number;
  92990. /**
  92991. * Defines the zooming sensibility of the inputs.
  92992. * (How fast is the camera zooming)
  92993. */
  92994. zoomingSensibility: number;
  92995. /**
  92996. * Defines wether maintaining the alt key down switch the movement mode from
  92997. * orientation to zoom.
  92998. */
  92999. useAltToZoom: boolean;
  93000. /**
  93001. * Rotation speed of the camera
  93002. */
  93003. angularSpeed: number;
  93004. private _keys;
  93005. private _ctrlPressed;
  93006. private _altPressed;
  93007. private _onCanvasBlurObserver;
  93008. private _onKeyboardObserver;
  93009. private _engine;
  93010. private _scene;
  93011. /**
  93012. * Attach the input controls to a specific dom element to get the input from.
  93013. * @param element Defines the element the controls should be listened from
  93014. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93015. */
  93016. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93017. /**
  93018. * Detach the current controls from the specified dom element.
  93019. * @param element Defines the element to stop listening the inputs from
  93020. */
  93021. detachControl(element: Nullable<HTMLElement>): void;
  93022. /**
  93023. * Update the current camera state depending on the inputs that have been used this frame.
  93024. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  93025. */
  93026. checkInputs(): void;
  93027. /**
  93028. * Gets the class name of the current intput.
  93029. * @returns the class name
  93030. */
  93031. getClassName(): string;
  93032. /**
  93033. * Get the friendly name associated with the input class.
  93034. * @returns the input friendly name
  93035. */
  93036. getSimpleName(): string;
  93037. }
  93038. }
  93039. declare module BABYLON {
  93040. /**
  93041. * Manage the mouse wheel inputs to control an arc rotate camera.
  93042. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93043. */
  93044. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  93045. /**
  93046. * Defines the camera the input is attached to.
  93047. */
  93048. camera: ArcRotateCamera;
  93049. /**
  93050. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  93051. */
  93052. wheelPrecision: number;
  93053. /**
  93054. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  93055. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  93056. */
  93057. wheelDeltaPercentage: number;
  93058. private _wheel;
  93059. private _observer;
  93060. /**
  93061. * Attach the input controls to a specific dom element to get the input from.
  93062. * @param element Defines the element the controls should be listened from
  93063. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93064. */
  93065. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93066. /**
  93067. * Detach the current controls from the specified dom element.
  93068. * @param element Defines the element to stop listening the inputs from
  93069. */
  93070. detachControl(element: Nullable<HTMLElement>): void;
  93071. /**
  93072. * Gets the class name of the current intput.
  93073. * @returns the class name
  93074. */
  93075. getClassName(): string;
  93076. /**
  93077. * Get the friendly name associated with the input class.
  93078. * @returns the input friendly name
  93079. */
  93080. getSimpleName(): string;
  93081. }
  93082. }
  93083. declare module BABYLON {
  93084. /**
  93085. * Default Inputs manager for the ArcRotateCamera.
  93086. * It groups all the default supported inputs for ease of use.
  93087. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  93088. */
  93089. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  93090. /**
  93091. * Instantiates a new ArcRotateCameraInputsManager.
  93092. * @param camera Defines the camera the inputs belong to
  93093. */
  93094. constructor(camera: ArcRotateCamera);
  93095. /**
  93096. * Add mouse wheel input support to the input manager.
  93097. * @returns the current input manager
  93098. */
  93099. addMouseWheel(): ArcRotateCameraInputsManager;
  93100. /**
  93101. * Add pointers input support to the input manager.
  93102. * @returns the current input manager
  93103. */
  93104. addPointers(): ArcRotateCameraInputsManager;
  93105. /**
  93106. * Add keyboard input support to the input manager.
  93107. * @returns the current input manager
  93108. */
  93109. addKeyboard(): ArcRotateCameraInputsManager;
  93110. }
  93111. }
  93112. declare module BABYLON {
  93113. /**
  93114. * This represents an orbital type of camera.
  93115. *
  93116. * 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.
  93117. * 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.
  93118. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  93119. */
  93120. export class ArcRotateCamera extends TargetCamera {
  93121. /**
  93122. * Defines the rotation angle of the camera along the longitudinal axis.
  93123. */
  93124. alpha: number;
  93125. /**
  93126. * Defines the rotation angle of the camera along the latitudinal axis.
  93127. */
  93128. beta: number;
  93129. /**
  93130. * Defines the radius of the camera from it s target point.
  93131. */
  93132. radius: number;
  93133. protected _target: Vector3;
  93134. protected _targetHost: Nullable<AbstractMesh>;
  93135. /**
  93136. * Defines the target point of the camera.
  93137. * The camera looks towards it form the radius distance.
  93138. */
  93139. target: Vector3;
  93140. /**
  93141. * Define the current local position of the camera in the scene
  93142. */
  93143. position: Vector3;
  93144. /**
  93145. * Current inertia value on the longitudinal axis.
  93146. * The bigger this number the longer it will take for the camera to stop.
  93147. */
  93148. inertialAlphaOffset: number;
  93149. /**
  93150. * Current inertia value on the latitudinal axis.
  93151. * The bigger this number the longer it will take for the camera to stop.
  93152. */
  93153. inertialBetaOffset: number;
  93154. /**
  93155. * Current inertia value on the radius axis.
  93156. * The bigger this number the longer it will take for the camera to stop.
  93157. */
  93158. inertialRadiusOffset: number;
  93159. /**
  93160. * Minimum allowed angle on the longitudinal axis.
  93161. * This can help limiting how the Camera is able to move in the scene.
  93162. */
  93163. lowerAlphaLimit: Nullable<number>;
  93164. /**
  93165. * Maximum allowed angle on the longitudinal axis.
  93166. * This can help limiting how the Camera is able to move in the scene.
  93167. */
  93168. upperAlphaLimit: Nullable<number>;
  93169. /**
  93170. * Minimum allowed angle on the latitudinal axis.
  93171. * This can help limiting how the Camera is able to move in the scene.
  93172. */
  93173. lowerBetaLimit: number;
  93174. /**
  93175. * Maximum allowed angle on the latitudinal axis.
  93176. * This can help limiting how the Camera is able to move in the scene.
  93177. */
  93178. upperBetaLimit: number;
  93179. /**
  93180. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  93181. * This can help limiting how the Camera is able to move in the scene.
  93182. */
  93183. lowerRadiusLimit: Nullable<number>;
  93184. /**
  93185. * Maximum allowed distance of the camera to the target (The camera can not get further).
  93186. * This can help limiting how the Camera is able to move in the scene.
  93187. */
  93188. upperRadiusLimit: Nullable<number>;
  93189. /**
  93190. * Defines the current inertia value used during panning of the camera along the X axis.
  93191. */
  93192. inertialPanningX: number;
  93193. /**
  93194. * Defines the current inertia value used during panning of the camera along the Y axis.
  93195. */
  93196. inertialPanningY: number;
  93197. /**
  93198. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  93199. * Basically if your fingers moves away from more than this distance you will be considered
  93200. * in pinch mode.
  93201. */
  93202. pinchToPanMaxDistance: number;
  93203. /**
  93204. * Defines the maximum distance the camera can pan.
  93205. * This could help keeping the cammera always in your scene.
  93206. */
  93207. panningDistanceLimit: Nullable<number>;
  93208. /**
  93209. * Defines the target of the camera before paning.
  93210. */
  93211. panningOriginTarget: Vector3;
  93212. /**
  93213. * Defines the value of the inertia used during panning.
  93214. * 0 would mean stop inertia and one would mean no decelleration at all.
  93215. */
  93216. panningInertia: number;
  93217. /**
  93218. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  93219. */
  93220. angularSensibilityX: number;
  93221. /**
  93222. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  93223. */
  93224. angularSensibilityY: number;
  93225. /**
  93226. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  93227. */
  93228. pinchPrecision: number;
  93229. /**
  93230. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  93231. * It will be used instead of pinchDeltaPrecision if different from 0.
  93232. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  93233. */
  93234. pinchDeltaPercentage: number;
  93235. /**
  93236. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  93237. */
  93238. panningSensibility: number;
  93239. /**
  93240. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  93241. */
  93242. keysUp: number[];
  93243. /**
  93244. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  93245. */
  93246. keysDown: number[];
  93247. /**
  93248. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  93249. */
  93250. keysLeft: number[];
  93251. /**
  93252. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  93253. */
  93254. keysRight: number[];
  93255. /**
  93256. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  93257. */
  93258. wheelPrecision: number;
  93259. /**
  93260. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  93261. * It will be used instead of pinchDeltaPrecision if different from 0.
  93262. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  93263. */
  93264. wheelDeltaPercentage: number;
  93265. /**
  93266. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  93267. */
  93268. zoomOnFactor: number;
  93269. /**
  93270. * Defines a screen offset for the camera position.
  93271. */
  93272. targetScreenOffset: Vector2;
  93273. /**
  93274. * Allows the camera to be completely reversed.
  93275. * If false the camera can not arrive upside down.
  93276. */
  93277. allowUpsideDown: boolean;
  93278. /**
  93279. * Define if double tap/click is used to restore the previously saved state of the camera.
  93280. */
  93281. useInputToRestoreState: boolean;
  93282. /** @hidden */
  93283. _viewMatrix: Matrix;
  93284. /** @hidden */
  93285. _useCtrlForPanning: boolean;
  93286. /** @hidden */
  93287. _panningMouseButton: number;
  93288. /**
  93289. * Defines the input associated to the camera.
  93290. */
  93291. inputs: ArcRotateCameraInputsManager;
  93292. /** @hidden */
  93293. _reset: () => void;
  93294. /**
  93295. * Defines the allowed panning axis.
  93296. */
  93297. panningAxis: Vector3;
  93298. protected _localDirection: Vector3;
  93299. protected _transformedDirection: Vector3;
  93300. private _bouncingBehavior;
  93301. /**
  93302. * Gets the bouncing behavior of the camera if it has been enabled.
  93303. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  93304. */
  93305. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  93306. /**
  93307. * Defines if the bouncing behavior of the camera is enabled on the camera.
  93308. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  93309. */
  93310. useBouncingBehavior: boolean;
  93311. private _framingBehavior;
  93312. /**
  93313. * Gets the framing behavior of the camera if it has been enabled.
  93314. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  93315. */
  93316. readonly framingBehavior: Nullable<FramingBehavior>;
  93317. /**
  93318. * Defines if the framing behavior of the camera is enabled on the camera.
  93319. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  93320. */
  93321. useFramingBehavior: boolean;
  93322. private _autoRotationBehavior;
  93323. /**
  93324. * Gets the auto rotation behavior of the camera if it has been enabled.
  93325. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  93326. */
  93327. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  93328. /**
  93329. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  93330. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  93331. */
  93332. useAutoRotationBehavior: boolean;
  93333. /**
  93334. * Observable triggered when the mesh target has been changed on the camera.
  93335. */
  93336. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  93337. /**
  93338. * Event raised when the camera is colliding with a mesh.
  93339. */
  93340. onCollide: (collidedMesh: AbstractMesh) => void;
  93341. /**
  93342. * Defines whether the camera should check collision with the objects oh the scene.
  93343. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  93344. */
  93345. checkCollisions: boolean;
  93346. /**
  93347. * Defines the collision radius of the camera.
  93348. * This simulates a sphere around the camera.
  93349. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  93350. */
  93351. collisionRadius: Vector3;
  93352. protected _collider: Collider;
  93353. protected _previousPosition: Vector3;
  93354. protected _collisionVelocity: Vector3;
  93355. protected _newPosition: Vector3;
  93356. protected _previousAlpha: number;
  93357. protected _previousBeta: number;
  93358. protected _previousRadius: number;
  93359. protected _collisionTriggered: boolean;
  93360. protected _targetBoundingCenter: Nullable<Vector3>;
  93361. private _computationVector;
  93362. private _tempAxisVector;
  93363. private _tempAxisRotationMatrix;
  93364. /**
  93365. * Instantiates a new ArcRotateCamera in a given scene
  93366. * @param name Defines the name of the camera
  93367. * @param alpha Defines the camera rotation along the logitudinal axis
  93368. * @param beta Defines the camera rotation along the latitudinal axis
  93369. * @param radius Defines the camera distance from its target
  93370. * @param target Defines the camera target
  93371. * @param scene Defines the scene the camera belongs to
  93372. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  93373. */
  93374. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  93375. /** @hidden */
  93376. _initCache(): void;
  93377. /** @hidden */
  93378. _updateCache(ignoreParentClass?: boolean): void;
  93379. protected _getTargetPosition(): Vector3;
  93380. private _storedAlpha;
  93381. private _storedBeta;
  93382. private _storedRadius;
  93383. private _storedTarget;
  93384. /**
  93385. * Stores the current state of the camera (alpha, beta, radius and target)
  93386. * @returns the camera itself
  93387. */
  93388. storeState(): Camera;
  93389. /**
  93390. * @hidden
  93391. * Restored camera state. You must call storeState() first
  93392. */
  93393. _restoreStateValues(): boolean;
  93394. /** @hidden */
  93395. _isSynchronizedViewMatrix(): boolean;
  93396. /**
  93397. * Attached controls to the current camera.
  93398. * @param element Defines the element the controls should be listened from
  93399. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93400. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  93401. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  93402. */
  93403. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  93404. /**
  93405. * Detach the current controls from the camera.
  93406. * The camera will stop reacting to inputs.
  93407. * @param element Defines the element to stop listening the inputs from
  93408. */
  93409. detachControl(element: HTMLElement): void;
  93410. /** @hidden */
  93411. _checkInputs(): void;
  93412. protected _checkLimits(): void;
  93413. /**
  93414. * Rebuilds angles (alpha, beta) and radius from the give position and target
  93415. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  93416. */
  93417. rebuildAnglesAndRadius(updateView?: boolean): void;
  93418. /**
  93419. * Use a position to define the current camera related information like aplha, beta and radius
  93420. * @param position Defines the position to set the camera at
  93421. */
  93422. setPosition(position: Vector3): void;
  93423. /**
  93424. * Defines the target the camera should look at.
  93425. * This will automatically adapt alpha beta and radius to fit within the new target.
  93426. * @param target Defines the new target as a Vector or a mesh
  93427. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  93428. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  93429. */
  93430. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  93431. /** @hidden */
  93432. _getViewMatrix(): Matrix;
  93433. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  93434. /**
  93435. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  93436. * @param meshes Defines the mesh to zoom on
  93437. * @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)
  93438. */
  93439. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  93440. /**
  93441. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  93442. * The target will be changed but the radius
  93443. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  93444. * @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)
  93445. */
  93446. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  93447. min: Vector3;
  93448. max: Vector3;
  93449. distance: number;
  93450. }, doNotUpdateMaxZ?: boolean): void;
  93451. /**
  93452. * @override
  93453. * Override Camera.createRigCamera
  93454. */
  93455. createRigCamera(name: string, cameraIndex: number): Camera;
  93456. /**
  93457. * @hidden
  93458. * @override
  93459. * Override Camera._updateRigCameras
  93460. */
  93461. _updateRigCameras(): void;
  93462. /**
  93463. * Destroy the camera and release the current resources hold by it.
  93464. */
  93465. dispose(): void;
  93466. /**
  93467. * Gets the current object class name.
  93468. * @return the class name
  93469. */
  93470. getClassName(): string;
  93471. }
  93472. }
  93473. declare module BABYLON {
  93474. /**
  93475. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  93476. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  93477. */
  93478. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  93479. /**
  93480. * Gets the name of the behavior.
  93481. */
  93482. readonly name: string;
  93483. private _zoomStopsAnimation;
  93484. private _idleRotationSpeed;
  93485. private _idleRotationWaitTime;
  93486. private _idleRotationSpinupTime;
  93487. /**
  93488. * Sets the flag that indicates if user zooming should stop animation.
  93489. */
  93490. /**
  93491. * Gets the flag that indicates if user zooming should stop animation.
  93492. */
  93493. zoomStopsAnimation: boolean;
  93494. /**
  93495. * Sets the default speed at which the camera rotates around the model.
  93496. */
  93497. /**
  93498. * Gets the default speed at which the camera rotates around the model.
  93499. */
  93500. idleRotationSpeed: number;
  93501. /**
  93502. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  93503. */
  93504. /**
  93505. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  93506. */
  93507. idleRotationWaitTime: number;
  93508. /**
  93509. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  93510. */
  93511. /**
  93512. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  93513. */
  93514. idleRotationSpinupTime: number;
  93515. /**
  93516. * Gets a value indicating if the camera is currently rotating because of this behavior
  93517. */
  93518. readonly rotationInProgress: boolean;
  93519. private _onPrePointerObservableObserver;
  93520. private _onAfterCheckInputsObserver;
  93521. private _attachedCamera;
  93522. private _isPointerDown;
  93523. private _lastFrameTime;
  93524. private _lastInteractionTime;
  93525. private _cameraRotationSpeed;
  93526. /**
  93527. * Initializes the behavior.
  93528. */
  93529. init(): void;
  93530. /**
  93531. * Attaches the behavior to its arc rotate camera.
  93532. * @param camera Defines the camera to attach the behavior to
  93533. */
  93534. attach(camera: ArcRotateCamera): void;
  93535. /**
  93536. * Detaches the behavior from its current arc rotate camera.
  93537. */
  93538. detach(): void;
  93539. /**
  93540. * Returns true if user is scrolling.
  93541. * @return true if user is scrolling.
  93542. */
  93543. private _userIsZooming;
  93544. private _lastFrameRadius;
  93545. private _shouldAnimationStopForInteraction;
  93546. /**
  93547. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  93548. */
  93549. private _applyUserInteraction;
  93550. private _userIsMoving;
  93551. }
  93552. }
  93553. declare module BABYLON {
  93554. /**
  93555. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  93556. */
  93557. export class AttachToBoxBehavior implements Behavior<Mesh> {
  93558. private ui;
  93559. /**
  93560. * The name of the behavior
  93561. */
  93562. name: string;
  93563. /**
  93564. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  93565. */
  93566. distanceAwayFromFace: number;
  93567. /**
  93568. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  93569. */
  93570. distanceAwayFromBottomOfFace: number;
  93571. private _faceVectors;
  93572. private _target;
  93573. private _scene;
  93574. private _onRenderObserver;
  93575. private _tmpMatrix;
  93576. private _tmpVector;
  93577. /**
  93578. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  93579. * @param ui The transform node that should be attched to the mesh
  93580. */
  93581. constructor(ui: TransformNode);
  93582. /**
  93583. * Initializes the behavior
  93584. */
  93585. init(): void;
  93586. private _closestFace;
  93587. private _zeroVector;
  93588. private _lookAtTmpMatrix;
  93589. private _lookAtToRef;
  93590. /**
  93591. * Attaches the AttachToBoxBehavior to the passed in mesh
  93592. * @param target The mesh that the specified node will be attached to
  93593. */
  93594. attach(target: Mesh): void;
  93595. /**
  93596. * Detaches the behavior from the mesh
  93597. */
  93598. detach(): void;
  93599. }
  93600. }
  93601. declare module BABYLON {
  93602. /**
  93603. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  93604. */
  93605. export class FadeInOutBehavior implements Behavior<Mesh> {
  93606. /**
  93607. * Time in milliseconds to delay before fading in (Default: 0)
  93608. */
  93609. delay: number;
  93610. /**
  93611. * Time in milliseconds for the mesh to fade in (Default: 300)
  93612. */
  93613. fadeInTime: number;
  93614. private _millisecondsPerFrame;
  93615. private _hovered;
  93616. private _hoverValue;
  93617. private _ownerNode;
  93618. /**
  93619. * Instatiates the FadeInOutBehavior
  93620. */
  93621. constructor();
  93622. /**
  93623. * The name of the behavior
  93624. */
  93625. readonly name: string;
  93626. /**
  93627. * Initializes the behavior
  93628. */
  93629. init(): void;
  93630. /**
  93631. * Attaches the fade behavior on the passed in mesh
  93632. * @param ownerNode The mesh that will be faded in/out once attached
  93633. */
  93634. attach(ownerNode: Mesh): void;
  93635. /**
  93636. * Detaches the behavior from the mesh
  93637. */
  93638. detach(): void;
  93639. /**
  93640. * Triggers the mesh to begin fading in or out
  93641. * @param value if the object should fade in or out (true to fade in)
  93642. */
  93643. fadeIn(value: boolean): void;
  93644. private _update;
  93645. private _setAllVisibility;
  93646. }
  93647. }
  93648. declare module BABYLON {
  93649. /**
  93650. * Class containing a set of static utilities functions for managing Pivots
  93651. * @hidden
  93652. */
  93653. export class PivotTools {
  93654. private static _PivotCached;
  93655. private static _OldPivotPoint;
  93656. private static _PivotTranslation;
  93657. private static _PivotTmpVector;
  93658. /** @hidden */
  93659. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  93660. /** @hidden */
  93661. static _RestorePivotPoint(mesh: AbstractMesh): void;
  93662. }
  93663. }
  93664. declare module BABYLON {
  93665. /**
  93666. * Class containing static functions to help procedurally build meshes
  93667. */
  93668. export class PlaneBuilder {
  93669. /**
  93670. * Creates a plane mesh
  93671. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  93672. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  93673. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  93674. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  93675. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  93676. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  93677. * @param name defines the name of the mesh
  93678. * @param options defines the options used to create the mesh
  93679. * @param scene defines the hosting scene
  93680. * @returns the plane mesh
  93681. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  93682. */
  93683. static CreatePlane(name: string, options: {
  93684. size?: number;
  93685. width?: number;
  93686. height?: number;
  93687. sideOrientation?: number;
  93688. frontUVs?: Vector4;
  93689. backUVs?: Vector4;
  93690. updatable?: boolean;
  93691. sourcePlane?: Plane;
  93692. }, scene: Scene): Mesh;
  93693. }
  93694. }
  93695. declare module BABYLON {
  93696. /**
  93697. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  93698. */
  93699. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  93700. private static _AnyMouseID;
  93701. private _attachedNode;
  93702. private _dragPlane;
  93703. private _scene;
  93704. private _pointerObserver;
  93705. private _beforeRenderObserver;
  93706. private static _planeScene;
  93707. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  93708. /**
  93709. * 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)
  93710. */
  93711. maxDragAngle: number;
  93712. /**
  93713. * @hidden
  93714. */
  93715. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  93716. /**
  93717. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  93718. */
  93719. currentDraggingPointerID: number;
  93720. /**
  93721. * The last position where the pointer hit the drag plane in world space
  93722. */
  93723. lastDragPosition: Vector3;
  93724. /**
  93725. * If the behavior is currently in a dragging state
  93726. */
  93727. dragging: boolean;
  93728. /**
  93729. * 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)
  93730. */
  93731. dragDeltaRatio: number;
  93732. /**
  93733. * If the drag plane orientation should be updated during the dragging (Default: true)
  93734. */
  93735. updateDragPlane: boolean;
  93736. private _debugMode;
  93737. private _moving;
  93738. /**
  93739. * Fires each time the attached mesh is dragged with the pointer
  93740. * * delta between last drag position and current drag position in world space
  93741. * * dragDistance along the drag axis
  93742. * * dragPlaneNormal normal of the current drag plane used during the drag
  93743. * * dragPlanePoint in world space where the drag intersects the drag plane
  93744. */
  93745. onDragObservable: Observable<{
  93746. delta: Vector3;
  93747. dragPlanePoint: Vector3;
  93748. dragPlaneNormal: Vector3;
  93749. dragDistance: number;
  93750. pointerId: number;
  93751. }>;
  93752. /**
  93753. * Fires each time a drag begins (eg. mouse down on mesh)
  93754. */
  93755. onDragStartObservable: Observable<{
  93756. dragPlanePoint: Vector3;
  93757. pointerId: number;
  93758. }>;
  93759. /**
  93760. * Fires each time a drag ends (eg. mouse release after drag)
  93761. */
  93762. onDragEndObservable: Observable<{
  93763. dragPlanePoint: Vector3;
  93764. pointerId: number;
  93765. }>;
  93766. /**
  93767. * If the attached mesh should be moved when dragged
  93768. */
  93769. moveAttached: boolean;
  93770. /**
  93771. * If the drag behavior will react to drag events (Default: true)
  93772. */
  93773. enabled: boolean;
  93774. /**
  93775. * If camera controls should be detached during the drag
  93776. */
  93777. detachCameraControls: boolean;
  93778. /**
  93779. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  93780. */
  93781. useObjectOrienationForDragging: boolean;
  93782. private _options;
  93783. /**
  93784. * Creates a pointer drag behavior that can be attached to a mesh
  93785. * @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)
  93786. */
  93787. constructor(options?: {
  93788. dragAxis?: Vector3;
  93789. dragPlaneNormal?: Vector3;
  93790. });
  93791. /**
  93792. * Predicate to determine if it is valid to move the object to a new position when it is moved
  93793. */
  93794. validateDrag: (targetPosition: Vector3) => boolean;
  93795. /**
  93796. * The name of the behavior
  93797. */
  93798. readonly name: string;
  93799. /**
  93800. * Initializes the behavior
  93801. */
  93802. init(): void;
  93803. private _tmpVector;
  93804. private _alternatePickedPoint;
  93805. private _worldDragAxis;
  93806. private _targetPosition;
  93807. private _attachedElement;
  93808. /**
  93809. * Attaches the drag behavior the passed in mesh
  93810. * @param ownerNode The mesh that will be dragged around once attached
  93811. */
  93812. attach(ownerNode: AbstractMesh): void;
  93813. /**
  93814. * Force relase the drag action by code.
  93815. */
  93816. releaseDrag(): void;
  93817. private _startDragRay;
  93818. private _lastPointerRay;
  93819. /**
  93820. * Simulates the start of a pointer drag event on the behavior
  93821. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  93822. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  93823. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  93824. */
  93825. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  93826. private _startDrag;
  93827. private _dragDelta;
  93828. private _moveDrag;
  93829. private _pickWithRayOnDragPlane;
  93830. private _pointA;
  93831. private _pointB;
  93832. private _pointC;
  93833. private _lineA;
  93834. private _lineB;
  93835. private _localAxis;
  93836. private _lookAt;
  93837. private _updateDragPlanePosition;
  93838. /**
  93839. * Detaches the behavior from the mesh
  93840. */
  93841. detach(): void;
  93842. }
  93843. }
  93844. declare module BABYLON {
  93845. /**
  93846. * A behavior that when attached to a mesh will allow the mesh to be scaled
  93847. */
  93848. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  93849. private _dragBehaviorA;
  93850. private _dragBehaviorB;
  93851. private _startDistance;
  93852. private _initialScale;
  93853. private _targetScale;
  93854. private _ownerNode;
  93855. private _sceneRenderObserver;
  93856. /**
  93857. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  93858. */
  93859. constructor();
  93860. /**
  93861. * The name of the behavior
  93862. */
  93863. readonly name: string;
  93864. /**
  93865. * Initializes the behavior
  93866. */
  93867. init(): void;
  93868. private _getCurrentDistance;
  93869. /**
  93870. * Attaches the scale behavior the passed in mesh
  93871. * @param ownerNode The mesh that will be scaled around once attached
  93872. */
  93873. attach(ownerNode: Mesh): void;
  93874. /**
  93875. * Detaches the behavior from the mesh
  93876. */
  93877. detach(): void;
  93878. }
  93879. }
  93880. declare module BABYLON {
  93881. /**
  93882. * 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
  93883. */
  93884. export class SixDofDragBehavior implements Behavior<Mesh> {
  93885. private static _virtualScene;
  93886. private _ownerNode;
  93887. private _sceneRenderObserver;
  93888. private _scene;
  93889. private _targetPosition;
  93890. private _virtualOriginMesh;
  93891. private _virtualDragMesh;
  93892. private _pointerObserver;
  93893. private _moving;
  93894. private _startingOrientation;
  93895. /**
  93896. * 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)
  93897. */
  93898. private zDragFactor;
  93899. /**
  93900. * If the object should rotate to face the drag origin
  93901. */
  93902. rotateDraggedObject: boolean;
  93903. /**
  93904. * If the behavior is currently in a dragging state
  93905. */
  93906. dragging: boolean;
  93907. /**
  93908. * 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)
  93909. */
  93910. dragDeltaRatio: number;
  93911. /**
  93912. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  93913. */
  93914. currentDraggingPointerID: number;
  93915. /**
  93916. * If camera controls should be detached during the drag
  93917. */
  93918. detachCameraControls: boolean;
  93919. /**
  93920. * Fires each time a drag starts
  93921. */
  93922. onDragStartObservable: Observable<{}>;
  93923. /**
  93924. * Fires each time a drag ends (eg. mouse release after drag)
  93925. */
  93926. onDragEndObservable: Observable<{}>;
  93927. /**
  93928. * 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
  93929. */
  93930. constructor();
  93931. /**
  93932. * The name of the behavior
  93933. */
  93934. readonly name: string;
  93935. /**
  93936. * Initializes the behavior
  93937. */
  93938. init(): void;
  93939. /**
  93940. * Attaches the scale behavior the passed in mesh
  93941. * @param ownerNode The mesh that will be scaled around once attached
  93942. */
  93943. attach(ownerNode: Mesh): void;
  93944. /**
  93945. * Detaches the behavior from the mesh
  93946. */
  93947. detach(): void;
  93948. }
  93949. }
  93950. declare module BABYLON {
  93951. /**
  93952. * Class used to apply inverse kinematics to bones
  93953. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  93954. */
  93955. export class BoneIKController {
  93956. private static _tmpVecs;
  93957. private static _tmpQuat;
  93958. private static _tmpMats;
  93959. /**
  93960. * Gets or sets the target mesh
  93961. */
  93962. targetMesh: AbstractMesh;
  93963. /** Gets or sets the mesh used as pole */
  93964. poleTargetMesh: AbstractMesh;
  93965. /**
  93966. * Gets or sets the bone used as pole
  93967. */
  93968. poleTargetBone: Nullable<Bone>;
  93969. /**
  93970. * Gets or sets the target position
  93971. */
  93972. targetPosition: Vector3;
  93973. /**
  93974. * Gets or sets the pole target position
  93975. */
  93976. poleTargetPosition: Vector3;
  93977. /**
  93978. * Gets or sets the pole target local offset
  93979. */
  93980. poleTargetLocalOffset: Vector3;
  93981. /**
  93982. * Gets or sets the pole angle
  93983. */
  93984. poleAngle: number;
  93985. /**
  93986. * Gets or sets the mesh associated with the controller
  93987. */
  93988. mesh: AbstractMesh;
  93989. /**
  93990. * 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)
  93991. */
  93992. slerpAmount: number;
  93993. private _bone1Quat;
  93994. private _bone1Mat;
  93995. private _bone2Ang;
  93996. private _bone1;
  93997. private _bone2;
  93998. private _bone1Length;
  93999. private _bone2Length;
  94000. private _maxAngle;
  94001. private _maxReach;
  94002. private _rightHandedSystem;
  94003. private _bendAxis;
  94004. private _slerping;
  94005. private _adjustRoll;
  94006. /**
  94007. * Gets or sets maximum allowed angle
  94008. */
  94009. maxAngle: number;
  94010. /**
  94011. * Creates a new BoneIKController
  94012. * @param mesh defines the mesh to control
  94013. * @param bone defines the bone to control
  94014. * @param options defines options to set up the controller
  94015. */
  94016. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  94017. targetMesh?: AbstractMesh;
  94018. poleTargetMesh?: AbstractMesh;
  94019. poleTargetBone?: Bone;
  94020. poleTargetLocalOffset?: Vector3;
  94021. poleAngle?: number;
  94022. bendAxis?: Vector3;
  94023. maxAngle?: number;
  94024. slerpAmount?: number;
  94025. });
  94026. private _setMaxAngle;
  94027. /**
  94028. * Force the controller to update the bones
  94029. */
  94030. update(): void;
  94031. }
  94032. }
  94033. declare module BABYLON {
  94034. /**
  94035. * Class used to make a bone look toward a point in space
  94036. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  94037. */
  94038. export class BoneLookController {
  94039. private static _tmpVecs;
  94040. private static _tmpQuat;
  94041. private static _tmpMats;
  94042. /**
  94043. * The target Vector3 that the bone will look at
  94044. */
  94045. target: Vector3;
  94046. /**
  94047. * The mesh that the bone is attached to
  94048. */
  94049. mesh: AbstractMesh;
  94050. /**
  94051. * The bone that will be looking to the target
  94052. */
  94053. bone: Bone;
  94054. /**
  94055. * The up axis of the coordinate system that is used when the bone is rotated
  94056. */
  94057. upAxis: Vector3;
  94058. /**
  94059. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  94060. */
  94061. upAxisSpace: Space;
  94062. /**
  94063. * Used to make an adjustment to the yaw of the bone
  94064. */
  94065. adjustYaw: number;
  94066. /**
  94067. * Used to make an adjustment to the pitch of the bone
  94068. */
  94069. adjustPitch: number;
  94070. /**
  94071. * Used to make an adjustment to the roll of the bone
  94072. */
  94073. adjustRoll: number;
  94074. /**
  94075. * 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)
  94076. */
  94077. slerpAmount: number;
  94078. private _minYaw;
  94079. private _maxYaw;
  94080. private _minPitch;
  94081. private _maxPitch;
  94082. private _minYawSin;
  94083. private _minYawCos;
  94084. private _maxYawSin;
  94085. private _maxYawCos;
  94086. private _midYawConstraint;
  94087. private _minPitchTan;
  94088. private _maxPitchTan;
  94089. private _boneQuat;
  94090. private _slerping;
  94091. private _transformYawPitch;
  94092. private _transformYawPitchInv;
  94093. private _firstFrameSkipped;
  94094. private _yawRange;
  94095. private _fowardAxis;
  94096. /**
  94097. * Gets or sets the minimum yaw angle that the bone can look to
  94098. */
  94099. minYaw: number;
  94100. /**
  94101. * Gets or sets the maximum yaw angle that the bone can look to
  94102. */
  94103. maxYaw: number;
  94104. /**
  94105. * Gets or sets the minimum pitch angle that the bone can look to
  94106. */
  94107. minPitch: number;
  94108. /**
  94109. * Gets or sets the maximum pitch angle that the bone can look to
  94110. */
  94111. maxPitch: number;
  94112. /**
  94113. * Create a BoneLookController
  94114. * @param mesh the mesh that the bone belongs to
  94115. * @param bone the bone that will be looking to the target
  94116. * @param target the target Vector3 to look at
  94117. * @param options optional settings:
  94118. * * maxYaw: the maximum angle the bone will yaw to
  94119. * * minYaw: the minimum angle the bone will yaw to
  94120. * * maxPitch: the maximum angle the bone will pitch to
  94121. * * minPitch: the minimum angle the bone will yaw to
  94122. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  94123. * * upAxis: the up axis of the coordinate system
  94124. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  94125. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  94126. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  94127. * * adjustYaw: used to make an adjustment to the yaw of the bone
  94128. * * adjustPitch: used to make an adjustment to the pitch of the bone
  94129. * * adjustRoll: used to make an adjustment to the roll of the bone
  94130. **/
  94131. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  94132. maxYaw?: number;
  94133. minYaw?: number;
  94134. maxPitch?: number;
  94135. minPitch?: number;
  94136. slerpAmount?: number;
  94137. upAxis?: Vector3;
  94138. upAxisSpace?: Space;
  94139. yawAxis?: Vector3;
  94140. pitchAxis?: Vector3;
  94141. adjustYaw?: number;
  94142. adjustPitch?: number;
  94143. adjustRoll?: number;
  94144. });
  94145. /**
  94146. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  94147. */
  94148. update(): void;
  94149. private _getAngleDiff;
  94150. private _getAngleBetween;
  94151. private _isAngleBetween;
  94152. }
  94153. }
  94154. declare module BABYLON {
  94155. /**
  94156. * Manage the gamepad inputs to control an arc rotate camera.
  94157. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94158. */
  94159. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  94160. /**
  94161. * Defines the camera the input is attached to.
  94162. */
  94163. camera: ArcRotateCamera;
  94164. /**
  94165. * Defines the gamepad the input is gathering event from.
  94166. */
  94167. gamepad: Nullable<Gamepad>;
  94168. /**
  94169. * Defines the gamepad rotation sensiblity.
  94170. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  94171. */
  94172. gamepadRotationSensibility: number;
  94173. /**
  94174. * Defines the gamepad move sensiblity.
  94175. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  94176. */
  94177. gamepadMoveSensibility: number;
  94178. private _onGamepadConnectedObserver;
  94179. private _onGamepadDisconnectedObserver;
  94180. /**
  94181. * Attach the input controls to a specific dom element to get the input from.
  94182. * @param element Defines the element the controls should be listened from
  94183. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94184. */
  94185. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94186. /**
  94187. * Detach the current controls from the specified dom element.
  94188. * @param element Defines the element to stop listening the inputs from
  94189. */
  94190. detachControl(element: Nullable<HTMLElement>): void;
  94191. /**
  94192. * Update the current camera state depending on the inputs that have been used this frame.
  94193. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94194. */
  94195. checkInputs(): void;
  94196. /**
  94197. * Gets the class name of the current intput.
  94198. * @returns the class name
  94199. */
  94200. getClassName(): string;
  94201. /**
  94202. * Get the friendly name associated with the input class.
  94203. * @returns the input friendly name
  94204. */
  94205. getSimpleName(): string;
  94206. }
  94207. }
  94208. declare module BABYLON {
  94209. interface ArcRotateCameraInputsManager {
  94210. /**
  94211. * Add orientation input support to the input manager.
  94212. * @returns the current input manager
  94213. */
  94214. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  94215. }
  94216. /**
  94217. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  94218. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94219. */
  94220. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  94221. /**
  94222. * Defines the camera the input is attached to.
  94223. */
  94224. camera: ArcRotateCamera;
  94225. /**
  94226. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  94227. */
  94228. alphaCorrection: number;
  94229. /**
  94230. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  94231. */
  94232. gammaCorrection: number;
  94233. private _alpha;
  94234. private _gamma;
  94235. private _dirty;
  94236. private _deviceOrientationHandler;
  94237. /**
  94238. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  94239. */
  94240. constructor();
  94241. /**
  94242. * Attach the input controls to a specific dom element to get the input from.
  94243. * @param element Defines the element the controls should be listened from
  94244. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94245. */
  94246. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94247. /** @hidden */
  94248. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  94249. /**
  94250. * Update the current camera state depending on the inputs that have been used this frame.
  94251. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94252. */
  94253. checkInputs(): void;
  94254. /**
  94255. * Detach the current controls from the specified dom element.
  94256. * @param element Defines the element to stop listening the inputs from
  94257. */
  94258. detachControl(element: Nullable<HTMLElement>): void;
  94259. /**
  94260. * Gets the class name of the current intput.
  94261. * @returns the class name
  94262. */
  94263. getClassName(): string;
  94264. /**
  94265. * Get the friendly name associated with the input class.
  94266. * @returns the input friendly name
  94267. */
  94268. getSimpleName(): string;
  94269. }
  94270. }
  94271. declare module BABYLON {
  94272. /**
  94273. * Listen to mouse events to control the camera.
  94274. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94275. */
  94276. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  94277. /**
  94278. * Defines the camera the input is attached to.
  94279. */
  94280. camera: FlyCamera;
  94281. /**
  94282. * Defines if touch is enabled. (Default is true.)
  94283. */
  94284. touchEnabled: boolean;
  94285. /**
  94286. * Defines the buttons associated with the input to handle camera rotation.
  94287. */
  94288. buttons: number[];
  94289. /**
  94290. * Assign buttons for Yaw control.
  94291. */
  94292. buttonsYaw: number[];
  94293. /**
  94294. * Assign buttons for Pitch control.
  94295. */
  94296. buttonsPitch: number[];
  94297. /**
  94298. * Assign buttons for Roll control.
  94299. */
  94300. buttonsRoll: number[];
  94301. /**
  94302. * Detect if any button is being pressed while mouse is moved.
  94303. * -1 = Mouse locked.
  94304. * 0 = Left button.
  94305. * 1 = Middle Button.
  94306. * 2 = Right Button.
  94307. */
  94308. activeButton: number;
  94309. /**
  94310. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  94311. * Higher values reduce its sensitivity.
  94312. */
  94313. angularSensibility: number;
  94314. private _mousemoveCallback;
  94315. private _observer;
  94316. private _rollObserver;
  94317. private previousPosition;
  94318. private noPreventDefault;
  94319. private element;
  94320. /**
  94321. * Listen to mouse events to control the camera.
  94322. * @param touchEnabled Define if touch is enabled. (Default is true.)
  94323. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94324. */
  94325. constructor(touchEnabled?: boolean);
  94326. /**
  94327. * Attach the mouse control to the HTML DOM element.
  94328. * @param element Defines the element that listens to the input events.
  94329. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  94330. */
  94331. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94332. /**
  94333. * Detach the current controls from the specified dom element.
  94334. * @param element Defines the element to stop listening the inputs from
  94335. */
  94336. detachControl(element: Nullable<HTMLElement>): void;
  94337. /**
  94338. * Gets the class name of the current input.
  94339. * @returns the class name.
  94340. */
  94341. getClassName(): string;
  94342. /**
  94343. * Get the friendly name associated with the input class.
  94344. * @returns the input's friendly name.
  94345. */
  94346. getSimpleName(): string;
  94347. private _pointerInput;
  94348. private _onMouseMove;
  94349. /**
  94350. * Rotate camera by mouse offset.
  94351. */
  94352. private rotateCamera;
  94353. }
  94354. }
  94355. declare module BABYLON {
  94356. /**
  94357. * Default Inputs manager for the FlyCamera.
  94358. * It groups all the default supported inputs for ease of use.
  94359. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94360. */
  94361. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  94362. /**
  94363. * Instantiates a new FlyCameraInputsManager.
  94364. * @param camera Defines the camera the inputs belong to.
  94365. */
  94366. constructor(camera: FlyCamera);
  94367. /**
  94368. * Add keyboard input support to the input manager.
  94369. * @returns the new FlyCameraKeyboardMoveInput().
  94370. */
  94371. addKeyboard(): FlyCameraInputsManager;
  94372. /**
  94373. * Add mouse input support to the input manager.
  94374. * @param touchEnabled Enable touch screen support.
  94375. * @returns the new FlyCameraMouseInput().
  94376. */
  94377. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  94378. }
  94379. }
  94380. declare module BABYLON {
  94381. /**
  94382. * This is a flying camera, designed for 3D movement and rotation in all directions,
  94383. * such as in a 3D Space Shooter or a Flight Simulator.
  94384. */
  94385. export class FlyCamera extends TargetCamera {
  94386. /**
  94387. * Define the collision ellipsoid of the camera.
  94388. * This is helpful for simulating a camera body, like a player's body.
  94389. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  94390. */
  94391. ellipsoid: Vector3;
  94392. /**
  94393. * Define an offset for the position of the ellipsoid around the camera.
  94394. * This can be helpful if the camera is attached away from the player's body center,
  94395. * such as at its head.
  94396. */
  94397. ellipsoidOffset: Vector3;
  94398. /**
  94399. * Enable or disable collisions of the camera with the rest of the scene objects.
  94400. */
  94401. checkCollisions: boolean;
  94402. /**
  94403. * Enable or disable gravity on the camera.
  94404. */
  94405. applyGravity: boolean;
  94406. /**
  94407. * Define the current direction the camera is moving to.
  94408. */
  94409. cameraDirection: Vector3;
  94410. /**
  94411. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  94412. * This overrides and empties cameraRotation.
  94413. */
  94414. rotationQuaternion: Quaternion;
  94415. /**
  94416. * Track Roll to maintain the wanted Rolling when looking around.
  94417. */
  94418. _trackRoll: number;
  94419. /**
  94420. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  94421. */
  94422. rollCorrect: number;
  94423. /**
  94424. * Mimic a banked turn, Rolling the camera when Yawing.
  94425. * It's recommended to use rollCorrect = 10 for faster banking correction.
  94426. */
  94427. bankedTurn: boolean;
  94428. /**
  94429. * Limit in radians for how much Roll banking will add. (Default: 90°)
  94430. */
  94431. bankedTurnLimit: number;
  94432. /**
  94433. * Value of 0 disables the banked Roll.
  94434. * Value of 1 is equal to the Yaw angle in radians.
  94435. */
  94436. bankedTurnMultiplier: number;
  94437. /**
  94438. * The inputs manager loads all the input sources, such as keyboard and mouse.
  94439. */
  94440. inputs: FlyCameraInputsManager;
  94441. /**
  94442. * Gets the input sensibility for mouse input.
  94443. * Higher values reduce sensitivity.
  94444. */
  94445. /**
  94446. * Sets the input sensibility for a mouse input.
  94447. * Higher values reduce sensitivity.
  94448. */
  94449. angularSensibility: number;
  94450. /**
  94451. * Get the keys for camera movement forward.
  94452. */
  94453. /**
  94454. * Set the keys for camera movement forward.
  94455. */
  94456. keysForward: number[];
  94457. /**
  94458. * Get the keys for camera movement backward.
  94459. */
  94460. keysBackward: number[];
  94461. /**
  94462. * Get the keys for camera movement up.
  94463. */
  94464. /**
  94465. * Set the keys for camera movement up.
  94466. */
  94467. keysUp: number[];
  94468. /**
  94469. * Get the keys for camera movement down.
  94470. */
  94471. /**
  94472. * Set the keys for camera movement down.
  94473. */
  94474. keysDown: number[];
  94475. /**
  94476. * Get the keys for camera movement left.
  94477. */
  94478. /**
  94479. * Set the keys for camera movement left.
  94480. */
  94481. keysLeft: number[];
  94482. /**
  94483. * Set the keys for camera movement right.
  94484. */
  94485. /**
  94486. * Set the keys for camera movement right.
  94487. */
  94488. keysRight: number[];
  94489. /**
  94490. * Event raised when the camera collides with a mesh in the scene.
  94491. */
  94492. onCollide: (collidedMesh: AbstractMesh) => void;
  94493. private _collider;
  94494. private _needMoveForGravity;
  94495. private _oldPosition;
  94496. private _diffPosition;
  94497. private _newPosition;
  94498. /** @hidden */
  94499. _localDirection: Vector3;
  94500. /** @hidden */
  94501. _transformedDirection: Vector3;
  94502. /**
  94503. * Instantiates a FlyCamera.
  94504. * This is a flying camera, designed for 3D movement and rotation in all directions,
  94505. * such as in a 3D Space Shooter or a Flight Simulator.
  94506. * @param name Define the name of the camera in the scene.
  94507. * @param position Define the starting position of the camera in the scene.
  94508. * @param scene Define the scene the camera belongs to.
  94509. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  94510. */
  94511. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  94512. /**
  94513. * Attach a control to the HTML DOM element.
  94514. * @param element Defines the element that listens to the input events.
  94515. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  94516. */
  94517. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94518. /**
  94519. * Detach a control from the HTML DOM element.
  94520. * The camera will stop reacting to that input.
  94521. * @param element Defines the element that listens to the input events.
  94522. */
  94523. detachControl(element: HTMLElement): void;
  94524. private _collisionMask;
  94525. /**
  94526. * Get the mask that the camera ignores in collision events.
  94527. */
  94528. /**
  94529. * Set the mask that the camera ignores in collision events.
  94530. */
  94531. collisionMask: number;
  94532. /** @hidden */
  94533. _collideWithWorld(displacement: Vector3): void;
  94534. /** @hidden */
  94535. private _onCollisionPositionChange;
  94536. /** @hidden */
  94537. _checkInputs(): void;
  94538. /** @hidden */
  94539. _decideIfNeedsToMove(): boolean;
  94540. /** @hidden */
  94541. _updatePosition(): void;
  94542. /**
  94543. * Restore the Roll to its target value at the rate specified.
  94544. * @param rate - Higher means slower restoring.
  94545. * @hidden
  94546. */
  94547. restoreRoll(rate: number): void;
  94548. /**
  94549. * Destroy the camera and release the current resources held by it.
  94550. */
  94551. dispose(): void;
  94552. /**
  94553. * Get the current object class name.
  94554. * @returns the class name.
  94555. */
  94556. getClassName(): string;
  94557. }
  94558. }
  94559. declare module BABYLON {
  94560. /**
  94561. * Listen to keyboard events to control the camera.
  94562. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94563. */
  94564. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  94565. /**
  94566. * Defines the camera the input is attached to.
  94567. */
  94568. camera: FlyCamera;
  94569. /**
  94570. * The list of keyboard keys used to control the forward move of the camera.
  94571. */
  94572. keysForward: number[];
  94573. /**
  94574. * The list of keyboard keys used to control the backward move of the camera.
  94575. */
  94576. keysBackward: number[];
  94577. /**
  94578. * The list of keyboard keys used to control the forward move of the camera.
  94579. */
  94580. keysUp: number[];
  94581. /**
  94582. * The list of keyboard keys used to control the backward move of the camera.
  94583. */
  94584. keysDown: number[];
  94585. /**
  94586. * The list of keyboard keys used to control the right strafe move of the camera.
  94587. */
  94588. keysRight: number[];
  94589. /**
  94590. * The list of keyboard keys used to control the left strafe move of the camera.
  94591. */
  94592. keysLeft: number[];
  94593. private _keys;
  94594. private _onCanvasBlurObserver;
  94595. private _onKeyboardObserver;
  94596. private _engine;
  94597. private _scene;
  94598. /**
  94599. * Attach the input controls to a specific dom element to get the input from.
  94600. * @param element Defines the element the controls should be listened from
  94601. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94602. */
  94603. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94604. /**
  94605. * Detach the current controls from the specified dom element.
  94606. * @param element Defines the element to stop listening the inputs from
  94607. */
  94608. detachControl(element: Nullable<HTMLElement>): void;
  94609. /**
  94610. * Gets the class name of the current intput.
  94611. * @returns the class name
  94612. */
  94613. getClassName(): string;
  94614. /** @hidden */
  94615. _onLostFocus(e: FocusEvent): void;
  94616. /**
  94617. * Get the friendly name associated with the input class.
  94618. * @returns the input friendly name
  94619. */
  94620. getSimpleName(): string;
  94621. /**
  94622. * Update the current camera state depending on the inputs that have been used this frame.
  94623. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94624. */
  94625. checkInputs(): void;
  94626. }
  94627. }
  94628. declare module BABYLON {
  94629. /**
  94630. * Manage the mouse wheel inputs to control a follow camera.
  94631. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94632. */
  94633. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  94634. /**
  94635. * Defines the camera the input is attached to.
  94636. */
  94637. camera: FollowCamera;
  94638. /**
  94639. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  94640. */
  94641. axisControlRadius: boolean;
  94642. /**
  94643. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  94644. */
  94645. axisControlHeight: boolean;
  94646. /**
  94647. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  94648. */
  94649. axisControlRotation: boolean;
  94650. /**
  94651. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  94652. * relation to mouseWheel events.
  94653. */
  94654. wheelPrecision: number;
  94655. /**
  94656. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  94657. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  94658. */
  94659. wheelDeltaPercentage: number;
  94660. private _wheel;
  94661. private _observer;
  94662. /**
  94663. * Attach the input controls to a specific dom element to get the input from.
  94664. * @param element Defines the element the controls should be listened from
  94665. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94666. */
  94667. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94668. /**
  94669. * Detach the current controls from the specified dom element.
  94670. * @param element Defines the element to stop listening the inputs from
  94671. */
  94672. detachControl(element: Nullable<HTMLElement>): void;
  94673. /**
  94674. * Gets the class name of the current intput.
  94675. * @returns the class name
  94676. */
  94677. getClassName(): string;
  94678. /**
  94679. * Get the friendly name associated with the input class.
  94680. * @returns the input friendly name
  94681. */
  94682. getSimpleName(): string;
  94683. }
  94684. }
  94685. declare module BABYLON {
  94686. /**
  94687. * Manage the pointers inputs to control an follow camera.
  94688. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94689. */
  94690. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  94691. /**
  94692. * Defines the camera the input is attached to.
  94693. */
  94694. camera: FollowCamera;
  94695. /**
  94696. * Gets the class name of the current input.
  94697. * @returns the class name
  94698. */
  94699. getClassName(): string;
  94700. /**
  94701. * Defines the pointer angular sensibility along the X axis or how fast is
  94702. * the camera rotating.
  94703. * A negative number will reverse the axis direction.
  94704. */
  94705. angularSensibilityX: number;
  94706. /**
  94707. * Defines the pointer angular sensibility along the Y axis or how fast is
  94708. * the camera rotating.
  94709. * A negative number will reverse the axis direction.
  94710. */
  94711. angularSensibilityY: number;
  94712. /**
  94713. * Defines the pointer pinch precision or how fast is the camera zooming.
  94714. * A negative number will reverse the axis direction.
  94715. */
  94716. pinchPrecision: number;
  94717. /**
  94718. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  94719. * from 0.
  94720. * It defines the percentage of current camera.radius to use as delta when
  94721. * pinch zoom is used.
  94722. */
  94723. pinchDeltaPercentage: number;
  94724. /**
  94725. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  94726. */
  94727. axisXControlRadius: boolean;
  94728. /**
  94729. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  94730. */
  94731. axisXControlHeight: boolean;
  94732. /**
  94733. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  94734. */
  94735. axisXControlRotation: boolean;
  94736. /**
  94737. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  94738. */
  94739. axisYControlRadius: boolean;
  94740. /**
  94741. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  94742. */
  94743. axisYControlHeight: boolean;
  94744. /**
  94745. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  94746. */
  94747. axisYControlRotation: boolean;
  94748. /**
  94749. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  94750. */
  94751. axisPinchControlRadius: boolean;
  94752. /**
  94753. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  94754. */
  94755. axisPinchControlHeight: boolean;
  94756. /**
  94757. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  94758. */
  94759. axisPinchControlRotation: boolean;
  94760. /**
  94761. * Log error messages if basic misconfiguration has occurred.
  94762. */
  94763. warningEnable: boolean;
  94764. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  94765. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  94766. private _warningCounter;
  94767. private _warning;
  94768. }
  94769. }
  94770. declare module BABYLON {
  94771. /**
  94772. * Default Inputs manager for the FollowCamera.
  94773. * It groups all the default supported inputs for ease of use.
  94774. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94775. */
  94776. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  94777. /**
  94778. * Instantiates a new FollowCameraInputsManager.
  94779. * @param camera Defines the camera the inputs belong to
  94780. */
  94781. constructor(camera: FollowCamera);
  94782. /**
  94783. * Add keyboard input support to the input manager.
  94784. * @returns the current input manager
  94785. */
  94786. addKeyboard(): FollowCameraInputsManager;
  94787. /**
  94788. * Add mouse wheel input support to the input manager.
  94789. * @returns the current input manager
  94790. */
  94791. addMouseWheel(): FollowCameraInputsManager;
  94792. /**
  94793. * Add pointers input support to the input manager.
  94794. * @returns the current input manager
  94795. */
  94796. addPointers(): FollowCameraInputsManager;
  94797. /**
  94798. * Add orientation input support to the input manager.
  94799. * @returns the current input manager
  94800. */
  94801. addVRDeviceOrientation(): FollowCameraInputsManager;
  94802. }
  94803. }
  94804. declare module BABYLON {
  94805. /**
  94806. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  94807. * an arc rotate version arcFollowCamera are available.
  94808. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  94809. */
  94810. export class FollowCamera extends TargetCamera {
  94811. /**
  94812. * Distance the follow camera should follow an object at
  94813. */
  94814. radius: number;
  94815. /**
  94816. * Minimum allowed distance of the camera to the axis of rotation
  94817. * (The camera can not get closer).
  94818. * This can help limiting how the Camera is able to move in the scene.
  94819. */
  94820. lowerRadiusLimit: Nullable<number>;
  94821. /**
  94822. * Maximum allowed distance of the camera to the axis of rotation
  94823. * (The camera can not get further).
  94824. * This can help limiting how the Camera is able to move in the scene.
  94825. */
  94826. upperRadiusLimit: Nullable<number>;
  94827. /**
  94828. * Define a rotation offset between the camera and the object it follows
  94829. */
  94830. rotationOffset: number;
  94831. /**
  94832. * Minimum allowed angle to camera position relative to target object.
  94833. * This can help limiting how the Camera is able to move in the scene.
  94834. */
  94835. lowerRotationOffsetLimit: Nullable<number>;
  94836. /**
  94837. * Maximum allowed angle to camera position relative to target object.
  94838. * This can help limiting how the Camera is able to move in the scene.
  94839. */
  94840. upperRotationOffsetLimit: Nullable<number>;
  94841. /**
  94842. * Define a height offset between the camera and the object it follows.
  94843. * It can help following an object from the top (like a car chaing a plane)
  94844. */
  94845. heightOffset: number;
  94846. /**
  94847. * Minimum allowed height of camera position relative to target object.
  94848. * This can help limiting how the Camera is able to move in the scene.
  94849. */
  94850. lowerHeightOffsetLimit: Nullable<number>;
  94851. /**
  94852. * Maximum allowed height of camera position relative to target object.
  94853. * This can help limiting how the Camera is able to move in the scene.
  94854. */
  94855. upperHeightOffsetLimit: Nullable<number>;
  94856. /**
  94857. * Define how fast the camera can accelerate to follow it s target.
  94858. */
  94859. cameraAcceleration: number;
  94860. /**
  94861. * Define the speed limit of the camera following an object.
  94862. */
  94863. maxCameraSpeed: number;
  94864. /**
  94865. * Define the target of the camera.
  94866. */
  94867. lockedTarget: Nullable<AbstractMesh>;
  94868. /**
  94869. * Defines the input associated with the camera.
  94870. */
  94871. inputs: FollowCameraInputsManager;
  94872. /**
  94873. * Instantiates the follow camera.
  94874. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  94875. * @param name Define the name of the camera in the scene
  94876. * @param position Define the position of the camera
  94877. * @param scene Define the scene the camera belong to
  94878. * @param lockedTarget Define the target of the camera
  94879. */
  94880. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  94881. private _follow;
  94882. /**
  94883. * Attached controls to the current camera.
  94884. * @param element Defines the element the controls should be listened from
  94885. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94886. */
  94887. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94888. /**
  94889. * Detach the current controls from the camera.
  94890. * The camera will stop reacting to inputs.
  94891. * @param element Defines the element to stop listening the inputs from
  94892. */
  94893. detachControl(element: HTMLElement): void;
  94894. /** @hidden */
  94895. _checkInputs(): void;
  94896. private _checkLimits;
  94897. /**
  94898. * Gets the camera class name.
  94899. * @returns the class name
  94900. */
  94901. getClassName(): string;
  94902. }
  94903. /**
  94904. * Arc Rotate version of the follow camera.
  94905. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  94906. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  94907. */
  94908. export class ArcFollowCamera extends TargetCamera {
  94909. /** The longitudinal angle of the camera */
  94910. alpha: number;
  94911. /** The latitudinal angle of the camera */
  94912. beta: number;
  94913. /** The radius of the camera from its target */
  94914. radius: number;
  94915. /** Define the camera target (the messh it should follow) */
  94916. target: Nullable<AbstractMesh>;
  94917. private _cartesianCoordinates;
  94918. /**
  94919. * Instantiates a new ArcFollowCamera
  94920. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  94921. * @param name Define the name of the camera
  94922. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  94923. * @param beta Define the rotation angle of the camera around the elevation axis
  94924. * @param radius Define the radius of the camera from its target point
  94925. * @param target Define the target of the camera
  94926. * @param scene Define the scene the camera belongs to
  94927. */
  94928. constructor(name: string,
  94929. /** The longitudinal angle of the camera */
  94930. alpha: number,
  94931. /** The latitudinal angle of the camera */
  94932. beta: number,
  94933. /** The radius of the camera from its target */
  94934. radius: number,
  94935. /** Define the camera target (the messh it should follow) */
  94936. target: Nullable<AbstractMesh>, scene: Scene);
  94937. private _follow;
  94938. /** @hidden */
  94939. _checkInputs(): void;
  94940. /**
  94941. * Returns the class name of the object.
  94942. * It is mostly used internally for serialization purposes.
  94943. */
  94944. getClassName(): string;
  94945. }
  94946. }
  94947. declare module BABYLON {
  94948. /**
  94949. * Manage the keyboard inputs to control the movement of a follow camera.
  94950. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94951. */
  94952. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  94953. /**
  94954. * Defines the camera the input is attached to.
  94955. */
  94956. camera: FollowCamera;
  94957. /**
  94958. * Defines the list of key codes associated with the up action (increase heightOffset)
  94959. */
  94960. keysHeightOffsetIncr: number[];
  94961. /**
  94962. * Defines the list of key codes associated with the down action (decrease heightOffset)
  94963. */
  94964. keysHeightOffsetDecr: number[];
  94965. /**
  94966. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  94967. */
  94968. keysHeightOffsetModifierAlt: boolean;
  94969. /**
  94970. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  94971. */
  94972. keysHeightOffsetModifierCtrl: boolean;
  94973. /**
  94974. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  94975. */
  94976. keysHeightOffsetModifierShift: boolean;
  94977. /**
  94978. * Defines the list of key codes associated with the left action (increase rotationOffset)
  94979. */
  94980. keysRotationOffsetIncr: number[];
  94981. /**
  94982. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  94983. */
  94984. keysRotationOffsetDecr: number[];
  94985. /**
  94986. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  94987. */
  94988. keysRotationOffsetModifierAlt: boolean;
  94989. /**
  94990. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  94991. */
  94992. keysRotationOffsetModifierCtrl: boolean;
  94993. /**
  94994. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  94995. */
  94996. keysRotationOffsetModifierShift: boolean;
  94997. /**
  94998. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  94999. */
  95000. keysRadiusIncr: number[];
  95001. /**
  95002. * Defines the list of key codes associated with the zoom-out action (increase radius)
  95003. */
  95004. keysRadiusDecr: number[];
  95005. /**
  95006. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  95007. */
  95008. keysRadiusModifierAlt: boolean;
  95009. /**
  95010. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  95011. */
  95012. keysRadiusModifierCtrl: boolean;
  95013. /**
  95014. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  95015. */
  95016. keysRadiusModifierShift: boolean;
  95017. /**
  95018. * Defines the rate of change of heightOffset.
  95019. */
  95020. heightSensibility: number;
  95021. /**
  95022. * Defines the rate of change of rotationOffset.
  95023. */
  95024. rotationSensibility: number;
  95025. /**
  95026. * Defines the rate of change of radius.
  95027. */
  95028. radiusSensibility: number;
  95029. private _keys;
  95030. private _ctrlPressed;
  95031. private _altPressed;
  95032. private _shiftPressed;
  95033. private _onCanvasBlurObserver;
  95034. private _onKeyboardObserver;
  95035. private _engine;
  95036. private _scene;
  95037. /**
  95038. * Attach the input controls to a specific dom element to get the input from.
  95039. * @param element Defines the element the controls should be listened from
  95040. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95041. */
  95042. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95043. /**
  95044. * Detach the current controls from the specified dom element.
  95045. * @param element Defines the element to stop listening the inputs from
  95046. */
  95047. detachControl(element: Nullable<HTMLElement>): void;
  95048. /**
  95049. * Update the current camera state depending on the inputs that have been used this frame.
  95050. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95051. */
  95052. checkInputs(): void;
  95053. /**
  95054. * Gets the class name of the current input.
  95055. * @returns the class name
  95056. */
  95057. getClassName(): string;
  95058. /**
  95059. * Get the friendly name associated with the input class.
  95060. * @returns the input friendly name
  95061. */
  95062. getSimpleName(): string;
  95063. /**
  95064. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  95065. * allow modification of the heightOffset value.
  95066. */
  95067. private _modifierHeightOffset;
  95068. /**
  95069. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  95070. * allow modification of the rotationOffset value.
  95071. */
  95072. private _modifierRotationOffset;
  95073. /**
  95074. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  95075. * allow modification of the radius value.
  95076. */
  95077. private _modifierRadius;
  95078. }
  95079. }
  95080. declare module BABYLON {
  95081. interface FreeCameraInputsManager {
  95082. /**
  95083. * Add orientation input support to the input manager.
  95084. * @returns the current input manager
  95085. */
  95086. addDeviceOrientation(): FreeCameraInputsManager;
  95087. }
  95088. /**
  95089. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  95090. * Screen rotation is taken into account.
  95091. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95092. */
  95093. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  95094. private _camera;
  95095. private _screenOrientationAngle;
  95096. private _constantTranform;
  95097. private _screenQuaternion;
  95098. private _alpha;
  95099. private _beta;
  95100. private _gamma;
  95101. /**
  95102. * Instantiates a new input
  95103. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95104. */
  95105. constructor();
  95106. /**
  95107. * Define the camera controlled by the input.
  95108. */
  95109. camera: FreeCamera;
  95110. /**
  95111. * Attach the input controls to a specific dom element to get the input from.
  95112. * @param element Defines the element the controls should be listened from
  95113. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95114. */
  95115. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95116. private _orientationChanged;
  95117. private _deviceOrientation;
  95118. /**
  95119. * Detach the current controls from the specified dom element.
  95120. * @param element Defines the element to stop listening the inputs from
  95121. */
  95122. detachControl(element: Nullable<HTMLElement>): void;
  95123. /**
  95124. * Update the current camera state depending on the inputs that have been used this frame.
  95125. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95126. */
  95127. checkInputs(): void;
  95128. /**
  95129. * Gets the class name of the current intput.
  95130. * @returns the class name
  95131. */
  95132. getClassName(): string;
  95133. /**
  95134. * Get the friendly name associated with the input class.
  95135. * @returns the input friendly name
  95136. */
  95137. getSimpleName(): string;
  95138. }
  95139. }
  95140. declare module BABYLON {
  95141. /**
  95142. * Manage the gamepad inputs to control a free camera.
  95143. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95144. */
  95145. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  95146. /**
  95147. * Define the camera the input is attached to.
  95148. */
  95149. camera: FreeCamera;
  95150. /**
  95151. * Define the Gamepad controlling the input
  95152. */
  95153. gamepad: Nullable<Gamepad>;
  95154. /**
  95155. * Defines the gamepad rotation sensiblity.
  95156. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  95157. */
  95158. gamepadAngularSensibility: number;
  95159. /**
  95160. * Defines the gamepad move sensiblity.
  95161. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  95162. */
  95163. gamepadMoveSensibility: number;
  95164. private _onGamepadConnectedObserver;
  95165. private _onGamepadDisconnectedObserver;
  95166. private _cameraTransform;
  95167. private _deltaTransform;
  95168. private _vector3;
  95169. private _vector2;
  95170. /**
  95171. * Attach the input controls to a specific dom element to get the input from.
  95172. * @param element Defines the element the controls should be listened from
  95173. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95174. */
  95175. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95176. /**
  95177. * Detach the current controls from the specified dom element.
  95178. * @param element Defines the element to stop listening the inputs from
  95179. */
  95180. detachControl(element: Nullable<HTMLElement>): void;
  95181. /**
  95182. * Update the current camera state depending on the inputs that have been used this frame.
  95183. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95184. */
  95185. checkInputs(): void;
  95186. /**
  95187. * Gets the class name of the current intput.
  95188. * @returns the class name
  95189. */
  95190. getClassName(): string;
  95191. /**
  95192. * Get the friendly name associated with the input class.
  95193. * @returns the input friendly name
  95194. */
  95195. getSimpleName(): string;
  95196. }
  95197. }
  95198. declare module BABYLON {
  95199. /**
  95200. * Defines the potential axis of a Joystick
  95201. */
  95202. export enum JoystickAxis {
  95203. /** X axis */
  95204. X = 0,
  95205. /** Y axis */
  95206. Y = 1,
  95207. /** Z axis */
  95208. Z = 2
  95209. }
  95210. /**
  95211. * Class used to define virtual joystick (used in touch mode)
  95212. */
  95213. export class VirtualJoystick {
  95214. /**
  95215. * Gets or sets a boolean indicating that left and right values must be inverted
  95216. */
  95217. reverseLeftRight: boolean;
  95218. /**
  95219. * Gets or sets a boolean indicating that up and down values must be inverted
  95220. */
  95221. reverseUpDown: boolean;
  95222. /**
  95223. * Gets the offset value for the position (ie. the change of the position value)
  95224. */
  95225. deltaPosition: Vector3;
  95226. /**
  95227. * Gets a boolean indicating if the virtual joystick was pressed
  95228. */
  95229. pressed: boolean;
  95230. /**
  95231. * Canvas the virtual joystick will render onto, default z-index of this is 5
  95232. */
  95233. static Canvas: Nullable<HTMLCanvasElement>;
  95234. private static _globalJoystickIndex;
  95235. private static vjCanvasContext;
  95236. private static vjCanvasWidth;
  95237. private static vjCanvasHeight;
  95238. private static halfWidth;
  95239. private _action;
  95240. private _axisTargetedByLeftAndRight;
  95241. private _axisTargetedByUpAndDown;
  95242. private _joystickSensibility;
  95243. private _inversedSensibility;
  95244. private _joystickPointerID;
  95245. private _joystickColor;
  95246. private _joystickPointerPos;
  95247. private _joystickPreviousPointerPos;
  95248. private _joystickPointerStartPos;
  95249. private _deltaJoystickVector;
  95250. private _leftJoystick;
  95251. private _touches;
  95252. private _onPointerDownHandlerRef;
  95253. private _onPointerMoveHandlerRef;
  95254. private _onPointerUpHandlerRef;
  95255. private _onResize;
  95256. /**
  95257. * Creates a new virtual joystick
  95258. * @param leftJoystick defines that the joystick is for left hand (false by default)
  95259. */
  95260. constructor(leftJoystick?: boolean);
  95261. /**
  95262. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  95263. * @param newJoystickSensibility defines the new sensibility
  95264. */
  95265. setJoystickSensibility(newJoystickSensibility: number): void;
  95266. private _onPointerDown;
  95267. private _onPointerMove;
  95268. private _onPointerUp;
  95269. /**
  95270. * Change the color of the virtual joystick
  95271. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  95272. */
  95273. setJoystickColor(newColor: string): void;
  95274. /**
  95275. * Defines a callback to call when the joystick is touched
  95276. * @param action defines the callback
  95277. */
  95278. setActionOnTouch(action: () => any): void;
  95279. /**
  95280. * Defines which axis you'd like to control for left & right
  95281. * @param axis defines the axis to use
  95282. */
  95283. setAxisForLeftRight(axis: JoystickAxis): void;
  95284. /**
  95285. * Defines which axis you'd like to control for up & down
  95286. * @param axis defines the axis to use
  95287. */
  95288. setAxisForUpDown(axis: JoystickAxis): void;
  95289. private _drawVirtualJoystick;
  95290. /**
  95291. * Release internal HTML canvas
  95292. */
  95293. releaseCanvas(): void;
  95294. }
  95295. }
  95296. declare module BABYLON {
  95297. interface FreeCameraInputsManager {
  95298. /**
  95299. * Add virtual joystick input support to the input manager.
  95300. * @returns the current input manager
  95301. */
  95302. addVirtualJoystick(): FreeCameraInputsManager;
  95303. }
  95304. /**
  95305. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  95306. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95307. */
  95308. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  95309. /**
  95310. * Defines the camera the input is attached to.
  95311. */
  95312. camera: FreeCamera;
  95313. private _leftjoystick;
  95314. private _rightjoystick;
  95315. /**
  95316. * Gets the left stick of the virtual joystick.
  95317. * @returns The virtual Joystick
  95318. */
  95319. getLeftJoystick(): VirtualJoystick;
  95320. /**
  95321. * Gets the right stick of the virtual joystick.
  95322. * @returns The virtual Joystick
  95323. */
  95324. getRightJoystick(): VirtualJoystick;
  95325. /**
  95326. * Update the current camera state depending on the inputs that have been used this frame.
  95327. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95328. */
  95329. checkInputs(): void;
  95330. /**
  95331. * Attach the input controls to a specific dom element to get the input from.
  95332. * @param element Defines the element the controls should be listened from
  95333. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95334. */
  95335. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95336. /**
  95337. * Detach the current controls from the specified dom element.
  95338. * @param element Defines the element to stop listening the inputs from
  95339. */
  95340. detachControl(element: Nullable<HTMLElement>): void;
  95341. /**
  95342. * Gets the class name of the current intput.
  95343. * @returns the class name
  95344. */
  95345. getClassName(): string;
  95346. /**
  95347. * Get the friendly name associated with the input class.
  95348. * @returns the input friendly name
  95349. */
  95350. getSimpleName(): string;
  95351. }
  95352. }
  95353. declare module BABYLON {
  95354. /**
  95355. * This represents a FPS type of camera controlled by touch.
  95356. * This is like a universal camera minus the Gamepad controls.
  95357. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95358. */
  95359. export class TouchCamera extends FreeCamera {
  95360. /**
  95361. * Defines the touch sensibility for rotation.
  95362. * The higher the faster.
  95363. */
  95364. touchAngularSensibility: number;
  95365. /**
  95366. * Defines the touch sensibility for move.
  95367. * The higher the faster.
  95368. */
  95369. touchMoveSensibility: number;
  95370. /**
  95371. * Instantiates a new touch camera.
  95372. * This represents a FPS type of camera controlled by touch.
  95373. * This is like a universal camera minus the Gamepad controls.
  95374. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95375. * @param name Define the name of the camera in the scene
  95376. * @param position Define the start position of the camera in the scene
  95377. * @param scene Define the scene the camera belongs to
  95378. */
  95379. constructor(name: string, position: Vector3, scene: Scene);
  95380. /**
  95381. * Gets the current object class name.
  95382. * @return the class name
  95383. */
  95384. getClassName(): string;
  95385. /** @hidden */
  95386. _setupInputs(): void;
  95387. }
  95388. }
  95389. declare module BABYLON {
  95390. /**
  95391. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  95392. * being tilted forward or back and left or right.
  95393. */
  95394. export class DeviceOrientationCamera extends FreeCamera {
  95395. private _initialQuaternion;
  95396. private _quaternionCache;
  95397. /**
  95398. * Creates a new device orientation camera
  95399. * @param name The name of the camera
  95400. * @param position The start position camera
  95401. * @param scene The scene the camera belongs to
  95402. */
  95403. constructor(name: string, position: Vector3, scene: Scene);
  95404. /**
  95405. * Gets the current instance class name ("DeviceOrientationCamera").
  95406. * This helps avoiding instanceof at run time.
  95407. * @returns the class name
  95408. */
  95409. getClassName(): string;
  95410. /**
  95411. * @hidden
  95412. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  95413. */
  95414. _checkInputs(): void;
  95415. /**
  95416. * Reset the camera to its default orientation on the specified axis only.
  95417. * @param axis The axis to reset
  95418. */
  95419. resetToCurrentRotation(axis?: Axis): void;
  95420. }
  95421. }
  95422. declare module BABYLON {
  95423. /**
  95424. * 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,
  95425. * which still works and will still be found in many Playgrounds.
  95426. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95427. */
  95428. export class UniversalCamera extends TouchCamera {
  95429. /**
  95430. * Defines the gamepad rotation sensiblity.
  95431. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  95432. */
  95433. gamepadAngularSensibility: number;
  95434. /**
  95435. * Defines the gamepad move sensiblity.
  95436. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  95437. */
  95438. gamepadMoveSensibility: number;
  95439. /**
  95440. * 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,
  95441. * which still works and will still be found in many Playgrounds.
  95442. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95443. * @param name Define the name of the camera in the scene
  95444. * @param position Define the start position of the camera in the scene
  95445. * @param scene Define the scene the camera belongs to
  95446. */
  95447. constructor(name: string, position: Vector3, scene: Scene);
  95448. /**
  95449. * Gets the current object class name.
  95450. * @return the class name
  95451. */
  95452. getClassName(): string;
  95453. }
  95454. }
  95455. declare module BABYLON {
  95456. /**
  95457. * This represents a FPS type of camera. This is only here for back compat purpose.
  95458. * Please use the UniversalCamera instead as both are identical.
  95459. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95460. */
  95461. export class GamepadCamera extends UniversalCamera {
  95462. /**
  95463. * Instantiates a new Gamepad Camera
  95464. * This represents a FPS type of camera. This is only here for back compat purpose.
  95465. * Please use the UniversalCamera instead as both are identical.
  95466. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95467. * @param name Define the name of the camera in the scene
  95468. * @param position Define the start position of the camera in the scene
  95469. * @param scene Define the scene the camera belongs to
  95470. */
  95471. constructor(name: string, position: Vector3, scene: Scene);
  95472. /**
  95473. * Gets the current object class name.
  95474. * @return the class name
  95475. */
  95476. getClassName(): string;
  95477. }
  95478. }
  95479. declare module BABYLON {
  95480. /** @hidden */
  95481. export var passPixelShader: {
  95482. name: string;
  95483. shader: string;
  95484. };
  95485. }
  95486. declare module BABYLON {
  95487. /** @hidden */
  95488. export var passCubePixelShader: {
  95489. name: string;
  95490. shader: string;
  95491. };
  95492. }
  95493. declare module BABYLON {
  95494. /**
  95495. * PassPostProcess which produces an output the same as it's input
  95496. */
  95497. export class PassPostProcess extends PostProcess {
  95498. /**
  95499. * Creates the PassPostProcess
  95500. * @param name The name of the effect.
  95501. * @param options The required width/height ratio to downsize to before computing the render pass.
  95502. * @param camera The camera to apply the render pass to.
  95503. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  95504. * @param engine The engine which the post process will be applied. (default: current engine)
  95505. * @param reusable If the post process can be reused on the same frame. (default: false)
  95506. * @param textureType The type of texture to be used when performing the post processing.
  95507. * @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)
  95508. */
  95509. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  95510. }
  95511. /**
  95512. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  95513. */
  95514. export class PassCubePostProcess extends PostProcess {
  95515. private _face;
  95516. /**
  95517. * Gets or sets the cube face to display.
  95518. * * 0 is +X
  95519. * * 1 is -X
  95520. * * 2 is +Y
  95521. * * 3 is -Y
  95522. * * 4 is +Z
  95523. * * 5 is -Z
  95524. */
  95525. face: number;
  95526. /**
  95527. * Creates the PassCubePostProcess
  95528. * @param name The name of the effect.
  95529. * @param options The required width/height ratio to downsize to before computing the render pass.
  95530. * @param camera The camera to apply the render pass to.
  95531. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  95532. * @param engine The engine which the post process will be applied. (default: current engine)
  95533. * @param reusable If the post process can be reused on the same frame. (default: false)
  95534. * @param textureType The type of texture to be used when performing the post processing.
  95535. * @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)
  95536. */
  95537. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  95538. }
  95539. }
  95540. declare module BABYLON {
  95541. /** @hidden */
  95542. export var anaglyphPixelShader: {
  95543. name: string;
  95544. shader: string;
  95545. };
  95546. }
  95547. declare module BABYLON {
  95548. /**
  95549. * Postprocess used to generate anaglyphic rendering
  95550. */
  95551. export class AnaglyphPostProcess extends PostProcess {
  95552. private _passedProcess;
  95553. /**
  95554. * Creates a new AnaglyphPostProcess
  95555. * @param name defines postprocess name
  95556. * @param options defines creation options or target ratio scale
  95557. * @param rigCameras defines cameras using this postprocess
  95558. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  95559. * @param engine defines hosting engine
  95560. * @param reusable defines if the postprocess will be reused multiple times per frame
  95561. */
  95562. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  95563. }
  95564. }
  95565. declare module BABYLON {
  95566. /**
  95567. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  95568. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  95569. */
  95570. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  95571. /**
  95572. * Creates a new AnaglyphArcRotateCamera
  95573. * @param name defines camera name
  95574. * @param alpha defines alpha angle (in radians)
  95575. * @param beta defines beta angle (in radians)
  95576. * @param radius defines radius
  95577. * @param target defines camera target
  95578. * @param interaxialDistance defines distance between each color axis
  95579. * @param scene defines the hosting scene
  95580. */
  95581. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  95582. /**
  95583. * Gets camera class name
  95584. * @returns AnaglyphArcRotateCamera
  95585. */
  95586. getClassName(): string;
  95587. }
  95588. }
  95589. declare module BABYLON {
  95590. /**
  95591. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  95592. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  95593. */
  95594. export class AnaglyphFreeCamera extends FreeCamera {
  95595. /**
  95596. * Creates a new AnaglyphFreeCamera
  95597. * @param name defines camera name
  95598. * @param position defines initial position
  95599. * @param interaxialDistance defines distance between each color axis
  95600. * @param scene defines the hosting scene
  95601. */
  95602. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  95603. /**
  95604. * Gets camera class name
  95605. * @returns AnaglyphFreeCamera
  95606. */
  95607. getClassName(): string;
  95608. }
  95609. }
  95610. declare module BABYLON {
  95611. /**
  95612. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  95613. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  95614. */
  95615. export class AnaglyphGamepadCamera extends GamepadCamera {
  95616. /**
  95617. * Creates a new AnaglyphGamepadCamera
  95618. * @param name defines camera name
  95619. * @param position defines initial position
  95620. * @param interaxialDistance defines distance between each color axis
  95621. * @param scene defines the hosting scene
  95622. */
  95623. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  95624. /**
  95625. * Gets camera class name
  95626. * @returns AnaglyphGamepadCamera
  95627. */
  95628. getClassName(): string;
  95629. }
  95630. }
  95631. declare module BABYLON {
  95632. /**
  95633. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  95634. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  95635. */
  95636. export class AnaglyphUniversalCamera extends UniversalCamera {
  95637. /**
  95638. * Creates a new AnaglyphUniversalCamera
  95639. * @param name defines camera name
  95640. * @param position defines initial position
  95641. * @param interaxialDistance defines distance between each color axis
  95642. * @param scene defines the hosting scene
  95643. */
  95644. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  95645. /**
  95646. * Gets camera class name
  95647. * @returns AnaglyphUniversalCamera
  95648. */
  95649. getClassName(): string;
  95650. }
  95651. }
  95652. declare module BABYLON {
  95653. /** @hidden */
  95654. export var stereoscopicInterlacePixelShader: {
  95655. name: string;
  95656. shader: string;
  95657. };
  95658. }
  95659. declare module BABYLON {
  95660. /**
  95661. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  95662. */
  95663. export class StereoscopicInterlacePostProcess extends PostProcess {
  95664. private _stepSize;
  95665. private _passedProcess;
  95666. /**
  95667. * Initializes a StereoscopicInterlacePostProcess
  95668. * @param name The name of the effect.
  95669. * @param rigCameras The rig cameras to be appled to the post process
  95670. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  95671. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  95672. * @param engine The engine which the post process will be applied. (default: current engine)
  95673. * @param reusable If the post process can be reused on the same frame. (default: false)
  95674. */
  95675. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  95676. }
  95677. }
  95678. declare module BABYLON {
  95679. /**
  95680. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  95681. * @see http://doc.babylonjs.com/features/cameras
  95682. */
  95683. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  95684. /**
  95685. * Creates a new StereoscopicArcRotateCamera
  95686. * @param name defines camera name
  95687. * @param alpha defines alpha angle (in radians)
  95688. * @param beta defines beta angle (in radians)
  95689. * @param radius defines radius
  95690. * @param target defines camera target
  95691. * @param interaxialDistance defines distance between each color axis
  95692. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  95693. * @param scene defines the hosting scene
  95694. */
  95695. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  95696. /**
  95697. * Gets camera class name
  95698. * @returns StereoscopicArcRotateCamera
  95699. */
  95700. getClassName(): string;
  95701. }
  95702. }
  95703. declare module BABYLON {
  95704. /**
  95705. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  95706. * @see http://doc.babylonjs.com/features/cameras
  95707. */
  95708. export class StereoscopicFreeCamera extends FreeCamera {
  95709. /**
  95710. * Creates a new StereoscopicFreeCamera
  95711. * @param name defines camera name
  95712. * @param position defines initial position
  95713. * @param interaxialDistance defines distance between each color axis
  95714. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  95715. * @param scene defines the hosting scene
  95716. */
  95717. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  95718. /**
  95719. * Gets camera class name
  95720. * @returns StereoscopicFreeCamera
  95721. */
  95722. getClassName(): string;
  95723. }
  95724. }
  95725. declare module BABYLON {
  95726. /**
  95727. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  95728. * @see http://doc.babylonjs.com/features/cameras
  95729. */
  95730. export class StereoscopicGamepadCamera extends GamepadCamera {
  95731. /**
  95732. * Creates a new StereoscopicGamepadCamera
  95733. * @param name defines camera name
  95734. * @param position defines initial position
  95735. * @param interaxialDistance defines distance between each color axis
  95736. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  95737. * @param scene defines the hosting scene
  95738. */
  95739. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  95740. /**
  95741. * Gets camera class name
  95742. * @returns StereoscopicGamepadCamera
  95743. */
  95744. getClassName(): string;
  95745. }
  95746. }
  95747. declare module BABYLON {
  95748. /**
  95749. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  95750. * @see http://doc.babylonjs.com/features/cameras
  95751. */
  95752. export class StereoscopicUniversalCamera extends UniversalCamera {
  95753. /**
  95754. * Creates a new StereoscopicUniversalCamera
  95755. * @param name defines camera name
  95756. * @param position defines initial position
  95757. * @param interaxialDistance defines distance between each color axis
  95758. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  95759. * @param scene defines the hosting scene
  95760. */
  95761. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  95762. /**
  95763. * Gets camera class name
  95764. * @returns StereoscopicUniversalCamera
  95765. */
  95766. getClassName(): string;
  95767. }
  95768. }
  95769. declare module BABYLON {
  95770. /**
  95771. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  95772. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  95773. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  95774. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  95775. */
  95776. export class VirtualJoysticksCamera extends FreeCamera {
  95777. /**
  95778. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  95779. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  95780. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  95781. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  95782. * @param name Define the name of the camera in the scene
  95783. * @param position Define the start position of the camera in the scene
  95784. * @param scene Define the scene the camera belongs to
  95785. */
  95786. constructor(name: string, position: Vector3, scene: Scene);
  95787. /**
  95788. * Gets the current object class name.
  95789. * @return the class name
  95790. */
  95791. getClassName(): string;
  95792. }
  95793. }
  95794. declare module BABYLON {
  95795. /**
  95796. * This represents all the required metrics to create a VR camera.
  95797. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  95798. */
  95799. export class VRCameraMetrics {
  95800. /**
  95801. * Define the horizontal resolution off the screen.
  95802. */
  95803. hResolution: number;
  95804. /**
  95805. * Define the vertical resolution off the screen.
  95806. */
  95807. vResolution: number;
  95808. /**
  95809. * Define the horizontal screen size.
  95810. */
  95811. hScreenSize: number;
  95812. /**
  95813. * Define the vertical screen size.
  95814. */
  95815. vScreenSize: number;
  95816. /**
  95817. * Define the vertical screen center position.
  95818. */
  95819. vScreenCenter: number;
  95820. /**
  95821. * Define the distance of the eyes to the screen.
  95822. */
  95823. eyeToScreenDistance: number;
  95824. /**
  95825. * Define the distance between both lenses
  95826. */
  95827. lensSeparationDistance: number;
  95828. /**
  95829. * Define the distance between both viewer's eyes.
  95830. */
  95831. interpupillaryDistance: number;
  95832. /**
  95833. * Define the distortion factor of the VR postprocess.
  95834. * Please, touch with care.
  95835. */
  95836. distortionK: number[];
  95837. /**
  95838. * Define the chromatic aberration correction factors for the VR post process.
  95839. */
  95840. chromaAbCorrection: number[];
  95841. /**
  95842. * Define the scale factor of the post process.
  95843. * The smaller the better but the slower.
  95844. */
  95845. postProcessScaleFactor: number;
  95846. /**
  95847. * Define an offset for the lens center.
  95848. */
  95849. lensCenterOffset: number;
  95850. /**
  95851. * Define if the current vr camera should compensate the distortion of the lense or not.
  95852. */
  95853. compensateDistortion: boolean;
  95854. /**
  95855. * Gets the rendering aspect ratio based on the provided resolutions.
  95856. */
  95857. readonly aspectRatio: number;
  95858. /**
  95859. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  95860. */
  95861. readonly aspectRatioFov: number;
  95862. /**
  95863. * @hidden
  95864. */
  95865. readonly leftHMatrix: Matrix;
  95866. /**
  95867. * @hidden
  95868. */
  95869. readonly rightHMatrix: Matrix;
  95870. /**
  95871. * @hidden
  95872. */
  95873. readonly leftPreViewMatrix: Matrix;
  95874. /**
  95875. * @hidden
  95876. */
  95877. readonly rightPreViewMatrix: Matrix;
  95878. /**
  95879. * Get the default VRMetrics based on the most generic setup.
  95880. * @returns the default vr metrics
  95881. */
  95882. static GetDefault(): VRCameraMetrics;
  95883. }
  95884. }
  95885. declare module BABYLON {
  95886. /** @hidden */
  95887. export var vrDistortionCorrectionPixelShader: {
  95888. name: string;
  95889. shader: string;
  95890. };
  95891. }
  95892. declare module BABYLON {
  95893. /**
  95894. * VRDistortionCorrectionPostProcess used for mobile VR
  95895. */
  95896. export class VRDistortionCorrectionPostProcess extends PostProcess {
  95897. private _isRightEye;
  95898. private _distortionFactors;
  95899. private _postProcessScaleFactor;
  95900. private _lensCenterOffset;
  95901. private _scaleIn;
  95902. private _scaleFactor;
  95903. private _lensCenter;
  95904. /**
  95905. * Initializes the VRDistortionCorrectionPostProcess
  95906. * @param name The name of the effect.
  95907. * @param camera The camera to apply the render pass to.
  95908. * @param isRightEye If this is for the right eye distortion
  95909. * @param vrMetrics All the required metrics for the VR camera
  95910. */
  95911. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  95912. }
  95913. }
  95914. declare module BABYLON {
  95915. /**
  95916. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  95917. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  95918. */
  95919. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  95920. /**
  95921. * Creates a new VRDeviceOrientationArcRotateCamera
  95922. * @param name defines camera name
  95923. * @param alpha defines the camera rotation along the logitudinal axis
  95924. * @param beta defines the camera rotation along the latitudinal axis
  95925. * @param radius defines the camera distance from its target
  95926. * @param target defines the camera target
  95927. * @param scene defines the scene the camera belongs to
  95928. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  95929. * @param vrCameraMetrics defines the vr metrics associated to the camera
  95930. */
  95931. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  95932. /**
  95933. * Gets camera class name
  95934. * @returns VRDeviceOrientationArcRotateCamera
  95935. */
  95936. getClassName(): string;
  95937. }
  95938. }
  95939. declare module BABYLON {
  95940. /**
  95941. * Camera used to simulate VR rendering (based on FreeCamera)
  95942. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  95943. */
  95944. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  95945. /**
  95946. * Creates a new VRDeviceOrientationFreeCamera
  95947. * @param name defines camera name
  95948. * @param position defines the start position of the camera
  95949. * @param scene defines the scene the camera belongs to
  95950. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  95951. * @param vrCameraMetrics defines the vr metrics associated to the camera
  95952. */
  95953. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  95954. /**
  95955. * Gets camera class name
  95956. * @returns VRDeviceOrientationFreeCamera
  95957. */
  95958. getClassName(): string;
  95959. }
  95960. }
  95961. declare module BABYLON {
  95962. /**
  95963. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  95964. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  95965. */
  95966. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  95967. /**
  95968. * Creates a new VRDeviceOrientationGamepadCamera
  95969. * @param name defines camera name
  95970. * @param position defines the start position of the camera
  95971. * @param scene defines the scene the camera belongs to
  95972. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  95973. * @param vrCameraMetrics defines the vr metrics associated to the camera
  95974. */
  95975. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  95976. /**
  95977. * Gets camera class name
  95978. * @returns VRDeviceOrientationGamepadCamera
  95979. */
  95980. getClassName(): string;
  95981. }
  95982. }
  95983. declare module BABYLON {
  95984. /**
  95985. * Defines supported buttons for XBox360 compatible gamepads
  95986. */
  95987. export enum Xbox360Button {
  95988. /** A */
  95989. A = 0,
  95990. /** B */
  95991. B = 1,
  95992. /** X */
  95993. X = 2,
  95994. /** Y */
  95995. Y = 3,
  95996. /** Start */
  95997. Start = 4,
  95998. /** Back */
  95999. Back = 5,
  96000. /** Left button */
  96001. LB = 6,
  96002. /** Right button */
  96003. RB = 7,
  96004. /** Left stick */
  96005. LeftStick = 8,
  96006. /** Right stick */
  96007. RightStick = 9
  96008. }
  96009. /** Defines values for XBox360 DPad */
  96010. export enum Xbox360Dpad {
  96011. /** Up */
  96012. Up = 0,
  96013. /** Down */
  96014. Down = 1,
  96015. /** Left */
  96016. Left = 2,
  96017. /** Right */
  96018. Right = 3
  96019. }
  96020. /**
  96021. * Defines a XBox360 gamepad
  96022. */
  96023. export class Xbox360Pad extends Gamepad {
  96024. private _leftTrigger;
  96025. private _rightTrigger;
  96026. private _onlefttriggerchanged;
  96027. private _onrighttriggerchanged;
  96028. private _onbuttondown;
  96029. private _onbuttonup;
  96030. private _ondpaddown;
  96031. private _ondpadup;
  96032. /** Observable raised when a button is pressed */
  96033. onButtonDownObservable: Observable<Xbox360Button>;
  96034. /** Observable raised when a button is released */
  96035. onButtonUpObservable: Observable<Xbox360Button>;
  96036. /** Observable raised when a pad is pressed */
  96037. onPadDownObservable: Observable<Xbox360Dpad>;
  96038. /** Observable raised when a pad is released */
  96039. onPadUpObservable: Observable<Xbox360Dpad>;
  96040. private _buttonA;
  96041. private _buttonB;
  96042. private _buttonX;
  96043. private _buttonY;
  96044. private _buttonBack;
  96045. private _buttonStart;
  96046. private _buttonLB;
  96047. private _buttonRB;
  96048. private _buttonLeftStick;
  96049. private _buttonRightStick;
  96050. private _dPadUp;
  96051. private _dPadDown;
  96052. private _dPadLeft;
  96053. private _dPadRight;
  96054. private _isXboxOnePad;
  96055. /**
  96056. * Creates a new XBox360 gamepad object
  96057. * @param id defines the id of this gamepad
  96058. * @param index defines its index
  96059. * @param gamepad defines the internal HTML gamepad object
  96060. * @param xboxOne defines if it is a XBox One gamepad
  96061. */
  96062. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  96063. /**
  96064. * Defines the callback to call when left trigger is pressed
  96065. * @param callback defines the callback to use
  96066. */
  96067. onlefttriggerchanged(callback: (value: number) => void): void;
  96068. /**
  96069. * Defines the callback to call when right trigger is pressed
  96070. * @param callback defines the callback to use
  96071. */
  96072. onrighttriggerchanged(callback: (value: number) => void): void;
  96073. /**
  96074. * Gets the left trigger value
  96075. */
  96076. /**
  96077. * Sets the left trigger value
  96078. */
  96079. leftTrigger: number;
  96080. /**
  96081. * Gets the right trigger value
  96082. */
  96083. /**
  96084. * Sets the right trigger value
  96085. */
  96086. rightTrigger: number;
  96087. /**
  96088. * Defines the callback to call when a button is pressed
  96089. * @param callback defines the callback to use
  96090. */
  96091. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  96092. /**
  96093. * Defines the callback to call when a button is released
  96094. * @param callback defines the callback to use
  96095. */
  96096. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  96097. /**
  96098. * Defines the callback to call when a pad is pressed
  96099. * @param callback defines the callback to use
  96100. */
  96101. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  96102. /**
  96103. * Defines the callback to call when a pad is released
  96104. * @param callback defines the callback to use
  96105. */
  96106. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  96107. private _setButtonValue;
  96108. private _setDPadValue;
  96109. /**
  96110. * Gets the value of the `A` button
  96111. */
  96112. /**
  96113. * Sets the value of the `A` button
  96114. */
  96115. buttonA: number;
  96116. /**
  96117. * Gets the value of the `B` button
  96118. */
  96119. /**
  96120. * Sets the value of the `B` button
  96121. */
  96122. buttonB: number;
  96123. /**
  96124. * Gets the value of the `X` button
  96125. */
  96126. /**
  96127. * Sets the value of the `X` button
  96128. */
  96129. buttonX: number;
  96130. /**
  96131. * Gets the value of the `Y` button
  96132. */
  96133. /**
  96134. * Sets the value of the `Y` button
  96135. */
  96136. buttonY: number;
  96137. /**
  96138. * Gets the value of the `Start` button
  96139. */
  96140. /**
  96141. * Sets the value of the `Start` button
  96142. */
  96143. buttonStart: number;
  96144. /**
  96145. * Gets the value of the `Back` button
  96146. */
  96147. /**
  96148. * Sets the value of the `Back` button
  96149. */
  96150. buttonBack: number;
  96151. /**
  96152. * Gets the value of the `Left` button
  96153. */
  96154. /**
  96155. * Sets the value of the `Left` button
  96156. */
  96157. buttonLB: number;
  96158. /**
  96159. * Gets the value of the `Right` button
  96160. */
  96161. /**
  96162. * Sets the value of the `Right` button
  96163. */
  96164. buttonRB: number;
  96165. /**
  96166. * Gets the value of the Left joystick
  96167. */
  96168. /**
  96169. * Sets the value of the Left joystick
  96170. */
  96171. buttonLeftStick: number;
  96172. /**
  96173. * Gets the value of the Right joystick
  96174. */
  96175. /**
  96176. * Sets the value of the Right joystick
  96177. */
  96178. buttonRightStick: number;
  96179. /**
  96180. * Gets the value of D-pad up
  96181. */
  96182. /**
  96183. * Sets the value of D-pad up
  96184. */
  96185. dPadUp: number;
  96186. /**
  96187. * Gets the value of D-pad down
  96188. */
  96189. /**
  96190. * Sets the value of D-pad down
  96191. */
  96192. dPadDown: number;
  96193. /**
  96194. * Gets the value of D-pad left
  96195. */
  96196. /**
  96197. * Sets the value of D-pad left
  96198. */
  96199. dPadLeft: number;
  96200. /**
  96201. * Gets the value of D-pad right
  96202. */
  96203. /**
  96204. * Sets the value of D-pad right
  96205. */
  96206. dPadRight: number;
  96207. /**
  96208. * Force the gamepad to synchronize with device values
  96209. */
  96210. update(): void;
  96211. /**
  96212. * Disposes the gamepad
  96213. */
  96214. dispose(): void;
  96215. }
  96216. }
  96217. declare module BABYLON {
  96218. /**
  96219. * Base class of materials working in push mode in babylon JS
  96220. * @hidden
  96221. */
  96222. export class PushMaterial extends Material {
  96223. protected _activeEffect: Effect;
  96224. protected _normalMatrix: Matrix;
  96225. /**
  96226. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  96227. * This means that the material can keep using a previous shader while a new one is being compiled.
  96228. * This is mostly used when shader parallel compilation is supported (true by default)
  96229. */
  96230. allowShaderHotSwapping: boolean;
  96231. constructor(name: string, scene: Scene);
  96232. getEffect(): Effect;
  96233. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  96234. /**
  96235. * Binds the given world matrix to the active effect
  96236. *
  96237. * @param world the matrix to bind
  96238. */
  96239. bindOnlyWorldMatrix(world: Matrix): void;
  96240. /**
  96241. * Binds the given normal matrix to the active effect
  96242. *
  96243. * @param normalMatrix the matrix to bind
  96244. */
  96245. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  96246. bind(world: Matrix, mesh?: Mesh): void;
  96247. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  96248. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  96249. }
  96250. }
  96251. declare module BABYLON {
  96252. /**
  96253. * This groups all the flags used to control the materials channel.
  96254. */
  96255. export class MaterialFlags {
  96256. private static _DiffuseTextureEnabled;
  96257. /**
  96258. * Are diffuse textures enabled in the application.
  96259. */
  96260. static DiffuseTextureEnabled: boolean;
  96261. private static _AmbientTextureEnabled;
  96262. /**
  96263. * Are ambient textures enabled in the application.
  96264. */
  96265. static AmbientTextureEnabled: boolean;
  96266. private static _OpacityTextureEnabled;
  96267. /**
  96268. * Are opacity textures enabled in the application.
  96269. */
  96270. static OpacityTextureEnabled: boolean;
  96271. private static _ReflectionTextureEnabled;
  96272. /**
  96273. * Are reflection textures enabled in the application.
  96274. */
  96275. static ReflectionTextureEnabled: boolean;
  96276. private static _EmissiveTextureEnabled;
  96277. /**
  96278. * Are emissive textures enabled in the application.
  96279. */
  96280. static EmissiveTextureEnabled: boolean;
  96281. private static _SpecularTextureEnabled;
  96282. /**
  96283. * Are specular textures enabled in the application.
  96284. */
  96285. static SpecularTextureEnabled: boolean;
  96286. private static _BumpTextureEnabled;
  96287. /**
  96288. * Are bump textures enabled in the application.
  96289. */
  96290. static BumpTextureEnabled: boolean;
  96291. private static _LightmapTextureEnabled;
  96292. /**
  96293. * Are lightmap textures enabled in the application.
  96294. */
  96295. static LightmapTextureEnabled: boolean;
  96296. private static _RefractionTextureEnabled;
  96297. /**
  96298. * Are refraction textures enabled in the application.
  96299. */
  96300. static RefractionTextureEnabled: boolean;
  96301. private static _ColorGradingTextureEnabled;
  96302. /**
  96303. * Are color grading textures enabled in the application.
  96304. */
  96305. static ColorGradingTextureEnabled: boolean;
  96306. private static _FresnelEnabled;
  96307. /**
  96308. * Are fresnels enabled in the application.
  96309. */
  96310. static FresnelEnabled: boolean;
  96311. private static _ClearCoatTextureEnabled;
  96312. /**
  96313. * Are clear coat textures enabled in the application.
  96314. */
  96315. static ClearCoatTextureEnabled: boolean;
  96316. private static _ClearCoatBumpTextureEnabled;
  96317. /**
  96318. * Are clear coat bump textures enabled in the application.
  96319. */
  96320. static ClearCoatBumpTextureEnabled: boolean;
  96321. private static _ClearCoatTintTextureEnabled;
  96322. /**
  96323. * Are clear coat tint textures enabled in the application.
  96324. */
  96325. static ClearCoatTintTextureEnabled: boolean;
  96326. private static _SheenTextureEnabled;
  96327. /**
  96328. * Are sheen textures enabled in the application.
  96329. */
  96330. static SheenTextureEnabled: boolean;
  96331. private static _AnisotropicTextureEnabled;
  96332. /**
  96333. * Are anisotropic textures enabled in the application.
  96334. */
  96335. static AnisotropicTextureEnabled: boolean;
  96336. }
  96337. }
  96338. declare module BABYLON {
  96339. /** @hidden */
  96340. export var defaultFragmentDeclaration: {
  96341. name: string;
  96342. shader: string;
  96343. };
  96344. }
  96345. declare module BABYLON {
  96346. /** @hidden */
  96347. export var defaultUboDeclaration: {
  96348. name: string;
  96349. shader: string;
  96350. };
  96351. }
  96352. declare module BABYLON {
  96353. /** @hidden */
  96354. export var lightFragmentDeclaration: {
  96355. name: string;
  96356. shader: string;
  96357. };
  96358. }
  96359. declare module BABYLON {
  96360. /** @hidden */
  96361. export var lightUboDeclaration: {
  96362. name: string;
  96363. shader: string;
  96364. };
  96365. }
  96366. declare module BABYLON {
  96367. /** @hidden */
  96368. export var lightsFragmentFunctions: {
  96369. name: string;
  96370. shader: string;
  96371. };
  96372. }
  96373. declare module BABYLON {
  96374. /** @hidden */
  96375. export var shadowsFragmentFunctions: {
  96376. name: string;
  96377. shader: string;
  96378. };
  96379. }
  96380. declare module BABYLON {
  96381. /** @hidden */
  96382. export var fresnelFunction: {
  96383. name: string;
  96384. shader: string;
  96385. };
  96386. }
  96387. declare module BABYLON {
  96388. /** @hidden */
  96389. export var reflectionFunction: {
  96390. name: string;
  96391. shader: string;
  96392. };
  96393. }
  96394. declare module BABYLON {
  96395. /** @hidden */
  96396. export var bumpFragmentFunctions: {
  96397. name: string;
  96398. shader: string;
  96399. };
  96400. }
  96401. declare module BABYLON {
  96402. /** @hidden */
  96403. export var logDepthDeclaration: {
  96404. name: string;
  96405. shader: string;
  96406. };
  96407. }
  96408. declare module BABYLON {
  96409. /** @hidden */
  96410. export var bumpFragment: {
  96411. name: string;
  96412. shader: string;
  96413. };
  96414. }
  96415. declare module BABYLON {
  96416. /** @hidden */
  96417. export var depthPrePass: {
  96418. name: string;
  96419. shader: string;
  96420. };
  96421. }
  96422. declare module BABYLON {
  96423. /** @hidden */
  96424. export var lightFragment: {
  96425. name: string;
  96426. shader: string;
  96427. };
  96428. }
  96429. declare module BABYLON {
  96430. /** @hidden */
  96431. export var logDepthFragment: {
  96432. name: string;
  96433. shader: string;
  96434. };
  96435. }
  96436. declare module BABYLON {
  96437. /** @hidden */
  96438. export var defaultPixelShader: {
  96439. name: string;
  96440. shader: string;
  96441. };
  96442. }
  96443. declare module BABYLON {
  96444. /** @hidden */
  96445. export var defaultVertexDeclaration: {
  96446. name: string;
  96447. shader: string;
  96448. };
  96449. }
  96450. declare module BABYLON {
  96451. /** @hidden */
  96452. export var bumpVertexDeclaration: {
  96453. name: string;
  96454. shader: string;
  96455. };
  96456. }
  96457. declare module BABYLON {
  96458. /** @hidden */
  96459. export var bumpVertex: {
  96460. name: string;
  96461. shader: string;
  96462. };
  96463. }
  96464. declare module BABYLON {
  96465. /** @hidden */
  96466. export var fogVertex: {
  96467. name: string;
  96468. shader: string;
  96469. };
  96470. }
  96471. declare module BABYLON {
  96472. /** @hidden */
  96473. export var shadowsVertex: {
  96474. name: string;
  96475. shader: string;
  96476. };
  96477. }
  96478. declare module BABYLON {
  96479. /** @hidden */
  96480. export var pointCloudVertex: {
  96481. name: string;
  96482. shader: string;
  96483. };
  96484. }
  96485. declare module BABYLON {
  96486. /** @hidden */
  96487. export var logDepthVertex: {
  96488. name: string;
  96489. shader: string;
  96490. };
  96491. }
  96492. declare module BABYLON {
  96493. /** @hidden */
  96494. export var defaultVertexShader: {
  96495. name: string;
  96496. shader: string;
  96497. };
  96498. }
  96499. declare module BABYLON {
  96500. /** @hidden */
  96501. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  96502. MAINUV1: boolean;
  96503. MAINUV2: boolean;
  96504. DIFFUSE: boolean;
  96505. DIFFUSEDIRECTUV: number;
  96506. AMBIENT: boolean;
  96507. AMBIENTDIRECTUV: number;
  96508. OPACITY: boolean;
  96509. OPACITYDIRECTUV: number;
  96510. OPACITYRGB: boolean;
  96511. REFLECTION: boolean;
  96512. EMISSIVE: boolean;
  96513. EMISSIVEDIRECTUV: number;
  96514. SPECULAR: boolean;
  96515. SPECULARDIRECTUV: number;
  96516. BUMP: boolean;
  96517. BUMPDIRECTUV: number;
  96518. PARALLAX: boolean;
  96519. PARALLAXOCCLUSION: boolean;
  96520. SPECULAROVERALPHA: boolean;
  96521. CLIPPLANE: boolean;
  96522. CLIPPLANE2: boolean;
  96523. CLIPPLANE3: boolean;
  96524. CLIPPLANE4: boolean;
  96525. ALPHATEST: boolean;
  96526. DEPTHPREPASS: boolean;
  96527. ALPHAFROMDIFFUSE: boolean;
  96528. POINTSIZE: boolean;
  96529. FOG: boolean;
  96530. SPECULARTERM: boolean;
  96531. DIFFUSEFRESNEL: boolean;
  96532. OPACITYFRESNEL: boolean;
  96533. REFLECTIONFRESNEL: boolean;
  96534. REFRACTIONFRESNEL: boolean;
  96535. EMISSIVEFRESNEL: boolean;
  96536. FRESNEL: boolean;
  96537. NORMAL: boolean;
  96538. UV1: boolean;
  96539. UV2: boolean;
  96540. VERTEXCOLOR: boolean;
  96541. VERTEXALPHA: boolean;
  96542. NUM_BONE_INFLUENCERS: number;
  96543. BonesPerMesh: number;
  96544. BONETEXTURE: boolean;
  96545. INSTANCES: boolean;
  96546. GLOSSINESS: boolean;
  96547. ROUGHNESS: boolean;
  96548. EMISSIVEASILLUMINATION: boolean;
  96549. LINKEMISSIVEWITHDIFFUSE: boolean;
  96550. REFLECTIONFRESNELFROMSPECULAR: boolean;
  96551. LIGHTMAP: boolean;
  96552. LIGHTMAPDIRECTUV: number;
  96553. OBJECTSPACE_NORMALMAP: boolean;
  96554. USELIGHTMAPASSHADOWMAP: boolean;
  96555. REFLECTIONMAP_3D: boolean;
  96556. REFLECTIONMAP_SPHERICAL: boolean;
  96557. REFLECTIONMAP_PLANAR: boolean;
  96558. REFLECTIONMAP_CUBIC: boolean;
  96559. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  96560. REFLECTIONMAP_PROJECTION: boolean;
  96561. REFLECTIONMAP_SKYBOX: boolean;
  96562. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  96563. REFLECTIONMAP_EXPLICIT: boolean;
  96564. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  96565. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  96566. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  96567. INVERTCUBICMAP: boolean;
  96568. LOGARITHMICDEPTH: boolean;
  96569. REFRACTION: boolean;
  96570. REFRACTIONMAP_3D: boolean;
  96571. REFLECTIONOVERALPHA: boolean;
  96572. TWOSIDEDLIGHTING: boolean;
  96573. SHADOWFLOAT: boolean;
  96574. MORPHTARGETS: boolean;
  96575. MORPHTARGETS_NORMAL: boolean;
  96576. MORPHTARGETS_TANGENT: boolean;
  96577. NUM_MORPH_INFLUENCERS: number;
  96578. NONUNIFORMSCALING: boolean;
  96579. PREMULTIPLYALPHA: boolean;
  96580. IMAGEPROCESSING: boolean;
  96581. VIGNETTE: boolean;
  96582. VIGNETTEBLENDMODEMULTIPLY: boolean;
  96583. VIGNETTEBLENDMODEOPAQUE: boolean;
  96584. TONEMAPPING: boolean;
  96585. TONEMAPPING_ACES: boolean;
  96586. CONTRAST: boolean;
  96587. COLORCURVES: boolean;
  96588. COLORGRADING: boolean;
  96589. COLORGRADING3D: boolean;
  96590. SAMPLER3DGREENDEPTH: boolean;
  96591. SAMPLER3DBGRMAP: boolean;
  96592. IMAGEPROCESSINGPOSTPROCESS: boolean;
  96593. /**
  96594. * If the reflection texture on this material is in linear color space
  96595. * @hidden
  96596. */
  96597. IS_REFLECTION_LINEAR: boolean;
  96598. /**
  96599. * If the refraction texture on this material is in linear color space
  96600. * @hidden
  96601. */
  96602. IS_REFRACTION_LINEAR: boolean;
  96603. EXPOSURE: boolean;
  96604. constructor();
  96605. setReflectionMode(modeToEnable: string): void;
  96606. }
  96607. /**
  96608. * This is the default material used in Babylon. It is the best trade off between quality
  96609. * and performances.
  96610. * @see http://doc.babylonjs.com/babylon101/materials
  96611. */
  96612. export class StandardMaterial extends PushMaterial {
  96613. private _diffuseTexture;
  96614. /**
  96615. * The basic texture of the material as viewed under a light.
  96616. */
  96617. diffuseTexture: Nullable<BaseTexture>;
  96618. private _ambientTexture;
  96619. /**
  96620. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  96621. */
  96622. ambientTexture: Nullable<BaseTexture>;
  96623. private _opacityTexture;
  96624. /**
  96625. * Define the transparency of the material from a texture.
  96626. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  96627. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  96628. */
  96629. opacityTexture: Nullable<BaseTexture>;
  96630. private _reflectionTexture;
  96631. /**
  96632. * Define the texture used to display the reflection.
  96633. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96634. */
  96635. reflectionTexture: Nullable<BaseTexture>;
  96636. private _emissiveTexture;
  96637. /**
  96638. * Define texture of the material as if self lit.
  96639. * This will be mixed in the final result even in the absence of light.
  96640. */
  96641. emissiveTexture: Nullable<BaseTexture>;
  96642. private _specularTexture;
  96643. /**
  96644. * Define how the color and intensity of the highlight given by the light in the material.
  96645. */
  96646. specularTexture: Nullable<BaseTexture>;
  96647. private _bumpTexture;
  96648. /**
  96649. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  96650. * 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.
  96651. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  96652. */
  96653. bumpTexture: Nullable<BaseTexture>;
  96654. private _lightmapTexture;
  96655. /**
  96656. * Complex lighting can be computationally expensive to compute at runtime.
  96657. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  96658. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  96659. */
  96660. lightmapTexture: Nullable<BaseTexture>;
  96661. private _refractionTexture;
  96662. /**
  96663. * Define the texture used to display the refraction.
  96664. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96665. */
  96666. refractionTexture: Nullable<BaseTexture>;
  96667. /**
  96668. * The color of the material lit by the environmental background lighting.
  96669. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  96670. */
  96671. ambientColor: Color3;
  96672. /**
  96673. * The basic color of the material as viewed under a light.
  96674. */
  96675. diffuseColor: Color3;
  96676. /**
  96677. * Define how the color and intensity of the highlight given by the light in the material.
  96678. */
  96679. specularColor: Color3;
  96680. /**
  96681. * Define the color of the material as if self lit.
  96682. * This will be mixed in the final result even in the absence of light.
  96683. */
  96684. emissiveColor: Color3;
  96685. /**
  96686. * Defines how sharp are the highlights in the material.
  96687. * The bigger the value the sharper giving a more glossy feeling to the result.
  96688. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  96689. */
  96690. specularPower: number;
  96691. private _useAlphaFromDiffuseTexture;
  96692. /**
  96693. * Does the transparency come from the diffuse texture alpha channel.
  96694. */
  96695. useAlphaFromDiffuseTexture: boolean;
  96696. private _useEmissiveAsIllumination;
  96697. /**
  96698. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  96699. */
  96700. useEmissiveAsIllumination: boolean;
  96701. private _linkEmissiveWithDiffuse;
  96702. /**
  96703. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  96704. * the emissive level when the final color is close to one.
  96705. */
  96706. linkEmissiveWithDiffuse: boolean;
  96707. private _useSpecularOverAlpha;
  96708. /**
  96709. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  96710. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  96711. */
  96712. useSpecularOverAlpha: boolean;
  96713. private _useReflectionOverAlpha;
  96714. /**
  96715. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  96716. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  96717. */
  96718. useReflectionOverAlpha: boolean;
  96719. private _disableLighting;
  96720. /**
  96721. * Does lights from the scene impacts this material.
  96722. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  96723. */
  96724. disableLighting: boolean;
  96725. private _useObjectSpaceNormalMap;
  96726. /**
  96727. * Allows using an object space normal map (instead of tangent space).
  96728. */
  96729. useObjectSpaceNormalMap: boolean;
  96730. private _useParallax;
  96731. /**
  96732. * Is parallax enabled or not.
  96733. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  96734. */
  96735. useParallax: boolean;
  96736. private _useParallaxOcclusion;
  96737. /**
  96738. * Is parallax occlusion enabled or not.
  96739. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  96740. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  96741. */
  96742. useParallaxOcclusion: boolean;
  96743. /**
  96744. * 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.
  96745. */
  96746. parallaxScaleBias: number;
  96747. private _roughness;
  96748. /**
  96749. * Helps to define how blurry the reflections should appears in the material.
  96750. */
  96751. roughness: number;
  96752. /**
  96753. * In case of refraction, define the value of the indice of refraction.
  96754. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96755. */
  96756. indexOfRefraction: number;
  96757. /**
  96758. * Invert the refraction texture alongside the y axis.
  96759. * It can be useful with procedural textures or probe for instance.
  96760. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96761. */
  96762. invertRefractionY: boolean;
  96763. /**
  96764. * Defines the alpha limits in alpha test mode.
  96765. */
  96766. alphaCutOff: number;
  96767. private _useLightmapAsShadowmap;
  96768. /**
  96769. * In case of light mapping, define whether the map contains light or shadow informations.
  96770. */
  96771. useLightmapAsShadowmap: boolean;
  96772. private _diffuseFresnelParameters;
  96773. /**
  96774. * Define the diffuse fresnel parameters of the material.
  96775. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96776. */
  96777. diffuseFresnelParameters: FresnelParameters;
  96778. private _opacityFresnelParameters;
  96779. /**
  96780. * Define the opacity fresnel parameters of the material.
  96781. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96782. */
  96783. opacityFresnelParameters: FresnelParameters;
  96784. private _reflectionFresnelParameters;
  96785. /**
  96786. * Define the reflection fresnel parameters of the material.
  96787. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96788. */
  96789. reflectionFresnelParameters: FresnelParameters;
  96790. private _refractionFresnelParameters;
  96791. /**
  96792. * Define the refraction fresnel parameters of the material.
  96793. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96794. */
  96795. refractionFresnelParameters: FresnelParameters;
  96796. private _emissiveFresnelParameters;
  96797. /**
  96798. * Define the emissive fresnel parameters of the material.
  96799. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96800. */
  96801. emissiveFresnelParameters: FresnelParameters;
  96802. private _useReflectionFresnelFromSpecular;
  96803. /**
  96804. * If true automatically deducts the fresnels values from the material specularity.
  96805. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96806. */
  96807. useReflectionFresnelFromSpecular: boolean;
  96808. private _useGlossinessFromSpecularMapAlpha;
  96809. /**
  96810. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  96811. */
  96812. useGlossinessFromSpecularMapAlpha: boolean;
  96813. private _maxSimultaneousLights;
  96814. /**
  96815. * Defines the maximum number of lights that can be used in the material
  96816. */
  96817. maxSimultaneousLights: number;
  96818. private _invertNormalMapX;
  96819. /**
  96820. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  96821. */
  96822. invertNormalMapX: boolean;
  96823. private _invertNormalMapY;
  96824. /**
  96825. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  96826. */
  96827. invertNormalMapY: boolean;
  96828. private _twoSidedLighting;
  96829. /**
  96830. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  96831. */
  96832. twoSidedLighting: boolean;
  96833. /**
  96834. * Default configuration related to image processing available in the standard Material.
  96835. */
  96836. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  96837. /**
  96838. * Gets the image processing configuration used either in this material.
  96839. */
  96840. /**
  96841. * Sets the Default image processing configuration used either in the this material.
  96842. *
  96843. * If sets to null, the scene one is in use.
  96844. */
  96845. imageProcessingConfiguration: ImageProcessingConfiguration;
  96846. /**
  96847. * Keep track of the image processing observer to allow dispose and replace.
  96848. */
  96849. private _imageProcessingObserver;
  96850. /**
  96851. * Attaches a new image processing configuration to the Standard Material.
  96852. * @param configuration
  96853. */
  96854. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  96855. /**
  96856. * Gets wether the color curves effect is enabled.
  96857. */
  96858. /**
  96859. * Sets wether the color curves effect is enabled.
  96860. */
  96861. cameraColorCurvesEnabled: boolean;
  96862. /**
  96863. * Gets wether the color grading effect is enabled.
  96864. */
  96865. /**
  96866. * Gets wether the color grading effect is enabled.
  96867. */
  96868. cameraColorGradingEnabled: boolean;
  96869. /**
  96870. * Gets wether tonemapping is enabled or not.
  96871. */
  96872. /**
  96873. * Sets wether tonemapping is enabled or not
  96874. */
  96875. cameraToneMappingEnabled: boolean;
  96876. /**
  96877. * The camera exposure used on this material.
  96878. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  96879. * This corresponds to a photographic exposure.
  96880. */
  96881. /**
  96882. * The camera exposure used on this material.
  96883. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  96884. * This corresponds to a photographic exposure.
  96885. */
  96886. cameraExposure: number;
  96887. /**
  96888. * Gets The camera contrast used on this material.
  96889. */
  96890. /**
  96891. * Sets The camera contrast used on this material.
  96892. */
  96893. cameraContrast: number;
  96894. /**
  96895. * Gets the Color Grading 2D Lookup Texture.
  96896. */
  96897. /**
  96898. * Sets the Color Grading 2D Lookup Texture.
  96899. */
  96900. cameraColorGradingTexture: Nullable<BaseTexture>;
  96901. /**
  96902. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  96903. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  96904. * 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;
  96905. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  96906. */
  96907. /**
  96908. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  96909. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  96910. * 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;
  96911. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  96912. */
  96913. cameraColorCurves: Nullable<ColorCurves>;
  96914. /**
  96915. * Custom callback helping to override the default shader used in the material.
  96916. */
  96917. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  96918. protected _renderTargets: SmartArray<RenderTargetTexture>;
  96919. protected _worldViewProjectionMatrix: Matrix;
  96920. protected _globalAmbientColor: Color3;
  96921. protected _useLogarithmicDepth: boolean;
  96922. /**
  96923. * Instantiates a new standard material.
  96924. * This is the default material used in Babylon. It is the best trade off between quality
  96925. * and performances.
  96926. * @see http://doc.babylonjs.com/babylon101/materials
  96927. * @param name Define the name of the material in the scene
  96928. * @param scene Define the scene the material belong to
  96929. */
  96930. constructor(name: string, scene: Scene);
  96931. /**
  96932. * Gets a boolean indicating that current material needs to register RTT
  96933. */
  96934. readonly hasRenderTargetTextures: boolean;
  96935. /**
  96936. * Gets the current class name of the material e.g. "StandardMaterial"
  96937. * Mainly use in serialization.
  96938. * @returns the class name
  96939. */
  96940. getClassName(): string;
  96941. /**
  96942. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  96943. * You can try switching to logarithmic depth.
  96944. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  96945. */
  96946. useLogarithmicDepth: boolean;
  96947. /**
  96948. * Specifies if the material will require alpha blending
  96949. * @returns a boolean specifying if alpha blending is needed
  96950. */
  96951. needAlphaBlending(): boolean;
  96952. /**
  96953. * Specifies if this material should be rendered in alpha test mode
  96954. * @returns a boolean specifying if an alpha test is needed.
  96955. */
  96956. needAlphaTesting(): boolean;
  96957. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  96958. /**
  96959. * Get the texture used for alpha test purpose.
  96960. * @returns the diffuse texture in case of the standard material.
  96961. */
  96962. getAlphaTestTexture(): Nullable<BaseTexture>;
  96963. /**
  96964. * Get if the submesh is ready to be used and all its information available.
  96965. * Child classes can use it to update shaders
  96966. * @param mesh defines the mesh to check
  96967. * @param subMesh defines which submesh to check
  96968. * @param useInstances specifies that instances should be used
  96969. * @returns a boolean indicating that the submesh is ready or not
  96970. */
  96971. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  96972. /**
  96973. * Builds the material UBO layouts.
  96974. * Used internally during the effect preparation.
  96975. */
  96976. buildUniformLayout(): void;
  96977. /**
  96978. * Unbinds the material from the mesh
  96979. */
  96980. unbind(): void;
  96981. /**
  96982. * Binds the submesh to this material by preparing the effect and shader to draw
  96983. * @param world defines the world transformation matrix
  96984. * @param mesh defines the mesh containing the submesh
  96985. * @param subMesh defines the submesh to bind the material to
  96986. */
  96987. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  96988. /**
  96989. * Get the list of animatables in the material.
  96990. * @returns the list of animatables object used in the material
  96991. */
  96992. getAnimatables(): IAnimatable[];
  96993. /**
  96994. * Gets the active textures from the material
  96995. * @returns an array of textures
  96996. */
  96997. getActiveTextures(): BaseTexture[];
  96998. /**
  96999. * Specifies if the material uses a texture
  97000. * @param texture defines the texture to check against the material
  97001. * @returns a boolean specifying if the material uses the texture
  97002. */
  97003. hasTexture(texture: BaseTexture): boolean;
  97004. /**
  97005. * Disposes the material
  97006. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  97007. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  97008. */
  97009. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  97010. /**
  97011. * Makes a duplicate of the material, and gives it a new name
  97012. * @param name defines the new name for the duplicated material
  97013. * @returns the cloned material
  97014. */
  97015. clone(name: string): StandardMaterial;
  97016. /**
  97017. * Serializes this material in a JSON representation
  97018. * @returns the serialized material object
  97019. */
  97020. serialize(): any;
  97021. /**
  97022. * Creates a standard material from parsed material data
  97023. * @param source defines the JSON representation of the material
  97024. * @param scene defines the hosting scene
  97025. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97026. * @returns a new standard material
  97027. */
  97028. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  97029. /**
  97030. * Are diffuse textures enabled in the application.
  97031. */
  97032. static DiffuseTextureEnabled: boolean;
  97033. /**
  97034. * Are ambient textures enabled in the application.
  97035. */
  97036. static AmbientTextureEnabled: boolean;
  97037. /**
  97038. * Are opacity textures enabled in the application.
  97039. */
  97040. static OpacityTextureEnabled: boolean;
  97041. /**
  97042. * Are reflection textures enabled in the application.
  97043. */
  97044. static ReflectionTextureEnabled: boolean;
  97045. /**
  97046. * Are emissive textures enabled in the application.
  97047. */
  97048. static EmissiveTextureEnabled: boolean;
  97049. /**
  97050. * Are specular textures enabled in the application.
  97051. */
  97052. static SpecularTextureEnabled: boolean;
  97053. /**
  97054. * Are bump textures enabled in the application.
  97055. */
  97056. static BumpTextureEnabled: boolean;
  97057. /**
  97058. * Are lightmap textures enabled in the application.
  97059. */
  97060. static LightmapTextureEnabled: boolean;
  97061. /**
  97062. * Are refraction textures enabled in the application.
  97063. */
  97064. static RefractionTextureEnabled: boolean;
  97065. /**
  97066. * Are color grading textures enabled in the application.
  97067. */
  97068. static ColorGradingTextureEnabled: boolean;
  97069. /**
  97070. * Are fresnels enabled in the application.
  97071. */
  97072. static FresnelEnabled: boolean;
  97073. }
  97074. }
  97075. declare module BABYLON {
  97076. /**
  97077. * A class extending Texture allowing drawing on a texture
  97078. * @see http://doc.babylonjs.com/how_to/dynamictexture
  97079. */
  97080. export class DynamicTexture extends Texture {
  97081. private _generateMipMaps;
  97082. private _canvas;
  97083. private _context;
  97084. private _engine;
  97085. /**
  97086. * Creates a DynamicTexture
  97087. * @param name defines the name of the texture
  97088. * @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
  97089. * @param scene defines the scene where you want the texture
  97090. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  97091. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  97092. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  97093. */
  97094. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  97095. /**
  97096. * Get the current class name of the texture useful for serialization or dynamic coding.
  97097. * @returns "DynamicTexture"
  97098. */
  97099. getClassName(): string;
  97100. /**
  97101. * Gets the current state of canRescale
  97102. */
  97103. readonly canRescale: boolean;
  97104. private _recreate;
  97105. /**
  97106. * Scales the texture
  97107. * @param ratio the scale factor to apply to both width and height
  97108. */
  97109. scale(ratio: number): void;
  97110. /**
  97111. * Resizes the texture
  97112. * @param width the new width
  97113. * @param height the new height
  97114. */
  97115. scaleTo(width: number, height: number): void;
  97116. /**
  97117. * Gets the context of the canvas used by the texture
  97118. * @returns the canvas context of the dynamic texture
  97119. */
  97120. getContext(): CanvasRenderingContext2D;
  97121. /**
  97122. * Clears the texture
  97123. */
  97124. clear(): void;
  97125. /**
  97126. * Updates the texture
  97127. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  97128. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  97129. */
  97130. update(invertY?: boolean, premulAlpha?: boolean): void;
  97131. /**
  97132. * Draws text onto the texture
  97133. * @param text defines the text to be drawn
  97134. * @param x defines the placement of the text from the left
  97135. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  97136. * @param font defines the font to be used with font-style, font-size, font-name
  97137. * @param color defines the color used for the text
  97138. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  97139. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  97140. * @param update defines whether texture is immediately update (default is true)
  97141. */
  97142. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  97143. /**
  97144. * Clones the texture
  97145. * @returns the clone of the texture.
  97146. */
  97147. clone(): DynamicTexture;
  97148. /**
  97149. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  97150. * @returns a serialized dynamic texture object
  97151. */
  97152. serialize(): any;
  97153. /** @hidden */
  97154. _rebuild(): void;
  97155. }
  97156. }
  97157. declare module BABYLON {
  97158. /** @hidden */
  97159. export var imageProcessingPixelShader: {
  97160. name: string;
  97161. shader: string;
  97162. };
  97163. }
  97164. declare module BABYLON {
  97165. /**
  97166. * ImageProcessingPostProcess
  97167. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  97168. */
  97169. export class ImageProcessingPostProcess extends PostProcess {
  97170. /**
  97171. * Default configuration related to image processing available in the PBR Material.
  97172. */
  97173. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  97174. /**
  97175. * Gets the image processing configuration used either in this material.
  97176. */
  97177. /**
  97178. * Sets the Default image processing configuration used either in the this material.
  97179. *
  97180. * If sets to null, the scene one is in use.
  97181. */
  97182. imageProcessingConfiguration: ImageProcessingConfiguration;
  97183. /**
  97184. * Keep track of the image processing observer to allow dispose and replace.
  97185. */
  97186. private _imageProcessingObserver;
  97187. /**
  97188. * Attaches a new image processing configuration to the PBR Material.
  97189. * @param configuration
  97190. */
  97191. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  97192. /**
  97193. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  97194. */
  97195. /**
  97196. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  97197. */
  97198. colorCurves: Nullable<ColorCurves>;
  97199. /**
  97200. * Gets wether the color curves effect is enabled.
  97201. */
  97202. /**
  97203. * Sets wether the color curves effect is enabled.
  97204. */
  97205. colorCurvesEnabled: boolean;
  97206. /**
  97207. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  97208. */
  97209. /**
  97210. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  97211. */
  97212. colorGradingTexture: Nullable<BaseTexture>;
  97213. /**
  97214. * Gets wether the color grading effect is enabled.
  97215. */
  97216. /**
  97217. * Gets wether the color grading effect is enabled.
  97218. */
  97219. colorGradingEnabled: boolean;
  97220. /**
  97221. * Gets exposure used in the effect.
  97222. */
  97223. /**
  97224. * Sets exposure used in the effect.
  97225. */
  97226. exposure: number;
  97227. /**
  97228. * Gets wether tonemapping is enabled or not.
  97229. */
  97230. /**
  97231. * Sets wether tonemapping is enabled or not
  97232. */
  97233. toneMappingEnabled: boolean;
  97234. /**
  97235. * Gets the type of tone mapping effect.
  97236. */
  97237. /**
  97238. * Sets the type of tone mapping effect.
  97239. */
  97240. toneMappingType: number;
  97241. /**
  97242. * Gets contrast used in the effect.
  97243. */
  97244. /**
  97245. * Sets contrast used in the effect.
  97246. */
  97247. contrast: number;
  97248. /**
  97249. * Gets Vignette stretch size.
  97250. */
  97251. /**
  97252. * Sets Vignette stretch size.
  97253. */
  97254. vignetteStretch: number;
  97255. /**
  97256. * Gets Vignette centre X Offset.
  97257. */
  97258. /**
  97259. * Sets Vignette centre X Offset.
  97260. */
  97261. vignetteCentreX: number;
  97262. /**
  97263. * Gets Vignette centre Y Offset.
  97264. */
  97265. /**
  97266. * Sets Vignette centre Y Offset.
  97267. */
  97268. vignetteCentreY: number;
  97269. /**
  97270. * Gets Vignette weight or intensity of the vignette effect.
  97271. */
  97272. /**
  97273. * Sets Vignette weight or intensity of the vignette effect.
  97274. */
  97275. vignetteWeight: number;
  97276. /**
  97277. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  97278. * if vignetteEnabled is set to true.
  97279. */
  97280. /**
  97281. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  97282. * if vignetteEnabled is set to true.
  97283. */
  97284. vignetteColor: Color4;
  97285. /**
  97286. * Gets Camera field of view used by the Vignette effect.
  97287. */
  97288. /**
  97289. * Sets Camera field of view used by the Vignette effect.
  97290. */
  97291. vignetteCameraFov: number;
  97292. /**
  97293. * Gets the vignette blend mode allowing different kind of effect.
  97294. */
  97295. /**
  97296. * Sets the vignette blend mode allowing different kind of effect.
  97297. */
  97298. vignetteBlendMode: number;
  97299. /**
  97300. * Gets wether the vignette effect is enabled.
  97301. */
  97302. /**
  97303. * Sets wether the vignette effect is enabled.
  97304. */
  97305. vignetteEnabled: boolean;
  97306. private _fromLinearSpace;
  97307. /**
  97308. * Gets wether the input of the processing is in Gamma or Linear Space.
  97309. */
  97310. /**
  97311. * Sets wether the input of the processing is in Gamma or Linear Space.
  97312. */
  97313. fromLinearSpace: boolean;
  97314. /**
  97315. * Defines cache preventing GC.
  97316. */
  97317. private _defines;
  97318. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  97319. /**
  97320. * "ImageProcessingPostProcess"
  97321. * @returns "ImageProcessingPostProcess"
  97322. */
  97323. getClassName(): string;
  97324. protected _updateParameters(): void;
  97325. dispose(camera?: Camera): void;
  97326. }
  97327. }
  97328. declare module BABYLON {
  97329. /**
  97330. * Class containing static functions to help procedurally build meshes
  97331. */
  97332. export class GroundBuilder {
  97333. /**
  97334. * Creates a ground mesh
  97335. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  97336. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  97337. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97338. * @param name defines the name of the mesh
  97339. * @param options defines the options used to create the mesh
  97340. * @param scene defines the hosting scene
  97341. * @returns the ground mesh
  97342. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  97343. */
  97344. static CreateGround(name: string, options: {
  97345. width?: number;
  97346. height?: number;
  97347. subdivisions?: number;
  97348. subdivisionsX?: number;
  97349. subdivisionsY?: number;
  97350. updatable?: boolean;
  97351. }, scene: any): Mesh;
  97352. /**
  97353. * Creates a tiled ground mesh
  97354. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  97355. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  97356. * * 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
  97357. * * 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
  97358. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  97359. * @param name defines the name of the mesh
  97360. * @param options defines the options used to create the mesh
  97361. * @param scene defines the hosting scene
  97362. * @returns the tiled ground mesh
  97363. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  97364. */
  97365. static CreateTiledGround(name: string, options: {
  97366. xmin: number;
  97367. zmin: number;
  97368. xmax: number;
  97369. zmax: number;
  97370. subdivisions?: {
  97371. w: number;
  97372. h: number;
  97373. };
  97374. precision?: {
  97375. w: number;
  97376. h: number;
  97377. };
  97378. updatable?: boolean;
  97379. }, scene: Scene): Mesh;
  97380. /**
  97381. * Creates a ground mesh from a height map
  97382. * * The parameter `url` sets the URL of the height map image resource.
  97383. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  97384. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  97385. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  97386. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  97387. * * 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.
  97388. * * 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).
  97389. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  97390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  97391. * @param name defines the name of the mesh
  97392. * @param url defines the url to the height map
  97393. * @param options defines the options used to create the mesh
  97394. * @param scene defines the hosting scene
  97395. * @returns the ground mesh
  97396. * @see https://doc.babylonjs.com/babylon101/height_map
  97397. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  97398. */
  97399. static CreateGroundFromHeightMap(name: string, url: string, options: {
  97400. width?: number;
  97401. height?: number;
  97402. subdivisions?: number;
  97403. minHeight?: number;
  97404. maxHeight?: number;
  97405. colorFilter?: Color3;
  97406. alphaFilter?: number;
  97407. updatable?: boolean;
  97408. onReady?: (mesh: GroundMesh) => void;
  97409. }, scene: Scene): GroundMesh;
  97410. }
  97411. }
  97412. declare module BABYLON {
  97413. /**
  97414. * Class containing static functions to help procedurally build meshes
  97415. */
  97416. export class TorusBuilder {
  97417. /**
  97418. * Creates a torus mesh
  97419. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  97420. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  97421. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  97422. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  97423. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  97424. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  97425. * @param name defines the name of the mesh
  97426. * @param options defines the options used to create the mesh
  97427. * @param scene defines the hosting scene
  97428. * @returns the torus mesh
  97429. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  97430. */
  97431. static CreateTorus(name: string, options: {
  97432. diameter?: number;
  97433. thickness?: number;
  97434. tessellation?: number;
  97435. updatable?: boolean;
  97436. sideOrientation?: number;
  97437. frontUVs?: Vector4;
  97438. backUVs?: Vector4;
  97439. }, scene: any): Mesh;
  97440. }
  97441. }
  97442. declare module BABYLON {
  97443. /**
  97444. * Class containing static functions to help procedurally build meshes
  97445. */
  97446. export class CylinderBuilder {
  97447. /**
  97448. * Creates a cylinder or a cone mesh
  97449. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  97450. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  97451. * * 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.
  97452. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  97453. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  97454. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  97455. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  97456. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  97457. * * 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).
  97458. * * 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
  97459. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  97460. * * 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
  97461. * * 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.
  97462. * * If `enclose` is false, a ring surface is one element.
  97463. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  97464. * * 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
  97465. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  97466. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  97467. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  97468. * @param name defines the name of the mesh
  97469. * @param options defines the options used to create the mesh
  97470. * @param scene defines the hosting scene
  97471. * @returns the cylinder mesh
  97472. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  97473. */
  97474. static CreateCylinder(name: string, options: {
  97475. height?: number;
  97476. diameterTop?: number;
  97477. diameterBottom?: number;
  97478. diameter?: number;
  97479. tessellation?: number;
  97480. subdivisions?: number;
  97481. arc?: number;
  97482. faceColors?: Color4[];
  97483. faceUV?: Vector4[];
  97484. updatable?: boolean;
  97485. hasRings?: boolean;
  97486. enclose?: boolean;
  97487. sideOrientation?: number;
  97488. frontUVs?: Vector4;
  97489. backUVs?: Vector4;
  97490. }, scene: any): Mesh;
  97491. }
  97492. }
  97493. declare module BABYLON {
  97494. /**
  97495. * Manager for handling gamepads
  97496. */
  97497. export class GamepadManager {
  97498. private _scene?;
  97499. private _babylonGamepads;
  97500. private _oneGamepadConnected;
  97501. /** @hidden */
  97502. _isMonitoring: boolean;
  97503. private _gamepadEventSupported;
  97504. private _gamepadSupport;
  97505. /**
  97506. * observable to be triggered when the gamepad controller has been connected
  97507. */
  97508. onGamepadConnectedObservable: Observable<Gamepad>;
  97509. /**
  97510. * observable to be triggered when the gamepad controller has been disconnected
  97511. */
  97512. onGamepadDisconnectedObservable: Observable<Gamepad>;
  97513. private _onGamepadConnectedEvent;
  97514. private _onGamepadDisconnectedEvent;
  97515. /**
  97516. * Initializes the gamepad manager
  97517. * @param _scene BabylonJS scene
  97518. */
  97519. constructor(_scene?: Scene | undefined);
  97520. /**
  97521. * The gamepads in the game pad manager
  97522. */
  97523. readonly gamepads: Gamepad[];
  97524. /**
  97525. * Get the gamepad controllers based on type
  97526. * @param type The type of gamepad controller
  97527. * @returns Nullable gamepad
  97528. */
  97529. getGamepadByType(type?: number): Nullable<Gamepad>;
  97530. /**
  97531. * Disposes the gamepad manager
  97532. */
  97533. dispose(): void;
  97534. private _addNewGamepad;
  97535. private _startMonitoringGamepads;
  97536. private _stopMonitoringGamepads;
  97537. /** @hidden */
  97538. _checkGamepadsStatus(): void;
  97539. private _updateGamepadObjects;
  97540. }
  97541. }
  97542. declare module BABYLON {
  97543. interface Scene {
  97544. /** @hidden */
  97545. _gamepadManager: Nullable<GamepadManager>;
  97546. /**
  97547. * Gets the gamepad manager associated with the scene
  97548. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  97549. */
  97550. gamepadManager: GamepadManager;
  97551. }
  97552. /**
  97553. * Interface representing a free camera inputs manager
  97554. */
  97555. interface FreeCameraInputsManager {
  97556. /**
  97557. * Adds gamepad input support to the FreeCameraInputsManager.
  97558. * @returns the FreeCameraInputsManager
  97559. */
  97560. addGamepad(): FreeCameraInputsManager;
  97561. }
  97562. /**
  97563. * Interface representing an arc rotate camera inputs manager
  97564. */
  97565. interface ArcRotateCameraInputsManager {
  97566. /**
  97567. * Adds gamepad input support to the ArcRotateCamera InputManager.
  97568. * @returns the camera inputs manager
  97569. */
  97570. addGamepad(): ArcRotateCameraInputsManager;
  97571. }
  97572. /**
  97573. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  97574. */
  97575. export class GamepadSystemSceneComponent implements ISceneComponent {
  97576. /**
  97577. * The component name helpfull to identify the component in the list of scene components.
  97578. */
  97579. readonly name: string;
  97580. /**
  97581. * The scene the component belongs to.
  97582. */
  97583. scene: Scene;
  97584. /**
  97585. * Creates a new instance of the component for the given scene
  97586. * @param scene Defines the scene to register the component in
  97587. */
  97588. constructor(scene: Scene);
  97589. /**
  97590. * Registers the component in a given scene
  97591. */
  97592. register(): void;
  97593. /**
  97594. * Rebuilds the elements related to this component in case of
  97595. * context lost for instance.
  97596. */
  97597. rebuild(): void;
  97598. /**
  97599. * Disposes the component and the associated ressources
  97600. */
  97601. dispose(): void;
  97602. private _beforeCameraUpdate;
  97603. }
  97604. }
  97605. declare module BABYLON {
  97606. /**
  97607. * Options to modify the vr teleportation behavior.
  97608. */
  97609. export interface VRTeleportationOptions {
  97610. /**
  97611. * The name of the mesh which should be used as the teleportation floor. (default: null)
  97612. */
  97613. floorMeshName?: string;
  97614. /**
  97615. * A list of meshes to be used as the teleportation floor. (default: empty)
  97616. */
  97617. floorMeshes?: Mesh[];
  97618. }
  97619. /**
  97620. * Options to modify the vr experience helper's behavior.
  97621. */
  97622. export interface VRExperienceHelperOptions extends WebVROptions {
  97623. /**
  97624. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  97625. */
  97626. createDeviceOrientationCamera?: boolean;
  97627. /**
  97628. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  97629. */
  97630. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  97631. /**
  97632. * Uses the main button on the controller to toggle the laser casted. (default: true)
  97633. */
  97634. laserToggle?: boolean;
  97635. /**
  97636. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  97637. */
  97638. floorMeshes?: Mesh[];
  97639. /**
  97640. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  97641. */
  97642. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  97643. }
  97644. /**
  97645. * Event containing information after VR has been entered
  97646. */
  97647. export class OnAfterEnteringVRObservableEvent {
  97648. /**
  97649. * If entering vr was successful
  97650. */
  97651. success: boolean;
  97652. }
  97653. /**
  97654. * Helps to quickly add VR support to an existing scene.
  97655. * See http://doc.babylonjs.com/how_to/webvr_helper
  97656. */
  97657. export class VRExperienceHelper {
  97658. /** Options to modify the vr experience helper's behavior. */
  97659. webVROptions: VRExperienceHelperOptions;
  97660. private _scene;
  97661. private _position;
  97662. private _btnVR;
  97663. private _btnVRDisplayed;
  97664. private _webVRsupported;
  97665. private _webVRready;
  97666. private _webVRrequesting;
  97667. private _webVRpresenting;
  97668. private _hasEnteredVR;
  97669. private _fullscreenVRpresenting;
  97670. private _canvas;
  97671. private _webVRCamera;
  97672. private _vrDeviceOrientationCamera;
  97673. private _deviceOrientationCamera;
  97674. private _existingCamera;
  97675. private _onKeyDown;
  97676. private _onVrDisplayPresentChange;
  97677. private _onVRDisplayChanged;
  97678. private _onVRRequestPresentStart;
  97679. private _onVRRequestPresentComplete;
  97680. /**
  97681. * Observable raised right before entering VR.
  97682. */
  97683. onEnteringVRObservable: Observable<VRExperienceHelper>;
  97684. /**
  97685. * Observable raised when entering VR has completed.
  97686. */
  97687. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  97688. /**
  97689. * Observable raised when exiting VR.
  97690. */
  97691. onExitingVRObservable: Observable<VRExperienceHelper>;
  97692. /**
  97693. * Observable raised when controller mesh is loaded.
  97694. */
  97695. onControllerMeshLoadedObservable: Observable<WebVRController>;
  97696. /** Return this.onEnteringVRObservable
  97697. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  97698. */
  97699. readonly onEnteringVR: Observable<VRExperienceHelper>;
  97700. /** Return this.onExitingVRObservable
  97701. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  97702. */
  97703. readonly onExitingVR: Observable<VRExperienceHelper>;
  97704. /** Return this.onControllerMeshLoadedObservable
  97705. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  97706. */
  97707. readonly onControllerMeshLoaded: Observable<WebVRController>;
  97708. private _rayLength;
  97709. private _useCustomVRButton;
  97710. private _teleportationRequested;
  97711. private _teleportActive;
  97712. private _floorMeshName;
  97713. private _floorMeshesCollection;
  97714. private _rotationAllowed;
  97715. private _teleportBackwardsVector;
  97716. private _teleportationTarget;
  97717. private _isDefaultTeleportationTarget;
  97718. private _postProcessMove;
  97719. private _teleportationFillColor;
  97720. private _teleportationBorderColor;
  97721. private _rotationAngle;
  97722. private _haloCenter;
  97723. private _cameraGazer;
  97724. private _padSensibilityUp;
  97725. private _padSensibilityDown;
  97726. private _leftController;
  97727. private _rightController;
  97728. /**
  97729. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  97730. */
  97731. onNewMeshSelected: Observable<AbstractMesh>;
  97732. /**
  97733. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  97734. */
  97735. onNewMeshPicked: Observable<PickingInfo>;
  97736. private _circleEase;
  97737. /**
  97738. * Observable raised before camera teleportation
  97739. */
  97740. onBeforeCameraTeleport: Observable<Vector3>;
  97741. /**
  97742. * Observable raised after camera teleportation
  97743. */
  97744. onAfterCameraTeleport: Observable<Vector3>;
  97745. /**
  97746. * Observable raised when current selected mesh gets unselected
  97747. */
  97748. onSelectedMeshUnselected: Observable<AbstractMesh>;
  97749. private _raySelectionPredicate;
  97750. /**
  97751. * To be optionaly changed by user to define custom ray selection
  97752. */
  97753. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  97754. /**
  97755. * To be optionaly changed by user to define custom selection logic (after ray selection)
  97756. */
  97757. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  97758. /**
  97759. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  97760. */
  97761. teleportationEnabled: boolean;
  97762. private _defaultHeight;
  97763. private _teleportationInitialized;
  97764. private _interactionsEnabled;
  97765. private _interactionsRequested;
  97766. private _displayGaze;
  97767. private _displayLaserPointer;
  97768. /**
  97769. * The mesh used to display where the user is going to teleport.
  97770. */
  97771. /**
  97772. * Sets the mesh to be used to display where the user is going to teleport.
  97773. */
  97774. teleportationTarget: Mesh;
  97775. /**
  97776. * 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
  97777. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  97778. * See http://doc.babylonjs.com/resources/baking_transformations
  97779. */
  97780. gazeTrackerMesh: Mesh;
  97781. /**
  97782. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  97783. */
  97784. updateGazeTrackerScale: boolean;
  97785. /**
  97786. * If the gaze trackers color should be updated when selecting meshes
  97787. */
  97788. updateGazeTrackerColor: boolean;
  97789. /**
  97790. * The gaze tracking mesh corresponding to the left controller
  97791. */
  97792. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  97793. /**
  97794. * The gaze tracking mesh corresponding to the right controller
  97795. */
  97796. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  97797. /**
  97798. * If the ray of the gaze should be displayed.
  97799. */
  97800. /**
  97801. * Sets if the ray of the gaze should be displayed.
  97802. */
  97803. displayGaze: boolean;
  97804. /**
  97805. * If the ray of the LaserPointer should be displayed.
  97806. */
  97807. /**
  97808. * Sets if the ray of the LaserPointer should be displayed.
  97809. */
  97810. displayLaserPointer: boolean;
  97811. /**
  97812. * The deviceOrientationCamera used as the camera when not in VR.
  97813. */
  97814. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  97815. /**
  97816. * Based on the current WebVR support, returns the current VR camera used.
  97817. */
  97818. readonly currentVRCamera: Nullable<Camera>;
  97819. /**
  97820. * The webVRCamera which is used when in VR.
  97821. */
  97822. readonly webVRCamera: WebVRFreeCamera;
  97823. /**
  97824. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  97825. */
  97826. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  97827. private readonly _teleportationRequestInitiated;
  97828. /**
  97829. * Defines wether or not Pointer lock should be requested when switching to
  97830. * full screen.
  97831. */
  97832. requestPointerLockOnFullScreen: boolean;
  97833. /**
  97834. * Instantiates a VRExperienceHelper.
  97835. * Helps to quickly add VR support to an existing scene.
  97836. * @param scene The scene the VRExperienceHelper belongs to.
  97837. * @param webVROptions Options to modify the vr experience helper's behavior.
  97838. */
  97839. constructor(scene: Scene,
  97840. /** Options to modify the vr experience helper's behavior. */
  97841. webVROptions?: VRExperienceHelperOptions);
  97842. private _onDefaultMeshLoaded;
  97843. private _onResize;
  97844. private _onFullscreenChange;
  97845. /**
  97846. * Gets a value indicating if we are currently in VR mode.
  97847. */
  97848. readonly isInVRMode: boolean;
  97849. private onVrDisplayPresentChange;
  97850. private onVRDisplayChanged;
  97851. private moveButtonToBottomRight;
  97852. private displayVRButton;
  97853. private updateButtonVisibility;
  97854. private _cachedAngularSensibility;
  97855. /**
  97856. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  97857. * Otherwise, will use the fullscreen API.
  97858. */
  97859. enterVR(): void;
  97860. /**
  97861. * Attempt to exit VR, or fullscreen.
  97862. */
  97863. exitVR(): void;
  97864. /**
  97865. * The position of the vr experience helper.
  97866. */
  97867. /**
  97868. * Sets the position of the vr experience helper.
  97869. */
  97870. position: Vector3;
  97871. /**
  97872. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  97873. */
  97874. enableInteractions(): void;
  97875. private readonly _noControllerIsActive;
  97876. private beforeRender;
  97877. private _isTeleportationFloor;
  97878. /**
  97879. * Adds a floor mesh to be used for teleportation.
  97880. * @param floorMesh the mesh to be used for teleportation.
  97881. */
  97882. addFloorMesh(floorMesh: Mesh): void;
  97883. /**
  97884. * Removes a floor mesh from being used for teleportation.
  97885. * @param floorMesh the mesh to be removed.
  97886. */
  97887. removeFloorMesh(floorMesh: Mesh): void;
  97888. /**
  97889. * Enables interactions and teleportation using the VR controllers and gaze.
  97890. * @param vrTeleportationOptions options to modify teleportation behavior.
  97891. */
  97892. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  97893. private _onNewGamepadConnected;
  97894. private _tryEnableInteractionOnController;
  97895. private _onNewGamepadDisconnected;
  97896. private _enableInteractionOnController;
  97897. private _checkTeleportWithRay;
  97898. private _checkRotate;
  97899. private _checkTeleportBackwards;
  97900. private _enableTeleportationOnController;
  97901. private _createTeleportationCircles;
  97902. private _displayTeleportationTarget;
  97903. private _hideTeleportationTarget;
  97904. private _rotateCamera;
  97905. private _moveTeleportationSelectorTo;
  97906. private _workingVector;
  97907. private _workingQuaternion;
  97908. private _workingMatrix;
  97909. /**
  97910. * Teleports the users feet to the desired location
  97911. * @param location The location where the user's feet should be placed
  97912. */
  97913. teleportCamera(location: Vector3): void;
  97914. private _convertNormalToDirectionOfRay;
  97915. private _castRayAndSelectObject;
  97916. private _notifySelectedMeshUnselected;
  97917. /**
  97918. * Sets the color of the laser ray from the vr controllers.
  97919. * @param color new color for the ray.
  97920. */
  97921. changeLaserColor(color: Color3): void;
  97922. /**
  97923. * Sets the color of the ray from the vr headsets gaze.
  97924. * @param color new color for the ray.
  97925. */
  97926. changeGazeColor(color: Color3): void;
  97927. /**
  97928. * Exits VR and disposes of the vr experience helper
  97929. */
  97930. dispose(): void;
  97931. /**
  97932. * Gets the name of the VRExperienceHelper class
  97933. * @returns "VRExperienceHelper"
  97934. */
  97935. getClassName(): string;
  97936. }
  97937. }
  97938. declare module BABYLON {
  97939. /**
  97940. * Manages an XRSession
  97941. * @see https://doc.babylonjs.com/how_to/webxr
  97942. */
  97943. export class WebXRSessionManager implements IDisposable {
  97944. private scene;
  97945. /**
  97946. * Fires every time a new xrFrame arrives which can be used to update the camera
  97947. */
  97948. onXRFrameObservable: Observable<any>;
  97949. /**
  97950. * Fires when the xr session is ended either by the device or manually done
  97951. */
  97952. onXRSessionEnded: Observable<any>;
  97953. /** @hidden */
  97954. _xrSession: XRSession;
  97955. /** @hidden */
  97956. _frameOfReference: XRFrameOfReference;
  97957. /** @hidden */
  97958. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  97959. /** @hidden */
  97960. _currentXRFrame: Nullable<XRFrame>;
  97961. private _xrNavigator;
  97962. private _xrDevice;
  97963. private _tmpMatrix;
  97964. /**
  97965. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  97966. * @param scene The scene which the session should be created for
  97967. */
  97968. constructor(scene: Scene);
  97969. /**
  97970. * Initializes the manager
  97971. * After initialization enterXR can be called to start an XR session
  97972. * @returns Promise which resolves after it is initialized
  97973. */
  97974. initializeAsync(): Promise<void>;
  97975. /**
  97976. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  97977. * @param sessionCreationOptions xr options to create the session with
  97978. * @param frameOfReferenceType option to configure how the xr pose is expressed
  97979. * @returns Promise which resolves after it enters XR
  97980. */
  97981. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  97982. /**
  97983. * Stops the xrSession and restores the renderloop
  97984. * @returns Promise which resolves after it exits XR
  97985. */
  97986. exitXRAsync(): Promise<void>;
  97987. /**
  97988. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  97989. * @param ray ray to cast into the environment
  97990. * @returns Promise which resolves with a collision point in the environment if it exists
  97991. */
  97992. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  97993. /**
  97994. * Checks if a session would be supported for the creation options specified
  97995. * @param options creation options to check if they are supported
  97996. * @returns true if supported
  97997. */
  97998. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  97999. /**
  98000. * @hidden
  98001. * Converts the render layer of xrSession to a render target
  98002. * @param session session to create render target for
  98003. * @param scene scene the new render target should be created for
  98004. */
  98005. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  98006. /**
  98007. * Disposes of the session manager
  98008. */
  98009. dispose(): void;
  98010. }
  98011. }
  98012. declare module BABYLON {
  98013. /**
  98014. * WebXR Camera which holds the views for the xrSession
  98015. * @see https://doc.babylonjs.com/how_to/webxr
  98016. */
  98017. export class WebXRCamera extends FreeCamera {
  98018. private static _TmpMatrix;
  98019. /**
  98020. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  98021. * @param name the name of the camera
  98022. * @param scene the scene to add the camera to
  98023. */
  98024. constructor(name: string, scene: Scene);
  98025. private _updateNumberOfRigCameras;
  98026. /** @hidden */
  98027. _updateForDualEyeDebugging(pupilDistance?: number): void;
  98028. /**
  98029. * Updates the cameras position from the current pose information of the XR session
  98030. * @param xrSessionManager the session containing pose information
  98031. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  98032. */
  98033. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  98034. }
  98035. }
  98036. declare module BABYLON {
  98037. /**
  98038. * States of the webXR experience
  98039. */
  98040. export enum WebXRState {
  98041. /**
  98042. * Transitioning to being in XR mode
  98043. */
  98044. ENTERING_XR = 0,
  98045. /**
  98046. * Transitioning to non XR mode
  98047. */
  98048. EXITING_XR = 1,
  98049. /**
  98050. * In XR mode and presenting
  98051. */
  98052. IN_XR = 2,
  98053. /**
  98054. * Not entered XR mode
  98055. */
  98056. NOT_IN_XR = 3
  98057. }
  98058. /**
  98059. * Helper class used to enable XR
  98060. * @see https://doc.babylonjs.com/how_to/webxr
  98061. */
  98062. export class WebXRExperienceHelper implements IDisposable {
  98063. private scene;
  98064. /**
  98065. * 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
  98066. */
  98067. container: AbstractMesh;
  98068. /**
  98069. * Camera used to render xr content
  98070. */
  98071. camera: WebXRCamera;
  98072. /**
  98073. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  98074. */
  98075. state: WebXRState;
  98076. private _setState;
  98077. private static _TmpVector;
  98078. /**
  98079. * Fires when the state of the experience helper has changed
  98080. */
  98081. onStateChangedObservable: Observable<WebXRState>;
  98082. /** @hidden */
  98083. _sessionManager: WebXRSessionManager;
  98084. private _nonVRCamera;
  98085. private _originalSceneAutoClear;
  98086. private _supported;
  98087. /**
  98088. * Creates the experience helper
  98089. * @param scene the scene to attach the experience helper to
  98090. * @returns a promise for the experience helper
  98091. */
  98092. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  98093. /**
  98094. * Creates a WebXRExperienceHelper
  98095. * @param scene The scene the helper should be created in
  98096. */
  98097. private constructor();
  98098. /**
  98099. * Exits XR mode and returns the scene to its original state
  98100. * @returns promise that resolves after xr mode has exited
  98101. */
  98102. exitXRAsync(): Promise<void>;
  98103. /**
  98104. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  98105. * @param sessionCreationOptions options for the XR session
  98106. * @param frameOfReference frame of reference of the XR session
  98107. * @returns promise that resolves after xr mode has entered
  98108. */
  98109. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  98110. /**
  98111. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  98112. * @param ray ray to cast into the environment
  98113. * @returns Promise which resolves with a collision point in the environment if it exists
  98114. */
  98115. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  98116. /**
  98117. * Updates the global position of the camera by moving the camera's container
  98118. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  98119. * @param position The desired global position of the camera
  98120. */
  98121. setPositionOfCameraUsingContainer(position: Vector3): void;
  98122. /**
  98123. * Rotates the xr camera by rotating the camera's container around the camera's position
  98124. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  98125. * @param rotation the desired quaternion rotation to apply to the camera
  98126. */
  98127. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  98128. /**
  98129. * Checks if the creation options are supported by the xr session
  98130. * @param options creation options
  98131. * @returns true if supported
  98132. */
  98133. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  98134. /**
  98135. * Disposes of the experience helper
  98136. */
  98137. dispose(): void;
  98138. }
  98139. }
  98140. declare module BABYLON {
  98141. /**
  98142. * Button which can be used to enter a different mode of XR
  98143. */
  98144. export class WebXREnterExitUIButton {
  98145. /** button element */
  98146. element: HTMLElement;
  98147. /** XR initialization options for the button */
  98148. initializationOptions: XRSessionCreationOptions;
  98149. /**
  98150. * Creates a WebXREnterExitUIButton
  98151. * @param element button element
  98152. * @param initializationOptions XR initialization options for the button
  98153. */
  98154. constructor(
  98155. /** button element */
  98156. element: HTMLElement,
  98157. /** XR initialization options for the button */
  98158. initializationOptions: XRSessionCreationOptions);
  98159. /**
  98160. * Overwritable function which can be used to update the button's visuals when the state changes
  98161. * @param activeButton the current active button in the UI
  98162. */
  98163. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  98164. }
  98165. /**
  98166. * Options to create the webXR UI
  98167. */
  98168. export class WebXREnterExitUIOptions {
  98169. /**
  98170. * Context to enter xr with
  98171. */
  98172. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  98173. /**
  98174. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  98175. */
  98176. customButtons?: Array<WebXREnterExitUIButton>;
  98177. }
  98178. /**
  98179. * UI to allow the user to enter/exit XR mode
  98180. */
  98181. export class WebXREnterExitUI implements IDisposable {
  98182. private scene;
  98183. private _overlay;
  98184. private _buttons;
  98185. private _activeButton;
  98186. /**
  98187. * Fired every time the active button is changed.
  98188. *
  98189. * When xr is entered via a button that launches xr that button will be the callback parameter
  98190. *
  98191. * When exiting xr the callback parameter will be null)
  98192. */
  98193. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  98194. /**
  98195. * Creates UI to allow the user to enter/exit XR mode
  98196. * @param scene the scene to add the ui to
  98197. * @param helper the xr experience helper to enter/exit xr with
  98198. * @param options options to configure the UI
  98199. * @returns the created ui
  98200. */
  98201. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  98202. private constructor();
  98203. private _updateButtons;
  98204. /**
  98205. * Disposes of the object
  98206. */
  98207. dispose(): void;
  98208. }
  98209. }
  98210. declare module BABYLON {
  98211. /**
  98212. * Represents an XR input
  98213. */
  98214. export class WebXRController {
  98215. /**
  98216. * 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
  98217. */
  98218. grip?: AbstractMesh;
  98219. /**
  98220. * Pointer which can be used to select objects or attach a visible laser to
  98221. */
  98222. pointer: AbstractMesh;
  98223. /**
  98224. * Creates the controller
  98225. * @see https://doc.babylonjs.com/how_to/webxr
  98226. * @param scene the scene which the controller should be associated to
  98227. */
  98228. constructor(scene: Scene);
  98229. /**
  98230. * Disposes of the object
  98231. */
  98232. dispose(): void;
  98233. }
  98234. /**
  98235. * XR input used to track XR inputs such as controllers/rays
  98236. */
  98237. export class WebXRInput implements IDisposable {
  98238. private helper;
  98239. /**
  98240. * XR controllers being tracked
  98241. */
  98242. controllers: Array<WebXRController>;
  98243. private _tmpMatrix;
  98244. private _frameObserver;
  98245. /**
  98246. * Initializes the WebXRInput
  98247. * @param helper experience helper which the input should be created for
  98248. */
  98249. constructor(helper: WebXRExperienceHelper);
  98250. /**
  98251. * Disposes of the object
  98252. */
  98253. dispose(): void;
  98254. }
  98255. }
  98256. declare module BABYLON {
  98257. /**
  98258. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  98259. */
  98260. export class WebXRManagedOutputCanvas implements IDisposable {
  98261. private _canvas;
  98262. /**
  98263. * xrpresent context of the canvas which can be used to display/mirror xr content
  98264. */
  98265. canvasContext: Nullable<WebGLRenderingContext>;
  98266. /**
  98267. * Initializes the canvas to be added/removed upon entering/exiting xr
  98268. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  98269. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  98270. */
  98271. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  98272. /**
  98273. * Disposes of the object
  98274. */
  98275. dispose(): void;
  98276. private _setManagedOutputCanvas;
  98277. private _addCanvas;
  98278. private _removeCanvas;
  98279. }
  98280. }
  98281. declare module BABYLON {
  98282. /**
  98283. * Contains an array of blocks representing the octree
  98284. */
  98285. export interface IOctreeContainer<T> {
  98286. /**
  98287. * Blocks within the octree
  98288. */
  98289. blocks: Array<OctreeBlock<T>>;
  98290. }
  98291. /**
  98292. * Class used to store a cell in an octree
  98293. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  98294. */
  98295. export class OctreeBlock<T> {
  98296. /**
  98297. * Gets the content of the current block
  98298. */
  98299. entries: T[];
  98300. /**
  98301. * Gets the list of block children
  98302. */
  98303. blocks: Array<OctreeBlock<T>>;
  98304. private _depth;
  98305. private _maxDepth;
  98306. private _capacity;
  98307. private _minPoint;
  98308. private _maxPoint;
  98309. private _boundingVectors;
  98310. private _creationFunc;
  98311. /**
  98312. * Creates a new block
  98313. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  98314. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  98315. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  98316. * @param depth defines the current depth of this block in the octree
  98317. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  98318. * @param creationFunc defines a callback to call when an element is added to the block
  98319. */
  98320. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  98321. /**
  98322. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  98323. */
  98324. readonly capacity: number;
  98325. /**
  98326. * Gets the minimum vector (in world space) of the block's bounding box
  98327. */
  98328. readonly minPoint: Vector3;
  98329. /**
  98330. * Gets the maximum vector (in world space) of the block's bounding box
  98331. */
  98332. readonly maxPoint: Vector3;
  98333. /**
  98334. * Add a new element to this block
  98335. * @param entry defines the element to add
  98336. */
  98337. addEntry(entry: T): void;
  98338. /**
  98339. * Remove an element from this block
  98340. * @param entry defines the element to remove
  98341. */
  98342. removeEntry(entry: T): void;
  98343. /**
  98344. * Add an array of elements to this block
  98345. * @param entries defines the array of elements to add
  98346. */
  98347. addEntries(entries: T[]): void;
  98348. /**
  98349. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  98350. * @param frustumPlanes defines the frustum planes to test
  98351. * @param selection defines the array to store current content if selection is positive
  98352. * @param allowDuplicate defines if the selection array can contains duplicated entries
  98353. */
  98354. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  98355. /**
  98356. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  98357. * @param sphereCenter defines the bounding sphere center
  98358. * @param sphereRadius defines the bounding sphere radius
  98359. * @param selection defines the array to store current content if selection is positive
  98360. * @param allowDuplicate defines if the selection array can contains duplicated entries
  98361. */
  98362. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  98363. /**
  98364. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  98365. * @param ray defines the ray to test with
  98366. * @param selection defines the array to store current content if selection is positive
  98367. */
  98368. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  98369. /**
  98370. * Subdivide the content into child blocks (this block will then be empty)
  98371. */
  98372. createInnerBlocks(): void;
  98373. /**
  98374. * @hidden
  98375. */
  98376. 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;
  98377. }
  98378. }
  98379. declare module BABYLON {
  98380. /**
  98381. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  98382. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  98383. */
  98384. export class Octree<T> {
  98385. /** 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.) */
  98386. maxDepth: number;
  98387. /**
  98388. * Blocks within the octree containing objects
  98389. */
  98390. blocks: Array<OctreeBlock<T>>;
  98391. /**
  98392. * Content stored in the octree
  98393. */
  98394. dynamicContent: T[];
  98395. private _maxBlockCapacity;
  98396. private _selectionContent;
  98397. private _creationFunc;
  98398. /**
  98399. * Creates a octree
  98400. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  98401. * @param creationFunc function to be used to instatiate the octree
  98402. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  98403. * @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.)
  98404. */
  98405. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  98406. /** 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.) */
  98407. maxDepth?: number);
  98408. /**
  98409. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  98410. * @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);
  98411. * @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);
  98412. * @param entries meshes to be added to the octree blocks
  98413. */
  98414. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  98415. /**
  98416. * Adds a mesh to the octree
  98417. * @param entry Mesh to add to the octree
  98418. */
  98419. addMesh(entry: T): void;
  98420. /**
  98421. * Remove an element from the octree
  98422. * @param entry defines the element to remove
  98423. */
  98424. removeMesh(entry: T): void;
  98425. /**
  98426. * Selects an array of meshes within the frustum
  98427. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  98428. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  98429. * @returns array of meshes within the frustum
  98430. */
  98431. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  98432. /**
  98433. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  98434. * @param sphereCenter defines the bounding sphere center
  98435. * @param sphereRadius defines the bounding sphere radius
  98436. * @param allowDuplicate defines if the selection array can contains duplicated entries
  98437. * @returns an array of objects that intersect the sphere
  98438. */
  98439. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  98440. /**
  98441. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  98442. * @param ray defines the ray to test with
  98443. * @returns array of intersected objects
  98444. */
  98445. intersectsRay(ray: Ray): SmartArray<T>;
  98446. /**
  98447. * Adds a mesh into the octree block if it intersects the block
  98448. */
  98449. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  98450. /**
  98451. * Adds a submesh into the octree block if it intersects the block
  98452. */
  98453. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  98454. }
  98455. }
  98456. declare module BABYLON {
  98457. interface Scene {
  98458. /**
  98459. * @hidden
  98460. * Backing Filed
  98461. */
  98462. _selectionOctree: Octree<AbstractMesh>;
  98463. /**
  98464. * Gets the octree used to boost mesh selection (picking)
  98465. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  98466. */
  98467. selectionOctree: Octree<AbstractMesh>;
  98468. /**
  98469. * Creates or updates the octree used to boost selection (picking)
  98470. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  98471. * @param maxCapacity defines the maximum capacity per leaf
  98472. * @param maxDepth defines the maximum depth of the octree
  98473. * @returns an octree of AbstractMesh
  98474. */
  98475. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  98476. }
  98477. interface AbstractMesh {
  98478. /**
  98479. * @hidden
  98480. * Backing Field
  98481. */
  98482. _submeshesOctree: Octree<SubMesh>;
  98483. /**
  98484. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  98485. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  98486. * @param maxCapacity defines the maximum size of each block (64 by default)
  98487. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  98488. * @returns the new octree
  98489. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  98490. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  98491. */
  98492. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  98493. }
  98494. /**
  98495. * Defines the octree scene component responsible to manage any octrees
  98496. * in a given scene.
  98497. */
  98498. export class OctreeSceneComponent {
  98499. /**
  98500. * The component name helpfull to identify the component in the list of scene components.
  98501. */
  98502. readonly name: string;
  98503. /**
  98504. * The scene the component belongs to.
  98505. */
  98506. scene: Scene;
  98507. /**
  98508. * Indicates if the meshes have been checked to make sure they are isEnabled()
  98509. */
  98510. readonly checksIsEnabled: boolean;
  98511. /**
  98512. * Creates a new instance of the component for the given scene
  98513. * @param scene Defines the scene to register the component in
  98514. */
  98515. constructor(scene: Scene);
  98516. /**
  98517. * Registers the component in a given scene
  98518. */
  98519. register(): void;
  98520. /**
  98521. * Return the list of active meshes
  98522. * @returns the list of active meshes
  98523. */
  98524. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  98525. /**
  98526. * Return the list of active sub meshes
  98527. * @param mesh The mesh to get the candidates sub meshes from
  98528. * @returns the list of active sub meshes
  98529. */
  98530. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  98531. private _tempRay;
  98532. /**
  98533. * Return the list of sub meshes intersecting with a given local ray
  98534. * @param mesh defines the mesh to find the submesh for
  98535. * @param localRay defines the ray in local space
  98536. * @returns the list of intersecting sub meshes
  98537. */
  98538. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  98539. /**
  98540. * Return the list of sub meshes colliding with a collider
  98541. * @param mesh defines the mesh to find the submesh for
  98542. * @param collider defines the collider to evaluate the collision against
  98543. * @returns the list of colliding sub meshes
  98544. */
  98545. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  98546. /**
  98547. * Rebuilds the elements related to this component in case of
  98548. * context lost for instance.
  98549. */
  98550. rebuild(): void;
  98551. /**
  98552. * Disposes the component and the associated ressources.
  98553. */
  98554. dispose(): void;
  98555. }
  98556. }
  98557. declare module BABYLON {
  98558. /**
  98559. * Class containing static functions to help procedurally build meshes
  98560. */
  98561. export class LinesBuilder {
  98562. /**
  98563. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  98564. * * 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
  98565. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  98566. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  98567. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  98568. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  98569. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  98570. * * 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
  98571. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  98572. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98573. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  98574. * @param name defines the name of the new line system
  98575. * @param options defines the options used to create the line system
  98576. * @param scene defines the hosting scene
  98577. * @returns a new line system mesh
  98578. */
  98579. static CreateLineSystem(name: string, options: {
  98580. lines: Vector3[][];
  98581. updatable?: boolean;
  98582. instance?: Nullable<LinesMesh>;
  98583. colors?: Nullable<Color4[][]>;
  98584. useVertexAlpha?: boolean;
  98585. }, scene: Nullable<Scene>): LinesMesh;
  98586. /**
  98587. * Creates a line mesh
  98588. * 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
  98589. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  98590. * * The parameter `points` is an array successive Vector3
  98591. * * 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
  98592. * * The optional parameter `colors` is an array of successive Color4, one per line point
  98593. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  98594. * * When updating an instance, remember that only point positions can change, not the number of points
  98595. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98596. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  98597. * @param name defines the name of the new line system
  98598. * @param options defines the options used to create the line system
  98599. * @param scene defines the hosting scene
  98600. * @returns a new line mesh
  98601. */
  98602. static CreateLines(name: string, options: {
  98603. points: Vector3[];
  98604. updatable?: boolean;
  98605. instance?: Nullable<LinesMesh>;
  98606. colors?: Color4[];
  98607. useVertexAlpha?: boolean;
  98608. }, scene?: Nullable<Scene>): LinesMesh;
  98609. /**
  98610. * Creates a dashed line mesh
  98611. * * 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
  98612. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  98613. * * The parameter `points` is an array successive Vector3
  98614. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  98615. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  98616. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  98617. * * 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
  98618. * * When updating an instance, remember that only point positions can change, not the number of points
  98619. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98620. * @param name defines the name of the mesh
  98621. * @param options defines the options used to create the mesh
  98622. * @param scene defines the hosting scene
  98623. * @returns the dashed line mesh
  98624. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  98625. */
  98626. static CreateDashedLines(name: string, options: {
  98627. points: Vector3[];
  98628. dashSize?: number;
  98629. gapSize?: number;
  98630. dashNb?: number;
  98631. updatable?: boolean;
  98632. instance?: LinesMesh;
  98633. }, scene?: Nullable<Scene>): LinesMesh;
  98634. }
  98635. }
  98636. declare module BABYLON {
  98637. /**
  98638. * Renders a layer on top of an existing scene
  98639. */
  98640. export class UtilityLayerRenderer implements IDisposable {
  98641. /** the original scene that will be rendered on top of */
  98642. originalScene: Scene;
  98643. private _pointerCaptures;
  98644. private _lastPointerEvents;
  98645. private static _DefaultUtilityLayer;
  98646. private static _DefaultKeepDepthUtilityLayer;
  98647. /**
  98648. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  98649. */
  98650. pickUtilitySceneFirst: boolean;
  98651. /**
  98652. * 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)
  98653. */
  98654. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  98655. /**
  98656. * 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)
  98657. */
  98658. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  98659. /**
  98660. * The scene that is rendered on top of the original scene
  98661. */
  98662. utilityLayerScene: Scene;
  98663. /**
  98664. * If the utility layer should automatically be rendered on top of existing scene
  98665. */
  98666. shouldRender: boolean;
  98667. /**
  98668. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  98669. */
  98670. onlyCheckPointerDownEvents: boolean;
  98671. /**
  98672. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  98673. */
  98674. processAllEvents: boolean;
  98675. /**
  98676. * Observable raised when the pointer move from the utility layer scene to the main scene
  98677. */
  98678. onPointerOutObservable: Observable<number>;
  98679. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  98680. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  98681. private _afterRenderObserver;
  98682. private _sceneDisposeObserver;
  98683. private _originalPointerObserver;
  98684. /**
  98685. * Instantiates a UtilityLayerRenderer
  98686. * @param originalScene the original scene that will be rendered on top of
  98687. * @param handleEvents boolean indicating if the utility layer should handle events
  98688. */
  98689. constructor(
  98690. /** the original scene that will be rendered on top of */
  98691. originalScene: Scene, handleEvents?: boolean);
  98692. private _notifyObservers;
  98693. /**
  98694. * Renders the utility layers scene on top of the original scene
  98695. */
  98696. render(): void;
  98697. /**
  98698. * Disposes of the renderer
  98699. */
  98700. dispose(): void;
  98701. private _updateCamera;
  98702. }
  98703. }
  98704. declare module BABYLON {
  98705. /**
  98706. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  98707. */
  98708. export class Gizmo implements IDisposable {
  98709. /** The utility layer the gizmo will be added to */
  98710. gizmoLayer: UtilityLayerRenderer;
  98711. /**
  98712. * The root mesh of the gizmo
  98713. */
  98714. _rootMesh: Mesh;
  98715. private _attachedMesh;
  98716. /**
  98717. * Ratio for the scale of the gizmo (Default: 1)
  98718. */
  98719. scaleRatio: number;
  98720. private _tmpMatrix;
  98721. /**
  98722. * If a custom mesh has been set (Default: false)
  98723. */
  98724. protected _customMeshSet: boolean;
  98725. /**
  98726. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  98727. * * When set, interactions will be enabled
  98728. */
  98729. attachedMesh: Nullable<AbstractMesh>;
  98730. /**
  98731. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  98732. * @param mesh The mesh to replace the default mesh of the gizmo
  98733. */
  98734. setCustomMesh(mesh: Mesh): void;
  98735. /**
  98736. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  98737. */
  98738. updateGizmoRotationToMatchAttachedMesh: boolean;
  98739. /**
  98740. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  98741. */
  98742. updateGizmoPositionToMatchAttachedMesh: boolean;
  98743. /**
  98744. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  98745. */
  98746. protected _updateScale: boolean;
  98747. protected _interactionsEnabled: boolean;
  98748. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  98749. private _beforeRenderObserver;
  98750. /**
  98751. * Creates a gizmo
  98752. * @param gizmoLayer The utility layer the gizmo will be added to
  98753. */
  98754. constructor(
  98755. /** The utility layer the gizmo will be added to */
  98756. gizmoLayer?: UtilityLayerRenderer);
  98757. private _tempVector;
  98758. /**
  98759. * @hidden
  98760. * Updates the gizmo to match the attached mesh's position/rotation
  98761. */
  98762. protected _update(): void;
  98763. /**
  98764. * Disposes of the gizmo
  98765. */
  98766. dispose(): void;
  98767. }
  98768. }
  98769. declare module BABYLON {
  98770. /**
  98771. * Single axis drag gizmo
  98772. */
  98773. export class AxisDragGizmo extends Gizmo {
  98774. /**
  98775. * Drag behavior responsible for the gizmos dragging interactions
  98776. */
  98777. dragBehavior: PointerDragBehavior;
  98778. private _pointerObserver;
  98779. /**
  98780. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  98781. */
  98782. snapDistance: number;
  98783. /**
  98784. * Event that fires each time the gizmo snaps to a new location.
  98785. * * snapDistance is the the change in distance
  98786. */
  98787. onSnapObservable: Observable<{
  98788. snapDistance: number;
  98789. }>;
  98790. /** @hidden */
  98791. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  98792. /** @hidden */
  98793. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  98794. /**
  98795. * Creates an AxisDragGizmo
  98796. * @param gizmoLayer The utility layer the gizmo will be added to
  98797. * @param dragAxis The axis which the gizmo will be able to drag on
  98798. * @param color The color of the gizmo
  98799. */
  98800. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  98801. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  98802. /**
  98803. * Disposes of the gizmo
  98804. */
  98805. dispose(): void;
  98806. }
  98807. }
  98808. declare module BABYLON.Debug {
  98809. /**
  98810. * The Axes viewer will show 3 axes in a specific point in space
  98811. */
  98812. export class AxesViewer {
  98813. private _xAxis;
  98814. private _yAxis;
  98815. private _zAxis;
  98816. private _scaleLinesFactor;
  98817. private _instanced;
  98818. /**
  98819. * Gets the hosting scene
  98820. */
  98821. scene: Scene;
  98822. /**
  98823. * Gets or sets a number used to scale line length
  98824. */
  98825. scaleLines: number;
  98826. /** Gets the node hierarchy used to render x-axis */
  98827. readonly xAxis: TransformNode;
  98828. /** Gets the node hierarchy used to render y-axis */
  98829. readonly yAxis: TransformNode;
  98830. /** Gets the node hierarchy used to render z-axis */
  98831. readonly zAxis: TransformNode;
  98832. /**
  98833. * Creates a new AxesViewer
  98834. * @param scene defines the hosting scene
  98835. * @param scaleLines defines a number used to scale line length (1 by default)
  98836. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  98837. * @param xAxis defines the node hierarchy used to render the x-axis
  98838. * @param yAxis defines the node hierarchy used to render the y-axis
  98839. * @param zAxis defines the node hierarchy used to render the z-axis
  98840. */
  98841. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  98842. /**
  98843. * Force the viewer to update
  98844. * @param position defines the position of the viewer
  98845. * @param xaxis defines the x axis of the viewer
  98846. * @param yaxis defines the y axis of the viewer
  98847. * @param zaxis defines the z axis of the viewer
  98848. */
  98849. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  98850. /**
  98851. * Creates an instance of this axes viewer.
  98852. * @returns a new axes viewer with instanced meshes
  98853. */
  98854. createInstance(): AxesViewer;
  98855. /** Releases resources */
  98856. dispose(): void;
  98857. private static _SetRenderingGroupId;
  98858. }
  98859. }
  98860. declare module BABYLON.Debug {
  98861. /**
  98862. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  98863. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  98864. */
  98865. export class BoneAxesViewer extends AxesViewer {
  98866. /**
  98867. * Gets or sets the target mesh where to display the axes viewer
  98868. */
  98869. mesh: Nullable<Mesh>;
  98870. /**
  98871. * Gets or sets the target bone where to display the axes viewer
  98872. */
  98873. bone: Nullable<Bone>;
  98874. /** Gets current position */
  98875. pos: Vector3;
  98876. /** Gets direction of X axis */
  98877. xaxis: Vector3;
  98878. /** Gets direction of Y axis */
  98879. yaxis: Vector3;
  98880. /** Gets direction of Z axis */
  98881. zaxis: Vector3;
  98882. /**
  98883. * Creates a new BoneAxesViewer
  98884. * @param scene defines the hosting scene
  98885. * @param bone defines the target bone
  98886. * @param mesh defines the target mesh
  98887. * @param scaleLines defines a scaling factor for line length (1 by default)
  98888. */
  98889. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  98890. /**
  98891. * Force the viewer to update
  98892. */
  98893. update(): void;
  98894. /** Releases resources */
  98895. dispose(): void;
  98896. }
  98897. }
  98898. declare module BABYLON {
  98899. /**
  98900. * Interface used to define scene explorer extensibility option
  98901. */
  98902. export interface IExplorerExtensibilityOption {
  98903. /**
  98904. * Define the option label
  98905. */
  98906. label: string;
  98907. /**
  98908. * Defines the action to execute on click
  98909. */
  98910. action: (entity: any) => void;
  98911. }
  98912. /**
  98913. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  98914. */
  98915. export interface IExplorerExtensibilityGroup {
  98916. /**
  98917. * Defines a predicate to test if a given type mut be extended
  98918. */
  98919. predicate: (entity: any) => boolean;
  98920. /**
  98921. * Gets the list of options added to a type
  98922. */
  98923. entries: IExplorerExtensibilityOption[];
  98924. }
  98925. /**
  98926. * Interface used to define the options to use to create the Inspector
  98927. */
  98928. export interface IInspectorOptions {
  98929. /**
  98930. * Display in overlay mode (default: false)
  98931. */
  98932. overlay?: boolean;
  98933. /**
  98934. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  98935. */
  98936. globalRoot?: HTMLElement;
  98937. /**
  98938. * Display the Scene explorer
  98939. */
  98940. showExplorer?: boolean;
  98941. /**
  98942. * Display the property inspector
  98943. */
  98944. showInspector?: boolean;
  98945. /**
  98946. * Display in embed mode (both panes on the right)
  98947. */
  98948. embedMode?: boolean;
  98949. /**
  98950. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  98951. */
  98952. handleResize?: boolean;
  98953. /**
  98954. * Allow the panes to popup (default: true)
  98955. */
  98956. enablePopup?: boolean;
  98957. /**
  98958. * Allow the panes to be closed by users (default: true)
  98959. */
  98960. enableClose?: boolean;
  98961. /**
  98962. * Optional list of extensibility entries
  98963. */
  98964. explorerExtensibility?: IExplorerExtensibilityGroup[];
  98965. /**
  98966. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  98967. */
  98968. inspectorURL?: string;
  98969. }
  98970. interface Scene {
  98971. /**
  98972. * @hidden
  98973. * Backing field
  98974. */
  98975. _debugLayer: DebugLayer;
  98976. /**
  98977. * Gets the debug layer (aka Inspector) associated with the scene
  98978. * @see http://doc.babylonjs.com/features/playground_debuglayer
  98979. */
  98980. debugLayer: DebugLayer;
  98981. }
  98982. /**
  98983. * The debug layer (aka Inspector) is the go to tool in order to better understand
  98984. * what is happening in your scene
  98985. * @see http://doc.babylonjs.com/features/playground_debuglayer
  98986. */
  98987. export class DebugLayer {
  98988. /**
  98989. * Define the url to get the inspector script from.
  98990. * By default it uses the babylonjs CDN.
  98991. * @ignoreNaming
  98992. */
  98993. static InspectorURL: string;
  98994. private _scene;
  98995. private BJSINSPECTOR;
  98996. /**
  98997. * Observable triggered when a property is changed through the inspector.
  98998. */
  98999. onPropertyChangedObservable: Observable<{
  99000. object: any;
  99001. property: string;
  99002. value: any;
  99003. initialValue: any;
  99004. }>;
  99005. /**
  99006. * Instantiates a new debug layer.
  99007. * The debug layer (aka Inspector) is the go to tool in order to better understand
  99008. * what is happening in your scene
  99009. * @see http://doc.babylonjs.com/features/playground_debuglayer
  99010. * @param scene Defines the scene to inspect
  99011. */
  99012. constructor(scene: Scene);
  99013. /** Creates the inspector window. */
  99014. private _createInspector;
  99015. /**
  99016. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  99017. * @param entity defines the entity to select
  99018. * @param lineContainerTitle defines the specific block to highlight
  99019. */
  99020. select(entity: any, lineContainerTitle?: string): void;
  99021. /** Get the inspector from bundle or global */
  99022. private _getGlobalInspector;
  99023. /**
  99024. * Get if the inspector is visible or not.
  99025. * @returns true if visible otherwise, false
  99026. */
  99027. isVisible(): boolean;
  99028. /**
  99029. * Hide the inspector and close its window.
  99030. */
  99031. hide(): void;
  99032. /**
  99033. * Launch the debugLayer.
  99034. * @param config Define the configuration of the inspector
  99035. * @return a promise fulfilled when the debug layer is visible
  99036. */
  99037. show(config?: IInspectorOptions): Promise<DebugLayer>;
  99038. }
  99039. }
  99040. declare module BABYLON {
  99041. /**
  99042. * Class containing static functions to help procedurally build meshes
  99043. */
  99044. export class BoxBuilder {
  99045. /**
  99046. * Creates a box mesh
  99047. * * The parameter `size` sets the size (float) of each box side (default 1)
  99048. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  99049. * * 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)
  99050. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  99051. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99052. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99053. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99054. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  99055. * @param name defines the name of the mesh
  99056. * @param options defines the options used to create the mesh
  99057. * @param scene defines the hosting scene
  99058. * @returns the box mesh
  99059. */
  99060. static CreateBox(name: string, options: {
  99061. size?: number;
  99062. width?: number;
  99063. height?: number;
  99064. depth?: number;
  99065. faceUV?: Vector4[];
  99066. faceColors?: Color4[];
  99067. sideOrientation?: number;
  99068. frontUVs?: Vector4;
  99069. backUVs?: Vector4;
  99070. updatable?: boolean;
  99071. }, scene?: Nullable<Scene>): Mesh;
  99072. }
  99073. }
  99074. declare module BABYLON {
  99075. /**
  99076. * Class containing static functions to help procedurally build meshes
  99077. */
  99078. export class SphereBuilder {
  99079. /**
  99080. * Creates a sphere mesh
  99081. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  99082. * * 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`)
  99083. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  99084. * * 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
  99085. * * 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)
  99086. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99087. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99088. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99089. * @param name defines the name of the mesh
  99090. * @param options defines the options used to create the mesh
  99091. * @param scene defines the hosting scene
  99092. * @returns the sphere mesh
  99093. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  99094. */
  99095. static CreateSphere(name: string, options: {
  99096. segments?: number;
  99097. diameter?: number;
  99098. diameterX?: number;
  99099. diameterY?: number;
  99100. diameterZ?: number;
  99101. arc?: number;
  99102. slice?: number;
  99103. sideOrientation?: number;
  99104. frontUVs?: Vector4;
  99105. backUVs?: Vector4;
  99106. updatable?: boolean;
  99107. }, scene: any): Mesh;
  99108. }
  99109. }
  99110. declare module BABYLON.Debug {
  99111. /**
  99112. * Used to show the physics impostor around the specific mesh
  99113. */
  99114. export class PhysicsViewer {
  99115. /** @hidden */
  99116. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  99117. /** @hidden */
  99118. protected _meshes: Array<Nullable<AbstractMesh>>;
  99119. /** @hidden */
  99120. protected _scene: Nullable<Scene>;
  99121. /** @hidden */
  99122. protected _numMeshes: number;
  99123. /** @hidden */
  99124. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  99125. private _renderFunction;
  99126. private _utilityLayer;
  99127. private _debugBoxMesh;
  99128. private _debugSphereMesh;
  99129. private _debugMaterial;
  99130. /**
  99131. * Creates a new PhysicsViewer
  99132. * @param scene defines the hosting scene
  99133. */
  99134. constructor(scene: Scene);
  99135. /** @hidden */
  99136. protected _updateDebugMeshes(): void;
  99137. /**
  99138. * Renders a specified physic impostor
  99139. * @param impostor defines the impostor to render
  99140. * @returns the new debug mesh used to render the impostor
  99141. */
  99142. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  99143. /**
  99144. * Hides a specified physic impostor
  99145. * @param impostor defines the impostor to hide
  99146. */
  99147. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  99148. private _getDebugMaterial;
  99149. private _getDebugBoxMesh;
  99150. private _getDebugSphereMesh;
  99151. private _getDebugMesh;
  99152. /** Releases all resources */
  99153. dispose(): void;
  99154. }
  99155. }
  99156. declare module BABYLON {
  99157. /**
  99158. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  99159. * in order to better appreciate the issue one might have.
  99160. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  99161. */
  99162. export class RayHelper {
  99163. /**
  99164. * Defines the ray we are currently tryin to visualize.
  99165. */
  99166. ray: Nullable<Ray>;
  99167. private _renderPoints;
  99168. private _renderLine;
  99169. private _renderFunction;
  99170. private _scene;
  99171. private _updateToMeshFunction;
  99172. private _attachedToMesh;
  99173. private _meshSpaceDirection;
  99174. private _meshSpaceOrigin;
  99175. /**
  99176. * Helper function to create a colored helper in a scene in one line.
  99177. * @param ray Defines the ray we are currently tryin to visualize
  99178. * @param scene Defines the scene the ray is used in
  99179. * @param color Defines the color we want to see the ray in
  99180. * @returns The newly created ray helper.
  99181. */
  99182. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  99183. /**
  99184. * Instantiate a new ray helper.
  99185. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  99186. * in order to better appreciate the issue one might have.
  99187. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  99188. * @param ray Defines the ray we are currently tryin to visualize
  99189. */
  99190. constructor(ray: Ray);
  99191. /**
  99192. * Shows the ray we are willing to debug.
  99193. * @param scene Defines the scene the ray needs to be rendered in
  99194. * @param color Defines the color the ray needs to be rendered in
  99195. */
  99196. show(scene: Scene, color?: Color3): void;
  99197. /**
  99198. * Hides the ray we are debugging.
  99199. */
  99200. hide(): void;
  99201. private _render;
  99202. /**
  99203. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  99204. * @param mesh Defines the mesh we want the helper attached to
  99205. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  99206. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  99207. * @param length Defines the length of the ray
  99208. */
  99209. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  99210. /**
  99211. * Detach the ray helper from the mesh it has previously been attached to.
  99212. */
  99213. detachFromMesh(): void;
  99214. private _updateToMesh;
  99215. /**
  99216. * Dispose the helper and release its associated resources.
  99217. */
  99218. dispose(): void;
  99219. }
  99220. }
  99221. declare module BABYLON.Debug {
  99222. /**
  99223. * Class used to render a debug view of a given skeleton
  99224. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  99225. */
  99226. export class SkeletonViewer {
  99227. /** defines the skeleton to render */
  99228. skeleton: Skeleton;
  99229. /** defines the mesh attached to the skeleton */
  99230. mesh: AbstractMesh;
  99231. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  99232. autoUpdateBonesMatrices: boolean;
  99233. /** defines the rendering group id to use with the viewer */
  99234. renderingGroupId: number;
  99235. /** Gets or sets the color used to render the skeleton */
  99236. color: Color3;
  99237. private _scene;
  99238. private _debugLines;
  99239. private _debugMesh;
  99240. private _isEnabled;
  99241. private _renderFunction;
  99242. private _utilityLayer;
  99243. /**
  99244. * Returns the mesh used to render the bones
  99245. */
  99246. readonly debugMesh: Nullable<LinesMesh>;
  99247. /**
  99248. * Creates a new SkeletonViewer
  99249. * @param skeleton defines the skeleton to render
  99250. * @param mesh defines the mesh attached to the skeleton
  99251. * @param scene defines the hosting scene
  99252. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  99253. * @param renderingGroupId defines the rendering group id to use with the viewer
  99254. */
  99255. constructor(
  99256. /** defines the skeleton to render */
  99257. skeleton: Skeleton,
  99258. /** defines the mesh attached to the skeleton */
  99259. mesh: AbstractMesh, scene: Scene,
  99260. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  99261. autoUpdateBonesMatrices?: boolean,
  99262. /** defines the rendering group id to use with the viewer */
  99263. renderingGroupId?: number);
  99264. /** Gets or sets a boolean indicating if the viewer is enabled */
  99265. isEnabled: boolean;
  99266. private _getBonePosition;
  99267. private _getLinesForBonesWithLength;
  99268. private _getLinesForBonesNoLength;
  99269. /** Update the viewer to sync with current skeleton state */
  99270. update(): void;
  99271. /** Release associated resources */
  99272. dispose(): void;
  99273. }
  99274. }
  99275. declare module BABYLON {
  99276. /**
  99277. * Options to create the null engine
  99278. */
  99279. export class NullEngineOptions {
  99280. /**
  99281. * Render width (Default: 512)
  99282. */
  99283. renderWidth: number;
  99284. /**
  99285. * Render height (Default: 256)
  99286. */
  99287. renderHeight: number;
  99288. /**
  99289. * Texture size (Default: 512)
  99290. */
  99291. textureSize: number;
  99292. /**
  99293. * If delta time between frames should be constant
  99294. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99295. */
  99296. deterministicLockstep: boolean;
  99297. /**
  99298. * Maximum about of steps between frames (Default: 4)
  99299. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99300. */
  99301. lockstepMaxSteps: number;
  99302. }
  99303. /**
  99304. * The null engine class provides support for headless version of babylon.js.
  99305. * This can be used in server side scenario or for testing purposes
  99306. */
  99307. export class NullEngine extends Engine {
  99308. private _options;
  99309. /**
  99310. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99311. */
  99312. isDeterministicLockStep(): boolean;
  99313. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  99314. getLockstepMaxSteps(): number;
  99315. /**
  99316. * Sets hardware scaling, used to save performance if needed
  99317. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  99318. */
  99319. getHardwareScalingLevel(): number;
  99320. constructor(options?: NullEngineOptions);
  99321. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  99322. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  99323. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  99324. getRenderWidth(useScreen?: boolean): number;
  99325. getRenderHeight(useScreen?: boolean): number;
  99326. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  99327. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  99328. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  99329. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  99330. bindSamplers(effect: Effect): void;
  99331. enableEffect(effect: Effect): void;
  99332. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  99333. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  99334. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  99335. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  99336. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  99337. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  99338. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  99339. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  99340. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  99341. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  99342. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  99343. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  99344. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  99345. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  99346. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  99347. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  99348. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  99349. setFloat(uniform: WebGLUniformLocation, value: number): void;
  99350. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  99351. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  99352. setBool(uniform: WebGLUniformLocation, bool: number): void;
  99353. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  99354. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  99355. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  99356. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  99357. bindBuffers(vertexBuffers: {
  99358. [key: string]: VertexBuffer;
  99359. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  99360. wipeCaches(bruteForce?: boolean): void;
  99361. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  99362. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  99363. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  99364. /** @hidden */
  99365. _createTexture(): WebGLTexture;
  99366. /** @hidden */
  99367. _releaseTexture(texture: InternalTexture): void;
  99368. 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;
  99369. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  99370. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  99371. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  99372. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  99373. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  99374. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  99375. areAllEffectsReady(): boolean;
  99376. /**
  99377. * @hidden
  99378. * Get the current error code of the webGL context
  99379. * @returns the error code
  99380. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  99381. */
  99382. getError(): number;
  99383. /** @hidden */
  99384. _getUnpackAlignement(): number;
  99385. /** @hidden */
  99386. _unpackFlipY(value: boolean): void;
  99387. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  99388. /**
  99389. * Updates a dynamic vertex buffer.
  99390. * @param vertexBuffer the vertex buffer to update
  99391. * @param data the data used to update the vertex buffer
  99392. * @param byteOffset the byte offset of the data (optional)
  99393. * @param byteLength the byte length of the data (optional)
  99394. */
  99395. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  99396. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  99397. /** @hidden */
  99398. _bindTexture(channel: number, texture: InternalTexture): void;
  99399. /** @hidden */
  99400. _releaseBuffer(buffer: WebGLBuffer): boolean;
  99401. releaseEffects(): void;
  99402. displayLoadingUI(): void;
  99403. hideLoadingUI(): void;
  99404. /** @hidden */
  99405. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  99406. /** @hidden */
  99407. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  99408. /** @hidden */
  99409. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  99410. /** @hidden */
  99411. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  99412. }
  99413. }
  99414. declare module BABYLON {
  99415. /** @hidden */
  99416. export class _OcclusionDataStorage {
  99417. /** @hidden */
  99418. occlusionInternalRetryCounter: number;
  99419. /** @hidden */
  99420. isOcclusionQueryInProgress: boolean;
  99421. /** @hidden */
  99422. isOccluded: boolean;
  99423. /** @hidden */
  99424. occlusionRetryCount: number;
  99425. /** @hidden */
  99426. occlusionType: number;
  99427. /** @hidden */
  99428. occlusionQueryAlgorithmType: number;
  99429. }
  99430. interface Engine {
  99431. /**
  99432. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  99433. * @return the new query
  99434. */
  99435. createQuery(): WebGLQuery;
  99436. /**
  99437. * Delete and release a webGL query
  99438. * @param query defines the query to delete
  99439. * @return the current engine
  99440. */
  99441. deleteQuery(query: WebGLQuery): Engine;
  99442. /**
  99443. * Check if a given query has resolved and got its value
  99444. * @param query defines the query to check
  99445. * @returns true if the query got its value
  99446. */
  99447. isQueryResultAvailable(query: WebGLQuery): boolean;
  99448. /**
  99449. * Gets the value of a given query
  99450. * @param query defines the query to check
  99451. * @returns the value of the query
  99452. */
  99453. getQueryResult(query: WebGLQuery): number;
  99454. /**
  99455. * Initiates an occlusion query
  99456. * @param algorithmType defines the algorithm to use
  99457. * @param query defines the query to use
  99458. * @returns the current engine
  99459. * @see http://doc.babylonjs.com/features/occlusionquery
  99460. */
  99461. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  99462. /**
  99463. * Ends an occlusion query
  99464. * @see http://doc.babylonjs.com/features/occlusionquery
  99465. * @param algorithmType defines the algorithm to use
  99466. * @returns the current engine
  99467. */
  99468. endOcclusionQuery(algorithmType: number): Engine;
  99469. /**
  99470. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  99471. * Please note that only one query can be issued at a time
  99472. * @returns a time token used to track the time span
  99473. */
  99474. startTimeQuery(): Nullable<_TimeToken>;
  99475. /**
  99476. * Ends a time query
  99477. * @param token defines the token used to measure the time span
  99478. * @returns the time spent (in ns)
  99479. */
  99480. endTimeQuery(token: _TimeToken): int;
  99481. /** @hidden */
  99482. _currentNonTimestampToken: Nullable<_TimeToken>;
  99483. /** @hidden */
  99484. _createTimeQuery(): WebGLQuery;
  99485. /** @hidden */
  99486. _deleteTimeQuery(query: WebGLQuery): void;
  99487. /** @hidden */
  99488. _getGlAlgorithmType(algorithmType: number): number;
  99489. /** @hidden */
  99490. _getTimeQueryResult(query: WebGLQuery): any;
  99491. /** @hidden */
  99492. _getTimeQueryAvailability(query: WebGLQuery): any;
  99493. }
  99494. interface AbstractMesh {
  99495. /**
  99496. * Backing filed
  99497. * @hidden
  99498. */
  99499. __occlusionDataStorage: _OcclusionDataStorage;
  99500. /**
  99501. * Access property
  99502. * @hidden
  99503. */
  99504. _occlusionDataStorage: _OcclusionDataStorage;
  99505. /**
  99506. * 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.
  99507. * The default value is -1 which means don't break the query and wait till the result
  99508. * @see http://doc.babylonjs.com/features/occlusionquery
  99509. */
  99510. occlusionRetryCount: number;
  99511. /**
  99512. * 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:
  99513. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  99514. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  99515. * * 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.
  99516. * @see http://doc.babylonjs.com/features/occlusionquery
  99517. */
  99518. occlusionType: number;
  99519. /**
  99520. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  99521. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  99522. * * 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.
  99523. * @see http://doc.babylonjs.com/features/occlusionquery
  99524. */
  99525. occlusionQueryAlgorithmType: number;
  99526. /**
  99527. * 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
  99528. * @see http://doc.babylonjs.com/features/occlusionquery
  99529. */
  99530. isOccluded: boolean;
  99531. /**
  99532. * Flag to check the progress status of the query
  99533. * @see http://doc.babylonjs.com/features/occlusionquery
  99534. */
  99535. isOcclusionQueryInProgress: boolean;
  99536. }
  99537. }
  99538. declare module BABYLON {
  99539. /** @hidden */
  99540. export var _forceTransformFeedbackToBundle: boolean;
  99541. interface Engine {
  99542. /**
  99543. * Creates a webGL transform feedback object
  99544. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  99545. * @returns the webGL transform feedback object
  99546. */
  99547. createTransformFeedback(): WebGLTransformFeedback;
  99548. /**
  99549. * Delete a webGL transform feedback object
  99550. * @param value defines the webGL transform feedback object to delete
  99551. */
  99552. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  99553. /**
  99554. * Bind a webGL transform feedback object to the webgl context
  99555. * @param value defines the webGL transform feedback object to bind
  99556. */
  99557. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  99558. /**
  99559. * Begins a transform feedback operation
  99560. * @param usePoints defines if points or triangles must be used
  99561. */
  99562. beginTransformFeedback(usePoints: boolean): void;
  99563. /**
  99564. * Ends a transform feedback operation
  99565. */
  99566. endTransformFeedback(): void;
  99567. /**
  99568. * Specify the varyings to use with transform feedback
  99569. * @param program defines the associated webGL program
  99570. * @param value defines the list of strings representing the varying names
  99571. */
  99572. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  99573. /**
  99574. * Bind a webGL buffer for a transform feedback operation
  99575. * @param value defines the webGL buffer to bind
  99576. */
  99577. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  99578. }
  99579. }
  99580. declare module BABYLON {
  99581. /**
  99582. * Gather the list of clipboard event types as constants.
  99583. */
  99584. export class ClipboardEventTypes {
  99585. /**
  99586. * The clipboard event is fired when a copy command is active (pressed).
  99587. */
  99588. static readonly COPY: number;
  99589. /**
  99590. * The clipboard event is fired when a cut command is active (pressed).
  99591. */
  99592. static readonly CUT: number;
  99593. /**
  99594. * The clipboard event is fired when a paste command is active (pressed).
  99595. */
  99596. static readonly PASTE: number;
  99597. }
  99598. /**
  99599. * This class is used to store clipboard related info for the onClipboardObservable event.
  99600. */
  99601. export class ClipboardInfo {
  99602. /**
  99603. * Defines the type of event (BABYLON.ClipboardEventTypes)
  99604. */
  99605. type: number;
  99606. /**
  99607. * Defines the related dom event
  99608. */
  99609. event: ClipboardEvent;
  99610. /**
  99611. *Creates an instance of ClipboardInfo.
  99612. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  99613. * @param event Defines the related dom event
  99614. */
  99615. constructor(
  99616. /**
  99617. * Defines the type of event (BABYLON.ClipboardEventTypes)
  99618. */
  99619. type: number,
  99620. /**
  99621. * Defines the related dom event
  99622. */
  99623. event: ClipboardEvent);
  99624. /**
  99625. * Get the clipboard event's type from the keycode.
  99626. * @param keyCode Defines the keyCode for the current keyboard event.
  99627. * @return {number}
  99628. */
  99629. static GetTypeFromCharacter(keyCode: number): number;
  99630. }
  99631. }
  99632. declare module BABYLON {
  99633. /**
  99634. * Class used to represent data loading progression
  99635. */
  99636. export class SceneLoaderProgressEvent {
  99637. /** defines if data length to load can be evaluated */
  99638. readonly lengthComputable: boolean;
  99639. /** defines the loaded data length */
  99640. readonly loaded: number;
  99641. /** defines the data length to load */
  99642. readonly total: number;
  99643. /**
  99644. * Create a new progress event
  99645. * @param lengthComputable defines if data length to load can be evaluated
  99646. * @param loaded defines the loaded data length
  99647. * @param total defines the data length to load
  99648. */
  99649. constructor(
  99650. /** defines if data length to load can be evaluated */
  99651. lengthComputable: boolean,
  99652. /** defines the loaded data length */
  99653. loaded: number,
  99654. /** defines the data length to load */
  99655. total: number);
  99656. /**
  99657. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  99658. * @param event defines the source event
  99659. * @returns a new SceneLoaderProgressEvent
  99660. */
  99661. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  99662. }
  99663. /**
  99664. * Interface used by SceneLoader plugins to define supported file extensions
  99665. */
  99666. export interface ISceneLoaderPluginExtensions {
  99667. /**
  99668. * Defines the list of supported extensions
  99669. */
  99670. [extension: string]: {
  99671. isBinary: boolean;
  99672. };
  99673. }
  99674. /**
  99675. * Interface used by SceneLoader plugin factory
  99676. */
  99677. export interface ISceneLoaderPluginFactory {
  99678. /**
  99679. * Defines the name of the factory
  99680. */
  99681. name: string;
  99682. /**
  99683. * Function called to create a new plugin
  99684. * @return the new plugin
  99685. */
  99686. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  99687. /**
  99688. * Boolean indicating if the plugin can direct load specific data
  99689. */
  99690. canDirectLoad?: (data: string) => boolean;
  99691. }
  99692. /**
  99693. * Interface used to define a SceneLoader plugin
  99694. */
  99695. export interface ISceneLoaderPlugin {
  99696. /**
  99697. * The friendly name of this plugin.
  99698. */
  99699. name: string;
  99700. /**
  99701. * The file extensions supported by this plugin.
  99702. */
  99703. extensions: string | ISceneLoaderPluginExtensions;
  99704. /**
  99705. * Import meshes into a scene.
  99706. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  99707. * @param scene The scene to import into
  99708. * @param data The data to import
  99709. * @param rootUrl The root url for scene and resources
  99710. * @param meshes The meshes array to import into
  99711. * @param particleSystems The particle systems array to import into
  99712. * @param skeletons The skeletons array to import into
  99713. * @param onError The callback when import fails
  99714. * @returns True if successful or false otherwise
  99715. */
  99716. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  99717. /**
  99718. * Load into a scene.
  99719. * @param scene The scene to load into
  99720. * @param data The data to import
  99721. * @param rootUrl The root url for scene and resources
  99722. * @param onError The callback when import fails
  99723. * @returns true if successful or false otherwise
  99724. */
  99725. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  99726. /**
  99727. * The callback that returns true if the data can be directly loaded.
  99728. */
  99729. canDirectLoad?: (data: string) => boolean;
  99730. /**
  99731. * The callback that allows custom handling of the root url based on the response url.
  99732. */
  99733. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  99734. /**
  99735. * Load into an asset container.
  99736. * @param scene The scene to load into
  99737. * @param data The data to import
  99738. * @param rootUrl The root url for scene and resources
  99739. * @param onError The callback when import fails
  99740. * @returns The loaded asset container
  99741. */
  99742. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  99743. }
  99744. /**
  99745. * Interface used to define an async SceneLoader plugin
  99746. */
  99747. export interface ISceneLoaderPluginAsync {
  99748. /**
  99749. * The friendly name of this plugin.
  99750. */
  99751. name: string;
  99752. /**
  99753. * The file extensions supported by this plugin.
  99754. */
  99755. extensions: string | ISceneLoaderPluginExtensions;
  99756. /**
  99757. * Import meshes into a scene.
  99758. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  99759. * @param scene The scene to import into
  99760. * @param data The data to import
  99761. * @param rootUrl The root url for scene and resources
  99762. * @param onProgress The callback when the load progresses
  99763. * @param fileName Defines the name of the file to load
  99764. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  99765. */
  99766. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  99767. meshes: AbstractMesh[];
  99768. particleSystems: IParticleSystem[];
  99769. skeletons: Skeleton[];
  99770. animationGroups: AnimationGroup[];
  99771. }>;
  99772. /**
  99773. * Load into a scene.
  99774. * @param scene The scene to load into
  99775. * @param data The data to import
  99776. * @param rootUrl The root url for scene and resources
  99777. * @param onProgress The callback when the load progresses
  99778. * @param fileName Defines the name of the file to load
  99779. * @returns Nothing
  99780. */
  99781. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  99782. /**
  99783. * The callback that returns true if the data can be directly loaded.
  99784. */
  99785. canDirectLoad?: (data: string) => boolean;
  99786. /**
  99787. * The callback that allows custom handling of the root url based on the response url.
  99788. */
  99789. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  99790. /**
  99791. * Load into an asset container.
  99792. * @param scene The scene to load into
  99793. * @param data The data to import
  99794. * @param rootUrl The root url for scene and resources
  99795. * @param onProgress The callback when the load progresses
  99796. * @param fileName Defines the name of the file to load
  99797. * @returns The loaded asset container
  99798. */
  99799. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  99800. }
  99801. /**
  99802. * Class used to load scene from various file formats using registered plugins
  99803. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  99804. */
  99805. export class SceneLoader {
  99806. /**
  99807. * No logging while loading
  99808. */
  99809. static readonly NO_LOGGING: number;
  99810. /**
  99811. * Minimal logging while loading
  99812. */
  99813. static readonly MINIMAL_LOGGING: number;
  99814. /**
  99815. * Summary logging while loading
  99816. */
  99817. static readonly SUMMARY_LOGGING: number;
  99818. /**
  99819. * Detailled logging while loading
  99820. */
  99821. static readonly DETAILED_LOGGING: number;
  99822. /**
  99823. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  99824. */
  99825. static ForceFullSceneLoadingForIncremental: boolean;
  99826. /**
  99827. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  99828. */
  99829. static ShowLoadingScreen: boolean;
  99830. /**
  99831. * Defines the current logging level (while loading the scene)
  99832. * @ignorenaming
  99833. */
  99834. static loggingLevel: number;
  99835. /**
  99836. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  99837. */
  99838. static CleanBoneMatrixWeights: boolean;
  99839. /**
  99840. * Event raised when a plugin is used to load a scene
  99841. */
  99842. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  99843. private static _registeredPlugins;
  99844. private static _getDefaultPlugin;
  99845. private static _getPluginForExtension;
  99846. private static _getPluginForDirectLoad;
  99847. private static _getPluginForFilename;
  99848. private static _getDirectLoad;
  99849. private static _loadData;
  99850. private static _getFileInfo;
  99851. /**
  99852. * Gets a plugin that can load the given extension
  99853. * @param extension defines the extension to load
  99854. * @returns a plugin or null if none works
  99855. */
  99856. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  99857. /**
  99858. * Gets a boolean indicating that the given extension can be loaded
  99859. * @param extension defines the extension to load
  99860. * @returns true if the extension is supported
  99861. */
  99862. static IsPluginForExtensionAvailable(extension: string): boolean;
  99863. /**
  99864. * Adds a new plugin to the list of registered plugins
  99865. * @param plugin defines the plugin to add
  99866. */
  99867. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  99868. /**
  99869. * Import meshes into a scene
  99870. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  99871. * @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)
  99872. * @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)
  99873. * @param scene the instance of BABYLON.Scene to append to
  99874. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  99875. * @param onProgress a callback with a progress event for each file being loaded
  99876. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  99877. * @param pluginExtension the extension used to determine the plugin
  99878. * @returns The loaded plugin
  99879. */
  99880. 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>;
  99881. /**
  99882. * Import meshes into a scene
  99883. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  99884. * @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)
  99885. * @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)
  99886. * @param scene the instance of BABYLON.Scene to append to
  99887. * @param onProgress a callback with a progress event for each file being loaded
  99888. * @param pluginExtension the extension used to determine the plugin
  99889. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  99890. */
  99891. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  99892. meshes: AbstractMesh[];
  99893. particleSystems: IParticleSystem[];
  99894. skeletons: Skeleton[];
  99895. animationGroups: AnimationGroup[];
  99896. }>;
  99897. /**
  99898. * Load a scene
  99899. * @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)
  99900. * @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)
  99901. * @param engine is the instance of BABYLON.Engine to use to create the scene
  99902. * @param onSuccess a callback with the scene when import succeeds
  99903. * @param onProgress a callback with a progress event for each file being loaded
  99904. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  99905. * @param pluginExtension the extension used to determine the plugin
  99906. * @returns The loaded plugin
  99907. */
  99908. 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>;
  99909. /**
  99910. * Load a scene
  99911. * @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)
  99912. * @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)
  99913. * @param engine is the instance of BABYLON.Engine to use to create the scene
  99914. * @param onProgress a callback with a progress event for each file being loaded
  99915. * @param pluginExtension the extension used to determine the plugin
  99916. * @returns The loaded scene
  99917. */
  99918. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  99919. /**
  99920. * Append a scene
  99921. * @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)
  99922. * @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)
  99923. * @param scene is the instance of BABYLON.Scene to append to
  99924. * @param onSuccess a callback with the scene when import succeeds
  99925. * @param onProgress a callback with a progress event for each file being loaded
  99926. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  99927. * @param pluginExtension the extension used to determine the plugin
  99928. * @returns The loaded plugin
  99929. */
  99930. 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>;
  99931. /**
  99932. * Append a scene
  99933. * @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)
  99934. * @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)
  99935. * @param scene is the instance of BABYLON.Scene to append to
  99936. * @param onProgress a callback with a progress event for each file being loaded
  99937. * @param pluginExtension the extension used to determine the plugin
  99938. * @returns The given scene
  99939. */
  99940. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  99941. /**
  99942. * Load a scene into an asset container
  99943. * @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)
  99944. * @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)
  99945. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  99946. * @param onSuccess a callback with the scene when import succeeds
  99947. * @param onProgress a callback with a progress event for each file being loaded
  99948. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  99949. * @param pluginExtension the extension used to determine the plugin
  99950. * @returns The loaded plugin
  99951. */
  99952. 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>;
  99953. /**
  99954. * Load a scene into an asset container
  99955. * @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)
  99956. * @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)
  99957. * @param scene is the instance of Scene to append to
  99958. * @param onProgress a callback with a progress event for each file being loaded
  99959. * @param pluginExtension the extension used to determine the plugin
  99960. * @returns The loaded asset container
  99961. */
  99962. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  99963. }
  99964. }
  99965. declare module BABYLON {
  99966. /**
  99967. * Google Daydream controller
  99968. */
  99969. export class DaydreamController extends WebVRController {
  99970. /**
  99971. * Base Url for the controller model.
  99972. */
  99973. static MODEL_BASE_URL: string;
  99974. /**
  99975. * File name for the controller model.
  99976. */
  99977. static MODEL_FILENAME: string;
  99978. /**
  99979. * Gamepad Id prefix used to identify Daydream Controller.
  99980. */
  99981. static readonly GAMEPAD_ID_PREFIX: string;
  99982. /**
  99983. * Creates a new DaydreamController from a gamepad
  99984. * @param vrGamepad the gamepad that the controller should be created from
  99985. */
  99986. constructor(vrGamepad: any);
  99987. /**
  99988. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  99989. * @param scene scene in which to add meshes
  99990. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  99991. */
  99992. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  99993. /**
  99994. * Called once for each button that changed state since the last frame
  99995. * @param buttonIdx Which button index changed
  99996. * @param state New state of the button
  99997. * @param changes Which properties on the state changed since last frame
  99998. */
  99999. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100000. }
  100001. }
  100002. declare module BABYLON {
  100003. /**
  100004. * Gear VR Controller
  100005. */
  100006. export class GearVRController extends WebVRController {
  100007. /**
  100008. * Base Url for the controller model.
  100009. */
  100010. static MODEL_BASE_URL: string;
  100011. /**
  100012. * File name for the controller model.
  100013. */
  100014. static MODEL_FILENAME: string;
  100015. /**
  100016. * Gamepad Id prefix used to identify this controller.
  100017. */
  100018. static readonly GAMEPAD_ID_PREFIX: string;
  100019. private readonly _buttonIndexToObservableNameMap;
  100020. /**
  100021. * Creates a new GearVRController from a gamepad
  100022. * @param vrGamepad the gamepad that the controller should be created from
  100023. */
  100024. constructor(vrGamepad: any);
  100025. /**
  100026. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  100027. * @param scene scene in which to add meshes
  100028. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  100029. */
  100030. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100031. /**
  100032. * Called once for each button that changed state since the last frame
  100033. * @param buttonIdx Which button index changed
  100034. * @param state New state of the button
  100035. * @param changes Which properties on the state changed since last frame
  100036. */
  100037. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100038. }
  100039. }
  100040. declare module BABYLON {
  100041. /**
  100042. * Generic Controller
  100043. */
  100044. export class GenericController extends WebVRController {
  100045. /**
  100046. * Base Url for the controller model.
  100047. */
  100048. static readonly MODEL_BASE_URL: string;
  100049. /**
  100050. * File name for the controller model.
  100051. */
  100052. static readonly MODEL_FILENAME: string;
  100053. /**
  100054. * Creates a new GenericController from a gamepad
  100055. * @param vrGamepad the gamepad that the controller should be created from
  100056. */
  100057. constructor(vrGamepad: any);
  100058. /**
  100059. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  100060. * @param scene scene in which to add meshes
  100061. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  100062. */
  100063. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100064. /**
  100065. * Called once for each button that changed state since the last frame
  100066. * @param buttonIdx Which button index changed
  100067. * @param state New state of the button
  100068. * @param changes Which properties on the state changed since last frame
  100069. */
  100070. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100071. }
  100072. }
  100073. declare module BABYLON {
  100074. /**
  100075. * Oculus Touch Controller
  100076. */
  100077. export class OculusTouchController extends WebVRController {
  100078. /**
  100079. * Base Url for the controller model.
  100080. */
  100081. static MODEL_BASE_URL: string;
  100082. /**
  100083. * File name for the left controller model.
  100084. */
  100085. static MODEL_LEFT_FILENAME: string;
  100086. /**
  100087. * File name for the right controller model.
  100088. */
  100089. static MODEL_RIGHT_FILENAME: string;
  100090. /**
  100091. * Fired when the secondary trigger on this controller is modified
  100092. */
  100093. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  100094. /**
  100095. * Fired when the thumb rest on this controller is modified
  100096. */
  100097. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  100098. /**
  100099. * Creates a new OculusTouchController from a gamepad
  100100. * @param vrGamepad the gamepad that the controller should be created from
  100101. */
  100102. constructor(vrGamepad: any);
  100103. /**
  100104. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  100105. * @param scene scene in which to add meshes
  100106. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  100107. */
  100108. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100109. /**
  100110. * Fired when the A button on this controller is modified
  100111. */
  100112. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100113. /**
  100114. * Fired when the B button on this controller is modified
  100115. */
  100116. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100117. /**
  100118. * Fired when the X button on this controller is modified
  100119. */
  100120. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100121. /**
  100122. * Fired when the Y button on this controller is modified
  100123. */
  100124. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100125. /**
  100126. * Called once for each button that changed state since the last frame
  100127. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  100128. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  100129. * 2) secondary trigger (same)
  100130. * 3) A (right) X (left), touch, pressed = value
  100131. * 4) B / Y
  100132. * 5) thumb rest
  100133. * @param buttonIdx Which button index changed
  100134. * @param state New state of the button
  100135. * @param changes Which properties on the state changed since last frame
  100136. */
  100137. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100138. }
  100139. }
  100140. declare module BABYLON {
  100141. /**
  100142. * Vive Controller
  100143. */
  100144. export class ViveController extends WebVRController {
  100145. /**
  100146. * Base Url for the controller model.
  100147. */
  100148. static MODEL_BASE_URL: string;
  100149. /**
  100150. * File name for the controller model.
  100151. */
  100152. static MODEL_FILENAME: string;
  100153. /**
  100154. * Creates a new ViveController from a gamepad
  100155. * @param vrGamepad the gamepad that the controller should be created from
  100156. */
  100157. constructor(vrGamepad: any);
  100158. /**
  100159. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  100160. * @param scene scene in which to add meshes
  100161. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  100162. */
  100163. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100164. /**
  100165. * Fired when the left button on this controller is modified
  100166. */
  100167. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100168. /**
  100169. * Fired when the right button on this controller is modified
  100170. */
  100171. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100172. /**
  100173. * Fired when the menu button on this controller is modified
  100174. */
  100175. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100176. /**
  100177. * Called once for each button that changed state since the last frame
  100178. * Vive mapping:
  100179. * 0: touchpad
  100180. * 1: trigger
  100181. * 2: left AND right buttons
  100182. * 3: menu button
  100183. * @param buttonIdx Which button index changed
  100184. * @param state New state of the button
  100185. * @param changes Which properties on the state changed since last frame
  100186. */
  100187. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100188. }
  100189. }
  100190. declare module BABYLON {
  100191. /**
  100192. * Defines the WindowsMotionController object that the state of the windows motion controller
  100193. */
  100194. export class WindowsMotionController extends WebVRController {
  100195. /**
  100196. * The base url used to load the left and right controller models
  100197. */
  100198. static MODEL_BASE_URL: string;
  100199. /**
  100200. * The name of the left controller model file
  100201. */
  100202. static MODEL_LEFT_FILENAME: string;
  100203. /**
  100204. * The name of the right controller model file
  100205. */
  100206. static MODEL_RIGHT_FILENAME: string;
  100207. /**
  100208. * The controller name prefix for this controller type
  100209. */
  100210. static readonly GAMEPAD_ID_PREFIX: string;
  100211. /**
  100212. * The controller id pattern for this controller type
  100213. */
  100214. private static readonly GAMEPAD_ID_PATTERN;
  100215. private _loadedMeshInfo;
  100216. private readonly _mapping;
  100217. /**
  100218. * Fired when the trackpad on this controller is clicked
  100219. */
  100220. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  100221. /**
  100222. * Fired when the trackpad on this controller is modified
  100223. */
  100224. onTrackpadValuesChangedObservable: Observable<StickValues>;
  100225. /**
  100226. * The current x and y values of this controller's trackpad
  100227. */
  100228. trackpad: StickValues;
  100229. /**
  100230. * Creates a new WindowsMotionController from a gamepad
  100231. * @param vrGamepad the gamepad that the controller should be created from
  100232. */
  100233. constructor(vrGamepad: any);
  100234. /**
  100235. * Fired when the trigger on this controller is modified
  100236. */
  100237. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100238. /**
  100239. * Fired when the menu button on this controller is modified
  100240. */
  100241. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100242. /**
  100243. * Fired when the grip button on this controller is modified
  100244. */
  100245. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100246. /**
  100247. * Fired when the thumbstick button on this controller is modified
  100248. */
  100249. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100250. /**
  100251. * Fired when the touchpad button on this controller is modified
  100252. */
  100253. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100254. /**
  100255. * Fired when the touchpad values on this controller are modified
  100256. */
  100257. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  100258. private _updateTrackpad;
  100259. /**
  100260. * Called once per frame by the engine.
  100261. */
  100262. update(): void;
  100263. /**
  100264. * Called once for each button that changed state since the last frame
  100265. * @param buttonIdx Which button index changed
  100266. * @param state New state of the button
  100267. * @param changes Which properties on the state changed since last frame
  100268. */
  100269. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100270. /**
  100271. * Moves the buttons on the controller mesh based on their current state
  100272. * @param buttonName the name of the button to move
  100273. * @param buttonValue the value of the button which determines the buttons new position
  100274. */
  100275. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  100276. /**
  100277. * Moves the axis on the controller mesh based on its current state
  100278. * @param axis the index of the axis
  100279. * @param axisValue the value of the axis which determines the meshes new position
  100280. * @hidden
  100281. */
  100282. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  100283. /**
  100284. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  100285. * @param scene scene in which to add meshes
  100286. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  100287. */
  100288. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  100289. /**
  100290. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  100291. * can be transformed by button presses and axes values, based on this._mapping.
  100292. *
  100293. * @param scene scene in which the meshes exist
  100294. * @param meshes list of meshes that make up the controller model to process
  100295. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  100296. */
  100297. private processModel;
  100298. private createMeshInfo;
  100299. /**
  100300. * Gets the ray of the controller in the direction the controller is pointing
  100301. * @param length the length the resulting ray should be
  100302. * @returns a ray in the direction the controller is pointing
  100303. */
  100304. getForwardRay(length?: number): Ray;
  100305. /**
  100306. * Disposes of the controller
  100307. */
  100308. dispose(): void;
  100309. }
  100310. }
  100311. declare module BABYLON {
  100312. /**
  100313. * Single axis scale gizmo
  100314. */
  100315. export class AxisScaleGizmo extends Gizmo {
  100316. private _coloredMaterial;
  100317. /**
  100318. * Drag behavior responsible for the gizmos dragging interactions
  100319. */
  100320. dragBehavior: PointerDragBehavior;
  100321. private _pointerObserver;
  100322. /**
  100323. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  100324. */
  100325. snapDistance: number;
  100326. /**
  100327. * Event that fires each time the gizmo snaps to a new location.
  100328. * * snapDistance is the the change in distance
  100329. */
  100330. onSnapObservable: Observable<{
  100331. snapDistance: number;
  100332. }>;
  100333. /**
  100334. * If the scaling operation should be done on all axis (default: false)
  100335. */
  100336. uniformScaling: boolean;
  100337. /**
  100338. * Creates an AxisScaleGizmo
  100339. * @param gizmoLayer The utility layer the gizmo will be added to
  100340. * @param dragAxis The axis which the gizmo will be able to scale on
  100341. * @param color The color of the gizmo
  100342. */
  100343. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  100344. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100345. /**
  100346. * Disposes of the gizmo
  100347. */
  100348. dispose(): void;
  100349. /**
  100350. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  100351. * @param mesh The mesh to replace the default mesh of the gizmo
  100352. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  100353. */
  100354. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  100355. }
  100356. }
  100357. declare module BABYLON {
  100358. /**
  100359. * Bounding box gizmo
  100360. */
  100361. export class BoundingBoxGizmo extends Gizmo {
  100362. private _lineBoundingBox;
  100363. private _rotateSpheresParent;
  100364. private _scaleBoxesParent;
  100365. private _boundingDimensions;
  100366. private _renderObserver;
  100367. private _pointerObserver;
  100368. private _scaleDragSpeed;
  100369. private _tmpQuaternion;
  100370. private _tmpVector;
  100371. private _tmpRotationMatrix;
  100372. /**
  100373. * 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)
  100374. */
  100375. ignoreChildren: boolean;
  100376. /**
  100377. * 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)
  100378. */
  100379. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  100380. /**
  100381. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  100382. */
  100383. rotationSphereSize: number;
  100384. /**
  100385. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  100386. */
  100387. scaleBoxSize: number;
  100388. /**
  100389. * 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)
  100390. */
  100391. fixedDragMeshScreenSize: boolean;
  100392. /**
  100393. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  100394. */
  100395. fixedDragMeshScreenSizeDistanceFactor: number;
  100396. /**
  100397. * Fired when a rotation sphere or scale box is dragged
  100398. */
  100399. onDragStartObservable: Observable<{}>;
  100400. /**
  100401. * Fired when a scale box is dragged
  100402. */
  100403. onScaleBoxDragObservable: Observable<{}>;
  100404. /**
  100405. * Fired when a scale box drag is ended
  100406. */
  100407. onScaleBoxDragEndObservable: Observable<{}>;
  100408. /**
  100409. * Fired when a rotation sphere is dragged
  100410. */
  100411. onRotationSphereDragObservable: Observable<{}>;
  100412. /**
  100413. * Fired when a rotation sphere drag is ended
  100414. */
  100415. onRotationSphereDragEndObservable: Observable<{}>;
  100416. /**
  100417. * 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)
  100418. */
  100419. scalePivot: Nullable<Vector3>;
  100420. private _anchorMesh;
  100421. private _existingMeshScale;
  100422. private _dragMesh;
  100423. private pointerDragBehavior;
  100424. private coloredMaterial;
  100425. private hoverColoredMaterial;
  100426. /**
  100427. * Sets the color of the bounding box gizmo
  100428. * @param color the color to set
  100429. */
  100430. setColor(color: Color3): void;
  100431. /**
  100432. * Creates an BoundingBoxGizmo
  100433. * @param gizmoLayer The utility layer the gizmo will be added to
  100434. * @param color The color of the gizmo
  100435. */
  100436. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  100437. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100438. private _selectNode;
  100439. /**
  100440. * Updates the bounding box information for the Gizmo
  100441. */
  100442. updateBoundingBox(): void;
  100443. private _updateRotationSpheres;
  100444. private _updateScaleBoxes;
  100445. /**
  100446. * Enables rotation on the specified axis and disables rotation on the others
  100447. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  100448. */
  100449. setEnabledRotationAxis(axis: string): void;
  100450. /**
  100451. * Enables/disables scaling
  100452. * @param enable if scaling should be enabled
  100453. */
  100454. setEnabledScaling(enable: boolean): void;
  100455. private _updateDummy;
  100456. /**
  100457. * Enables a pointer drag behavior on the bounding box of the gizmo
  100458. */
  100459. enableDragBehavior(): void;
  100460. /**
  100461. * Disposes of the gizmo
  100462. */
  100463. dispose(): void;
  100464. /**
  100465. * 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)
  100466. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  100467. * @returns the bounding box mesh with the passed in mesh as a child
  100468. */
  100469. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  100470. /**
  100471. * CustomMeshes are not supported by this gizmo
  100472. * @param mesh The mesh to replace the default mesh of the gizmo
  100473. */
  100474. setCustomMesh(mesh: Mesh): void;
  100475. }
  100476. }
  100477. declare module BABYLON {
  100478. /**
  100479. * Single plane rotation gizmo
  100480. */
  100481. export class PlaneRotationGizmo extends Gizmo {
  100482. /**
  100483. * Drag behavior responsible for the gizmos dragging interactions
  100484. */
  100485. dragBehavior: PointerDragBehavior;
  100486. private _pointerObserver;
  100487. /**
  100488. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  100489. */
  100490. snapDistance: number;
  100491. /**
  100492. * Event that fires each time the gizmo snaps to a new location.
  100493. * * snapDistance is the the change in distance
  100494. */
  100495. onSnapObservable: Observable<{
  100496. snapDistance: number;
  100497. }>;
  100498. /**
  100499. * Creates a PlaneRotationGizmo
  100500. * @param gizmoLayer The utility layer the gizmo will be added to
  100501. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  100502. * @param color The color of the gizmo
  100503. * @param tessellation Amount of tessellation to be used when creating rotation circles
  100504. */
  100505. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  100506. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100507. /**
  100508. * Disposes of the gizmo
  100509. */
  100510. dispose(): void;
  100511. }
  100512. }
  100513. declare module BABYLON {
  100514. /**
  100515. * Gizmo that enables rotating a mesh along 3 axis
  100516. */
  100517. export class RotationGizmo extends Gizmo {
  100518. /**
  100519. * Internal gizmo used for interactions on the x axis
  100520. */
  100521. xGizmo: PlaneRotationGizmo;
  100522. /**
  100523. * Internal gizmo used for interactions on the y axis
  100524. */
  100525. yGizmo: PlaneRotationGizmo;
  100526. /**
  100527. * Internal gizmo used for interactions on the z axis
  100528. */
  100529. zGizmo: PlaneRotationGizmo;
  100530. /** Fires an event when any of it's sub gizmos are dragged */
  100531. onDragStartObservable: Observable<{}>;
  100532. /** Fires an event when any of it's sub gizmos are released from dragging */
  100533. onDragEndObservable: Observable<{}>;
  100534. attachedMesh: Nullable<AbstractMesh>;
  100535. /**
  100536. * Creates a RotationGizmo
  100537. * @param gizmoLayer The utility layer the gizmo will be added to
  100538. * @param tessellation Amount of tessellation to be used when creating rotation circles
  100539. */
  100540. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  100541. updateGizmoRotationToMatchAttachedMesh: boolean;
  100542. /**
  100543. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  100544. */
  100545. snapDistance: number;
  100546. /**
  100547. * Ratio for the scale of the gizmo (Default: 1)
  100548. */
  100549. scaleRatio: number;
  100550. /**
  100551. * Disposes of the gizmo
  100552. */
  100553. dispose(): void;
  100554. /**
  100555. * CustomMeshes are not supported by this gizmo
  100556. * @param mesh The mesh to replace the default mesh of the gizmo
  100557. */
  100558. setCustomMesh(mesh: Mesh): void;
  100559. }
  100560. }
  100561. declare module BABYLON {
  100562. /**
  100563. * Gizmo that enables dragging a mesh along 3 axis
  100564. */
  100565. export class PositionGizmo extends Gizmo {
  100566. /**
  100567. * Internal gizmo used for interactions on the x axis
  100568. */
  100569. xGizmo: AxisDragGizmo;
  100570. /**
  100571. * Internal gizmo used for interactions on the y axis
  100572. */
  100573. yGizmo: AxisDragGizmo;
  100574. /**
  100575. * Internal gizmo used for interactions on the z axis
  100576. */
  100577. zGizmo: AxisDragGizmo;
  100578. /** Fires an event when any of it's sub gizmos are dragged */
  100579. onDragStartObservable: Observable<{}>;
  100580. /** Fires an event when any of it's sub gizmos are released from dragging */
  100581. onDragEndObservable: Observable<{}>;
  100582. attachedMesh: Nullable<AbstractMesh>;
  100583. /**
  100584. * Creates a PositionGizmo
  100585. * @param gizmoLayer The utility layer the gizmo will be added to
  100586. */
  100587. constructor(gizmoLayer?: UtilityLayerRenderer);
  100588. updateGizmoRotationToMatchAttachedMesh: boolean;
  100589. /**
  100590. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  100591. */
  100592. snapDistance: number;
  100593. /**
  100594. * Ratio for the scale of the gizmo (Default: 1)
  100595. */
  100596. scaleRatio: number;
  100597. /**
  100598. * Disposes of the gizmo
  100599. */
  100600. dispose(): void;
  100601. /**
  100602. * CustomMeshes are not supported by this gizmo
  100603. * @param mesh The mesh to replace the default mesh of the gizmo
  100604. */
  100605. setCustomMesh(mesh: Mesh): void;
  100606. }
  100607. }
  100608. declare module BABYLON {
  100609. /**
  100610. * Class containing static functions to help procedurally build meshes
  100611. */
  100612. export class PolyhedronBuilder {
  100613. /**
  100614. * Creates a polyhedron mesh
  100615. * * 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
  100616. * * The parameter `size` (positive float, default 1) sets the polygon size
  100617. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  100618. * * 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`
  100619. * * 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
  100620. * * 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)`)
  100621. * * 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
  100622. * * 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
  100623. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100624. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100625. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100626. * @param name defines the name of the mesh
  100627. * @param options defines the options used to create the mesh
  100628. * @param scene defines the hosting scene
  100629. * @returns the polyhedron mesh
  100630. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  100631. */
  100632. static CreatePolyhedron(name: string, options: {
  100633. type?: number;
  100634. size?: number;
  100635. sizeX?: number;
  100636. sizeY?: number;
  100637. sizeZ?: number;
  100638. custom?: any;
  100639. faceUV?: Vector4[];
  100640. faceColors?: Color4[];
  100641. flat?: boolean;
  100642. updatable?: boolean;
  100643. sideOrientation?: number;
  100644. frontUVs?: Vector4;
  100645. backUVs?: Vector4;
  100646. }, scene: Scene): Mesh;
  100647. }
  100648. }
  100649. declare module BABYLON {
  100650. /**
  100651. * Gizmo that enables scaling a mesh along 3 axis
  100652. */
  100653. export class ScaleGizmo extends Gizmo {
  100654. /**
  100655. * Internal gizmo used for interactions on the x axis
  100656. */
  100657. xGizmo: AxisScaleGizmo;
  100658. /**
  100659. * Internal gizmo used for interactions on the y axis
  100660. */
  100661. yGizmo: AxisScaleGizmo;
  100662. /**
  100663. * Internal gizmo used for interactions on the z axis
  100664. */
  100665. zGizmo: AxisScaleGizmo;
  100666. /**
  100667. * Internal gizmo used to scale all axis equally
  100668. */
  100669. uniformScaleGizmo: AxisScaleGizmo;
  100670. /** Fires an event when any of it's sub gizmos are dragged */
  100671. onDragStartObservable: Observable<{}>;
  100672. /** Fires an event when any of it's sub gizmos are released from dragging */
  100673. onDragEndObservable: Observable<{}>;
  100674. attachedMesh: Nullable<AbstractMesh>;
  100675. /**
  100676. * Creates a ScaleGizmo
  100677. * @param gizmoLayer The utility layer the gizmo will be added to
  100678. */
  100679. constructor(gizmoLayer?: UtilityLayerRenderer);
  100680. updateGizmoRotationToMatchAttachedMesh: boolean;
  100681. /**
  100682. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  100683. */
  100684. snapDistance: number;
  100685. /**
  100686. * Ratio for the scale of the gizmo (Default: 1)
  100687. */
  100688. scaleRatio: number;
  100689. /**
  100690. * Disposes of the gizmo
  100691. */
  100692. dispose(): void;
  100693. }
  100694. }
  100695. declare module BABYLON {
  100696. /**
  100697. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  100698. */
  100699. export class GizmoManager implements IDisposable {
  100700. private scene;
  100701. /**
  100702. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  100703. */
  100704. gizmos: {
  100705. positionGizmo: Nullable<PositionGizmo>;
  100706. rotationGizmo: Nullable<RotationGizmo>;
  100707. scaleGizmo: Nullable<ScaleGizmo>;
  100708. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  100709. };
  100710. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  100711. clearGizmoOnEmptyPointerEvent: boolean;
  100712. /** Fires an event when the manager is attached to a mesh */
  100713. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  100714. private _gizmosEnabled;
  100715. private _pointerObserver;
  100716. private _attachedMesh;
  100717. private _boundingBoxColor;
  100718. private _defaultUtilityLayer;
  100719. private _defaultKeepDepthUtilityLayer;
  100720. /**
  100721. * When bounding box gizmo is enabled, this can be used to track drag/end events
  100722. */
  100723. boundingBoxDragBehavior: SixDofDragBehavior;
  100724. /**
  100725. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  100726. */
  100727. attachableMeshes: Nullable<Array<AbstractMesh>>;
  100728. /**
  100729. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  100730. */
  100731. usePointerToAttachGizmos: boolean;
  100732. /**
  100733. * Instatiates a gizmo manager
  100734. * @param scene the scene to overlay the gizmos on top of
  100735. */
  100736. constructor(scene: Scene);
  100737. /**
  100738. * Attaches a set of gizmos to the specified mesh
  100739. * @param mesh The mesh the gizmo's should be attached to
  100740. */
  100741. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  100742. /**
  100743. * If the position gizmo is enabled
  100744. */
  100745. positionGizmoEnabled: boolean;
  100746. /**
  100747. * If the rotation gizmo is enabled
  100748. */
  100749. rotationGizmoEnabled: boolean;
  100750. /**
  100751. * If the scale gizmo is enabled
  100752. */
  100753. scaleGizmoEnabled: boolean;
  100754. /**
  100755. * If the boundingBox gizmo is enabled
  100756. */
  100757. boundingBoxGizmoEnabled: boolean;
  100758. /**
  100759. * Disposes of the gizmo manager
  100760. */
  100761. dispose(): void;
  100762. }
  100763. }
  100764. declare module BABYLON {
  100765. /**
  100766. * Gizmo that enables viewing a light
  100767. */
  100768. export class LightGizmo extends Gizmo {
  100769. private _box;
  100770. /**
  100771. * Creates a LightGizmo
  100772. * @param gizmoLayer The utility layer the gizmo will be added to
  100773. */
  100774. constructor(gizmoLayer?: UtilityLayerRenderer);
  100775. private _light;
  100776. /**
  100777. * The light that the gizmo is attached to
  100778. */
  100779. light: Nullable<Light>;
  100780. /**
  100781. * @hidden
  100782. * Updates the gizmo to match the attached mesh's position/rotation
  100783. */
  100784. protected _update(): void;
  100785. }
  100786. }
  100787. declare module BABYLON {
  100788. /** @hidden */
  100789. export var backgroundFragmentDeclaration: {
  100790. name: string;
  100791. shader: string;
  100792. };
  100793. }
  100794. declare module BABYLON {
  100795. /** @hidden */
  100796. export var backgroundUboDeclaration: {
  100797. name: string;
  100798. shader: string;
  100799. };
  100800. }
  100801. declare module BABYLON {
  100802. /** @hidden */
  100803. export var backgroundPixelShader: {
  100804. name: string;
  100805. shader: string;
  100806. };
  100807. }
  100808. declare module BABYLON {
  100809. /** @hidden */
  100810. export var backgroundVertexDeclaration: {
  100811. name: string;
  100812. shader: string;
  100813. };
  100814. }
  100815. declare module BABYLON {
  100816. /** @hidden */
  100817. export var backgroundVertexShader: {
  100818. name: string;
  100819. shader: string;
  100820. };
  100821. }
  100822. declare module BABYLON {
  100823. /**
  100824. * Background material used to create an efficient environement around your scene.
  100825. */
  100826. export class BackgroundMaterial extends PushMaterial {
  100827. /**
  100828. * Standard reflectance value at parallel view angle.
  100829. */
  100830. static StandardReflectance0: number;
  100831. /**
  100832. * Standard reflectance value at grazing angle.
  100833. */
  100834. static StandardReflectance90: number;
  100835. protected _primaryColor: Color3;
  100836. /**
  100837. * Key light Color (multiply against the environement texture)
  100838. */
  100839. primaryColor: Color3;
  100840. protected __perceptualColor: Nullable<Color3>;
  100841. /**
  100842. * Experimental Internal Use Only.
  100843. *
  100844. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  100845. * This acts as a helper to set the primary color to a more "human friendly" value.
  100846. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  100847. * output color as close as possible from the chosen value.
  100848. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  100849. * part of lighting setup.)
  100850. */
  100851. _perceptualColor: Nullable<Color3>;
  100852. protected _primaryColorShadowLevel: float;
  100853. /**
  100854. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  100855. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  100856. */
  100857. primaryColorShadowLevel: float;
  100858. protected _primaryColorHighlightLevel: float;
  100859. /**
  100860. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  100861. * The primary color is used at the level chosen to define what the white area would look.
  100862. */
  100863. primaryColorHighlightLevel: float;
  100864. protected _reflectionTexture: Nullable<BaseTexture>;
  100865. /**
  100866. * Reflection Texture used in the material.
  100867. * Should be author in a specific way for the best result (refer to the documentation).
  100868. */
  100869. reflectionTexture: Nullable<BaseTexture>;
  100870. protected _reflectionBlur: float;
  100871. /**
  100872. * Reflection Texture level of blur.
  100873. *
  100874. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  100875. * texture twice.
  100876. */
  100877. reflectionBlur: float;
  100878. protected _diffuseTexture: Nullable<BaseTexture>;
  100879. /**
  100880. * Diffuse Texture used in the material.
  100881. * Should be author in a specific way for the best result (refer to the documentation).
  100882. */
  100883. diffuseTexture: Nullable<BaseTexture>;
  100884. protected _shadowLights: Nullable<IShadowLight[]>;
  100885. /**
  100886. * Specify the list of lights casting shadow on the material.
  100887. * All scene shadow lights will be included if null.
  100888. */
  100889. shadowLights: Nullable<IShadowLight[]>;
  100890. protected _shadowLevel: float;
  100891. /**
  100892. * Helps adjusting the shadow to a softer level if required.
  100893. * 0 means black shadows and 1 means no shadows.
  100894. */
  100895. shadowLevel: float;
  100896. protected _sceneCenter: Vector3;
  100897. /**
  100898. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  100899. * It is usually zero but might be interesting to modify according to your setup.
  100900. */
  100901. sceneCenter: Vector3;
  100902. protected _opacityFresnel: boolean;
  100903. /**
  100904. * This helps specifying that the material is falling off to the sky box at grazing angle.
  100905. * This helps ensuring a nice transition when the camera goes under the ground.
  100906. */
  100907. opacityFresnel: boolean;
  100908. protected _reflectionFresnel: boolean;
  100909. /**
  100910. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  100911. * This helps adding a mirror texture on the ground.
  100912. */
  100913. reflectionFresnel: boolean;
  100914. protected _reflectionFalloffDistance: number;
  100915. /**
  100916. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  100917. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  100918. */
  100919. reflectionFalloffDistance: number;
  100920. protected _reflectionAmount: number;
  100921. /**
  100922. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  100923. */
  100924. reflectionAmount: number;
  100925. protected _reflectionReflectance0: number;
  100926. /**
  100927. * This specifies the weight of the reflection at grazing angle.
  100928. */
  100929. reflectionReflectance0: number;
  100930. protected _reflectionReflectance90: number;
  100931. /**
  100932. * This specifies the weight of the reflection at a perpendicular point of view.
  100933. */
  100934. reflectionReflectance90: number;
  100935. /**
  100936. * Sets the reflection reflectance fresnel values according to the default standard
  100937. * empirically know to work well :-)
  100938. */
  100939. reflectionStandardFresnelWeight: number;
  100940. protected _useRGBColor: boolean;
  100941. /**
  100942. * Helps to directly use the maps channels instead of their level.
  100943. */
  100944. useRGBColor: boolean;
  100945. protected _enableNoise: boolean;
  100946. /**
  100947. * This helps reducing the banding effect that could occur on the background.
  100948. */
  100949. enableNoise: boolean;
  100950. /**
  100951. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  100952. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  100953. * Recommended to be keep at 1.0 except for special cases.
  100954. */
  100955. fovMultiplier: number;
  100956. private _fovMultiplier;
  100957. /**
  100958. * Enable the FOV adjustment feature controlled by fovMultiplier.
  100959. */
  100960. useEquirectangularFOV: boolean;
  100961. private _maxSimultaneousLights;
  100962. /**
  100963. * Number of Simultaneous lights allowed on the material.
  100964. */
  100965. maxSimultaneousLights: int;
  100966. /**
  100967. * Default configuration related to image processing available in the Background Material.
  100968. */
  100969. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  100970. /**
  100971. * Keep track of the image processing observer to allow dispose and replace.
  100972. */
  100973. private _imageProcessingObserver;
  100974. /**
  100975. * Attaches a new image processing configuration to the PBR Material.
  100976. * @param configuration (if null the scene configuration will be use)
  100977. */
  100978. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  100979. /**
  100980. * Gets the image processing configuration used either in this material.
  100981. */
  100982. /**
  100983. * Sets the Default image processing configuration used either in the this material.
  100984. *
  100985. * If sets to null, the scene one is in use.
  100986. */
  100987. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  100988. /**
  100989. * Gets wether the color curves effect is enabled.
  100990. */
  100991. /**
  100992. * Sets wether the color curves effect is enabled.
  100993. */
  100994. cameraColorCurvesEnabled: boolean;
  100995. /**
  100996. * Gets wether the color grading effect is enabled.
  100997. */
  100998. /**
  100999. * Gets wether the color grading effect is enabled.
  101000. */
  101001. cameraColorGradingEnabled: boolean;
  101002. /**
  101003. * Gets wether tonemapping is enabled or not.
  101004. */
  101005. /**
  101006. * Sets wether tonemapping is enabled or not
  101007. */
  101008. cameraToneMappingEnabled: boolean;
  101009. /**
  101010. * The camera exposure used on this material.
  101011. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101012. * This corresponds to a photographic exposure.
  101013. */
  101014. /**
  101015. * The camera exposure used on this material.
  101016. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101017. * This corresponds to a photographic exposure.
  101018. */
  101019. cameraExposure: float;
  101020. /**
  101021. * Gets The camera contrast used on this material.
  101022. */
  101023. /**
  101024. * Sets The camera contrast used on this material.
  101025. */
  101026. cameraContrast: float;
  101027. /**
  101028. * Gets the Color Grading 2D Lookup Texture.
  101029. */
  101030. /**
  101031. * Sets the Color Grading 2D Lookup Texture.
  101032. */
  101033. cameraColorGradingTexture: Nullable<BaseTexture>;
  101034. /**
  101035. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101036. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101037. * 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;
  101038. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101039. */
  101040. /**
  101041. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101042. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101043. * 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;
  101044. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101045. */
  101046. cameraColorCurves: Nullable<ColorCurves>;
  101047. /**
  101048. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  101049. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  101050. */
  101051. switchToBGR: boolean;
  101052. private _renderTargets;
  101053. private _reflectionControls;
  101054. private _white;
  101055. private _primaryShadowColor;
  101056. private _primaryHighlightColor;
  101057. /**
  101058. * Instantiates a Background Material in the given scene
  101059. * @param name The friendly name of the material
  101060. * @param scene The scene to add the material to
  101061. */
  101062. constructor(name: string, scene: Scene);
  101063. /**
  101064. * Gets a boolean indicating that current material needs to register RTT
  101065. */
  101066. readonly hasRenderTargetTextures: boolean;
  101067. /**
  101068. * The entire material has been created in order to prevent overdraw.
  101069. * @returns false
  101070. */
  101071. needAlphaTesting(): boolean;
  101072. /**
  101073. * The entire material has been created in order to prevent overdraw.
  101074. * @returns true if blending is enable
  101075. */
  101076. needAlphaBlending(): boolean;
  101077. /**
  101078. * Checks wether the material is ready to be rendered for a given mesh.
  101079. * @param mesh The mesh to render
  101080. * @param subMesh The submesh to check against
  101081. * @param useInstances Specify wether or not the material is used with instances
  101082. * @returns true if all the dependencies are ready (Textures, Effects...)
  101083. */
  101084. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101085. /**
  101086. * Compute the primary color according to the chosen perceptual color.
  101087. */
  101088. private _computePrimaryColorFromPerceptualColor;
  101089. /**
  101090. * Compute the highlights and shadow colors according to their chosen levels.
  101091. */
  101092. private _computePrimaryColors;
  101093. /**
  101094. * Build the uniform buffer used in the material.
  101095. */
  101096. buildUniformLayout(): void;
  101097. /**
  101098. * Unbind the material.
  101099. */
  101100. unbind(): void;
  101101. /**
  101102. * Bind only the world matrix to the material.
  101103. * @param world The world matrix to bind.
  101104. */
  101105. bindOnlyWorldMatrix(world: Matrix): void;
  101106. /**
  101107. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  101108. * @param world The world matrix to bind.
  101109. * @param subMesh The submesh to bind for.
  101110. */
  101111. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  101112. /**
  101113. * Dispose the material.
  101114. * @param forceDisposeEffect Force disposal of the associated effect.
  101115. * @param forceDisposeTextures Force disposal of the associated textures.
  101116. */
  101117. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  101118. /**
  101119. * Clones the material.
  101120. * @param name The cloned name.
  101121. * @returns The cloned material.
  101122. */
  101123. clone(name: string): BackgroundMaterial;
  101124. /**
  101125. * Serializes the current material to its JSON representation.
  101126. * @returns The JSON representation.
  101127. */
  101128. serialize(): any;
  101129. /**
  101130. * Gets the class name of the material
  101131. * @returns "BackgroundMaterial"
  101132. */
  101133. getClassName(): string;
  101134. /**
  101135. * Parse a JSON input to create back a background material.
  101136. * @param source The JSON data to parse
  101137. * @param scene The scene to create the parsed material in
  101138. * @param rootUrl The root url of the assets the material depends upon
  101139. * @returns the instantiated BackgroundMaterial.
  101140. */
  101141. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  101142. }
  101143. }
  101144. declare module BABYLON {
  101145. /**
  101146. * Represents the different options available during the creation of
  101147. * a Environment helper.
  101148. *
  101149. * This can control the default ground, skybox and image processing setup of your scene.
  101150. */
  101151. export interface IEnvironmentHelperOptions {
  101152. /**
  101153. * Specifies wether or not to create a ground.
  101154. * True by default.
  101155. */
  101156. createGround: boolean;
  101157. /**
  101158. * Specifies the ground size.
  101159. * 15 by default.
  101160. */
  101161. groundSize: number;
  101162. /**
  101163. * The texture used on the ground for the main color.
  101164. * Comes from the BabylonJS CDN by default.
  101165. *
  101166. * Remarks: Can be either a texture or a url.
  101167. */
  101168. groundTexture: string | BaseTexture;
  101169. /**
  101170. * The color mixed in the ground texture by default.
  101171. * BabylonJS clearColor by default.
  101172. */
  101173. groundColor: Color3;
  101174. /**
  101175. * Specifies the ground opacity.
  101176. * 1 by default.
  101177. */
  101178. groundOpacity: number;
  101179. /**
  101180. * Enables the ground to receive shadows.
  101181. * True by default.
  101182. */
  101183. enableGroundShadow: boolean;
  101184. /**
  101185. * Helps preventing the shadow to be fully black on the ground.
  101186. * 0.5 by default.
  101187. */
  101188. groundShadowLevel: number;
  101189. /**
  101190. * Creates a mirror texture attach to the ground.
  101191. * false by default.
  101192. */
  101193. enableGroundMirror: boolean;
  101194. /**
  101195. * Specifies the ground mirror size ratio.
  101196. * 0.3 by default as the default kernel is 64.
  101197. */
  101198. groundMirrorSizeRatio: number;
  101199. /**
  101200. * Specifies the ground mirror blur kernel size.
  101201. * 64 by default.
  101202. */
  101203. groundMirrorBlurKernel: number;
  101204. /**
  101205. * Specifies the ground mirror visibility amount.
  101206. * 1 by default
  101207. */
  101208. groundMirrorAmount: number;
  101209. /**
  101210. * Specifies the ground mirror reflectance weight.
  101211. * This uses the standard weight of the background material to setup the fresnel effect
  101212. * of the mirror.
  101213. * 1 by default.
  101214. */
  101215. groundMirrorFresnelWeight: number;
  101216. /**
  101217. * Specifies the ground mirror Falloff distance.
  101218. * This can helps reducing the size of the reflection.
  101219. * 0 by Default.
  101220. */
  101221. groundMirrorFallOffDistance: number;
  101222. /**
  101223. * Specifies the ground mirror texture type.
  101224. * Unsigned Int by Default.
  101225. */
  101226. groundMirrorTextureType: number;
  101227. /**
  101228. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  101229. * the shown objects.
  101230. */
  101231. groundYBias: number;
  101232. /**
  101233. * Specifies wether or not to create a skybox.
  101234. * True by default.
  101235. */
  101236. createSkybox: boolean;
  101237. /**
  101238. * Specifies the skybox size.
  101239. * 20 by default.
  101240. */
  101241. skyboxSize: number;
  101242. /**
  101243. * The texture used on the skybox for the main color.
  101244. * Comes from the BabylonJS CDN by default.
  101245. *
  101246. * Remarks: Can be either a texture or a url.
  101247. */
  101248. skyboxTexture: string | BaseTexture;
  101249. /**
  101250. * The color mixed in the skybox texture by default.
  101251. * BabylonJS clearColor by default.
  101252. */
  101253. skyboxColor: Color3;
  101254. /**
  101255. * The background rotation around the Y axis of the scene.
  101256. * This helps aligning the key lights of your scene with the background.
  101257. * 0 by default.
  101258. */
  101259. backgroundYRotation: number;
  101260. /**
  101261. * Compute automatically the size of the elements to best fit with the scene.
  101262. */
  101263. sizeAuto: boolean;
  101264. /**
  101265. * Default position of the rootMesh if autoSize is not true.
  101266. */
  101267. rootPosition: Vector3;
  101268. /**
  101269. * Sets up the image processing in the scene.
  101270. * true by default.
  101271. */
  101272. setupImageProcessing: boolean;
  101273. /**
  101274. * The texture used as your environment texture in the scene.
  101275. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  101276. *
  101277. * Remarks: Can be either a texture or a url.
  101278. */
  101279. environmentTexture: string | BaseTexture;
  101280. /**
  101281. * The value of the exposure to apply to the scene.
  101282. * 0.6 by default if setupImageProcessing is true.
  101283. */
  101284. cameraExposure: number;
  101285. /**
  101286. * The value of the contrast to apply to the scene.
  101287. * 1.6 by default if setupImageProcessing is true.
  101288. */
  101289. cameraContrast: number;
  101290. /**
  101291. * Specifies wether or not tonemapping should be enabled in the scene.
  101292. * true by default if setupImageProcessing is true.
  101293. */
  101294. toneMappingEnabled: boolean;
  101295. }
  101296. /**
  101297. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  101298. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  101299. * It also helps with the default setup of your imageProcessing configuration.
  101300. */
  101301. export class EnvironmentHelper {
  101302. /**
  101303. * Default ground texture URL.
  101304. */
  101305. private static _groundTextureCDNUrl;
  101306. /**
  101307. * Default skybox texture URL.
  101308. */
  101309. private static _skyboxTextureCDNUrl;
  101310. /**
  101311. * Default environment texture URL.
  101312. */
  101313. private static _environmentTextureCDNUrl;
  101314. /**
  101315. * Creates the default options for the helper.
  101316. */
  101317. private static _getDefaultOptions;
  101318. private _rootMesh;
  101319. /**
  101320. * Gets the root mesh created by the helper.
  101321. */
  101322. readonly rootMesh: Mesh;
  101323. private _skybox;
  101324. /**
  101325. * Gets the skybox created by the helper.
  101326. */
  101327. readonly skybox: Nullable<Mesh>;
  101328. private _skyboxTexture;
  101329. /**
  101330. * Gets the skybox texture created by the helper.
  101331. */
  101332. readonly skyboxTexture: Nullable<BaseTexture>;
  101333. private _skyboxMaterial;
  101334. /**
  101335. * Gets the skybox material created by the helper.
  101336. */
  101337. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  101338. private _ground;
  101339. /**
  101340. * Gets the ground mesh created by the helper.
  101341. */
  101342. readonly ground: Nullable<Mesh>;
  101343. private _groundTexture;
  101344. /**
  101345. * Gets the ground texture created by the helper.
  101346. */
  101347. readonly groundTexture: Nullable<BaseTexture>;
  101348. private _groundMirror;
  101349. /**
  101350. * Gets the ground mirror created by the helper.
  101351. */
  101352. readonly groundMirror: Nullable<MirrorTexture>;
  101353. /**
  101354. * Gets the ground mirror render list to helps pushing the meshes
  101355. * you wish in the ground reflection.
  101356. */
  101357. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  101358. private _groundMaterial;
  101359. /**
  101360. * Gets the ground material created by the helper.
  101361. */
  101362. readonly groundMaterial: Nullable<BackgroundMaterial>;
  101363. /**
  101364. * Stores the creation options.
  101365. */
  101366. private readonly _scene;
  101367. private _options;
  101368. /**
  101369. * This observable will be notified with any error during the creation of the environment,
  101370. * mainly texture creation errors.
  101371. */
  101372. onErrorObservable: Observable<{
  101373. message?: string;
  101374. exception?: any;
  101375. }>;
  101376. /**
  101377. * constructor
  101378. * @param options Defines the options we want to customize the helper
  101379. * @param scene The scene to add the material to
  101380. */
  101381. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  101382. /**
  101383. * Updates the background according to the new options
  101384. * @param options
  101385. */
  101386. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  101387. /**
  101388. * Sets the primary color of all the available elements.
  101389. * @param color the main color to affect to the ground and the background
  101390. */
  101391. setMainColor(color: Color3): void;
  101392. /**
  101393. * Setup the image processing according to the specified options.
  101394. */
  101395. private _setupImageProcessing;
  101396. /**
  101397. * Setup the environment texture according to the specified options.
  101398. */
  101399. private _setupEnvironmentTexture;
  101400. /**
  101401. * Setup the background according to the specified options.
  101402. */
  101403. private _setupBackground;
  101404. /**
  101405. * Get the scene sizes according to the setup.
  101406. */
  101407. private _getSceneSize;
  101408. /**
  101409. * Setup the ground according to the specified options.
  101410. */
  101411. private _setupGround;
  101412. /**
  101413. * Setup the ground material according to the specified options.
  101414. */
  101415. private _setupGroundMaterial;
  101416. /**
  101417. * Setup the ground diffuse texture according to the specified options.
  101418. */
  101419. private _setupGroundDiffuseTexture;
  101420. /**
  101421. * Setup the ground mirror texture according to the specified options.
  101422. */
  101423. private _setupGroundMirrorTexture;
  101424. /**
  101425. * Setup the ground to receive the mirror texture.
  101426. */
  101427. private _setupMirrorInGroundMaterial;
  101428. /**
  101429. * Setup the skybox according to the specified options.
  101430. */
  101431. private _setupSkybox;
  101432. /**
  101433. * Setup the skybox material according to the specified options.
  101434. */
  101435. private _setupSkyboxMaterial;
  101436. /**
  101437. * Setup the skybox reflection texture according to the specified options.
  101438. */
  101439. private _setupSkyboxReflectionTexture;
  101440. private _errorHandler;
  101441. /**
  101442. * Dispose all the elements created by the Helper.
  101443. */
  101444. dispose(): void;
  101445. }
  101446. }
  101447. declare module BABYLON {
  101448. /**
  101449. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  101450. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  101451. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  101452. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  101453. */
  101454. export class PhotoDome extends TransformNode {
  101455. private _useDirectMapping;
  101456. /**
  101457. * The texture being displayed on the sphere
  101458. */
  101459. protected _photoTexture: Texture;
  101460. /**
  101461. * Gets or sets the texture being displayed on the sphere
  101462. */
  101463. photoTexture: Texture;
  101464. /**
  101465. * Observable raised when an error occured while loading the 360 image
  101466. */
  101467. onLoadErrorObservable: Observable<string>;
  101468. /**
  101469. * The skybox material
  101470. */
  101471. protected _material: BackgroundMaterial;
  101472. /**
  101473. * The surface used for the skybox
  101474. */
  101475. protected _mesh: Mesh;
  101476. /**
  101477. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  101478. * Also see the options.resolution property.
  101479. */
  101480. fovMultiplier: number;
  101481. /**
  101482. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  101483. * @param name Element's name, child elements will append suffixes for their own names.
  101484. * @param urlsOfPhoto defines the url of the photo to display
  101485. * @param options defines an object containing optional or exposed sub element properties
  101486. * @param onError defines a callback called when an error occured while loading the texture
  101487. */
  101488. constructor(name: string, urlOfPhoto: string, options: {
  101489. resolution?: number;
  101490. size?: number;
  101491. useDirectMapping?: boolean;
  101492. faceForward?: boolean;
  101493. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  101494. /**
  101495. * Releases resources associated with this node.
  101496. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  101497. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  101498. */
  101499. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  101500. }
  101501. }
  101502. declare module BABYLON {
  101503. /**
  101504. * Class used to host texture specific utilities
  101505. */
  101506. export class TextureTools {
  101507. /**
  101508. * Uses the GPU to create a copy texture rescaled at a given size
  101509. * @param texture Texture to copy from
  101510. * @param width defines the desired width
  101511. * @param height defines the desired height
  101512. * @param useBilinearMode defines if bilinear mode has to be used
  101513. * @return the generated texture
  101514. */
  101515. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  101516. /**
  101517. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  101518. * @param scene defines the hosting scene
  101519. * @returns the environment BRDF texture
  101520. */
  101521. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  101522. private static _environmentBRDFBase64Texture;
  101523. }
  101524. }
  101525. declare module BABYLON {
  101526. /**
  101527. * @hidden
  101528. */
  101529. export interface IMaterialClearCoatDefines {
  101530. CLEARCOAT: boolean;
  101531. CLEARCOAT_DEFAULTIOR: boolean;
  101532. CLEARCOAT_TEXTURE: boolean;
  101533. CLEARCOAT_TEXTUREDIRECTUV: number;
  101534. CLEARCOAT_BUMP: boolean;
  101535. CLEARCOAT_BUMPDIRECTUV: number;
  101536. CLEARCOAT_TINT: boolean;
  101537. CLEARCOAT_TINT_TEXTURE: boolean;
  101538. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  101539. /** @hidden */
  101540. _areTexturesDirty: boolean;
  101541. }
  101542. /**
  101543. * Define the code related to the clear coat parameters of the pbr material.
  101544. */
  101545. export class PBRClearCoatConfiguration {
  101546. /**
  101547. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  101548. * The default fits with a polyurethane material.
  101549. */
  101550. private static readonly _DefaultIndiceOfRefraction;
  101551. private _isEnabled;
  101552. /**
  101553. * Defines if the clear coat is enabled in the material.
  101554. */
  101555. isEnabled: boolean;
  101556. /**
  101557. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  101558. */
  101559. intensity: number;
  101560. /**
  101561. * Defines the clear coat layer roughness.
  101562. */
  101563. roughness: number;
  101564. private _indiceOfRefraction;
  101565. /**
  101566. * Defines the indice of refraction of the clear coat.
  101567. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  101568. * The default fits with a polyurethane material.
  101569. * Changing the default value is more performance intensive.
  101570. */
  101571. indiceOfRefraction: number;
  101572. private _texture;
  101573. /**
  101574. * Stores the clear coat values in a texture.
  101575. */
  101576. texture: Nullable<BaseTexture>;
  101577. private _bumpTexture;
  101578. /**
  101579. * Define the clear coat specific bump texture.
  101580. */
  101581. bumpTexture: Nullable<BaseTexture>;
  101582. private _isTintEnabled;
  101583. /**
  101584. * Defines if the clear coat tint is enabled in the material.
  101585. */
  101586. isTintEnabled: boolean;
  101587. /**
  101588. * Defines if the clear coat tint is enabled in the material.
  101589. * This is only use if tint is enabled
  101590. */
  101591. tintColor: Color3;
  101592. /**
  101593. * Defines if the distance at which the tint color should be found in the
  101594. * clear coat media.
  101595. * This is only use if tint is enabled
  101596. */
  101597. tintColorAtDistance: number;
  101598. /**
  101599. * Defines the clear coat layer thickness.
  101600. * This is only use if tint is enabled
  101601. */
  101602. tintThickness: number;
  101603. private _tintTexture;
  101604. /**
  101605. * Stores the clear tint values in a texture.
  101606. * rgb is tint
  101607. * a is a thickness factor
  101608. */
  101609. tintTexture: Nullable<BaseTexture>;
  101610. /** @hidden */
  101611. private _internalMarkAllSubMeshesAsTexturesDirty;
  101612. /** @hidden */
  101613. _markAllSubMeshesAsTexturesDirty(): void;
  101614. /**
  101615. * Instantiate a new istance of clear coat configuration.
  101616. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  101617. */
  101618. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  101619. /**
  101620. * Specifies that the submesh is ready to be used.
  101621. * @param defines the list of "defines" to update.
  101622. * @param scene defines the scene the material belongs to.
  101623. * @param engine defines the engine the material belongs to.
  101624. * @param disableBumpMap defines wether the material disables bump or not.
  101625. * @returns - boolean indicating that the submesh is ready or not.
  101626. */
  101627. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  101628. /**
  101629. * Checks to see if a texture is used in the material.
  101630. * @param defines the list of "defines" to update.
  101631. * @param scene defines the scene to the material belongs to.
  101632. */
  101633. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  101634. /**
  101635. * Binds the material data.
  101636. * @param uniformBuffer defines the Uniform buffer to fill in.
  101637. * @param scene defines the scene the material belongs to.
  101638. * @param engine defines the engine the material belongs to.
  101639. * @param disableBumpMap defines wether the material disables bump or not.
  101640. * @param isFrozen defines wether the material is frozen or not.
  101641. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  101642. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  101643. */
  101644. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  101645. /**
  101646. * Checks to see if a texture is used in the material.
  101647. * @param texture - Base texture to use.
  101648. * @returns - Boolean specifying if a texture is used in the material.
  101649. */
  101650. hasTexture(texture: BaseTexture): boolean;
  101651. /**
  101652. * Returns an array of the actively used textures.
  101653. * @param activeTextures Array of BaseTextures
  101654. */
  101655. getActiveTextures(activeTextures: BaseTexture[]): void;
  101656. /**
  101657. * Returns the animatable textures.
  101658. * @param animatables Array of animatable textures.
  101659. */
  101660. getAnimatables(animatables: IAnimatable[]): void;
  101661. /**
  101662. * Disposes the resources of the material.
  101663. * @param forceDisposeTextures - Forces the disposal of all textures.
  101664. */
  101665. dispose(forceDisposeTextures?: boolean): void;
  101666. /**
  101667. * Get the current class name of the texture useful for serialization or dynamic coding.
  101668. * @returns "PBRClearCoatConfiguration"
  101669. */
  101670. getClassName(): string;
  101671. /**
  101672. * Add fallbacks to the effect fallbacks list.
  101673. * @param defines defines the Base texture to use.
  101674. * @param fallbacks defines the current fallback list.
  101675. * @param currentRank defines the current fallback rank.
  101676. * @returns the new fallback rank.
  101677. */
  101678. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  101679. /**
  101680. * Add the required uniforms to the current list.
  101681. * @param uniforms defines the current uniform list.
  101682. */
  101683. static AddUniforms(uniforms: string[]): void;
  101684. /**
  101685. * Add the required samplers to the current list.
  101686. * @param samplers defines the current sampler list.
  101687. */
  101688. static AddSamplers(samplers: string[]): void;
  101689. /**
  101690. * Add the required uniforms to the current buffer.
  101691. * @param uniformBuffer defines the current uniform buffer.
  101692. */
  101693. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  101694. /**
  101695. * Makes a duplicate of the current configuration into another one.
  101696. * @param clearCoatConfiguration define the config where to copy the info
  101697. */
  101698. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  101699. /**
  101700. * Serializes this clear coat configuration.
  101701. * @returns - An object with the serialized config.
  101702. */
  101703. serialize(): any;
  101704. /**
  101705. * Parses a Clear Coat Configuration from a serialized object.
  101706. * @param source - Serialized object.
  101707. */
  101708. parse(source: any): void;
  101709. }
  101710. }
  101711. declare module BABYLON {
  101712. /**
  101713. * @hidden
  101714. */
  101715. export interface IMaterialAnisotropicDefines {
  101716. ANISOTROPIC: boolean;
  101717. ANISOTROPIC_TEXTURE: boolean;
  101718. ANISOTROPIC_TEXTUREDIRECTUV: number;
  101719. MAINUV1: boolean;
  101720. _areTexturesDirty: boolean;
  101721. _needUVs: boolean;
  101722. }
  101723. /**
  101724. * Define the code related to the anisotropic parameters of the pbr material.
  101725. */
  101726. export class PBRAnisotropicConfiguration {
  101727. private _isEnabled;
  101728. /**
  101729. * Defines if the anisotropy is enabled in the material.
  101730. */
  101731. isEnabled: boolean;
  101732. /**
  101733. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  101734. */
  101735. intensity: number;
  101736. /**
  101737. * Defines if the effect is along the tangents, bitangents or in between.
  101738. * By default, the effect is "strectching" the highlights along the tangents.
  101739. */
  101740. direction: Vector2;
  101741. private _texture;
  101742. /**
  101743. * Stores the anisotropy values in a texture.
  101744. * rg is direction (like normal from -1 to 1)
  101745. * b is a intensity
  101746. */
  101747. texture: Nullable<BaseTexture>;
  101748. /** @hidden */
  101749. private _internalMarkAllSubMeshesAsTexturesDirty;
  101750. /** @hidden */
  101751. _markAllSubMeshesAsTexturesDirty(): void;
  101752. /**
  101753. * Instantiate a new istance of anisotropy configuration.
  101754. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  101755. */
  101756. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  101757. /**
  101758. * Specifies that the submesh is ready to be used.
  101759. * @param defines the list of "defines" to update.
  101760. * @param scene defines the scene the material belongs to.
  101761. * @returns - boolean indicating that the submesh is ready or not.
  101762. */
  101763. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  101764. /**
  101765. * Checks to see if a texture is used in the material.
  101766. * @param defines the list of "defines" to update.
  101767. * @param mesh the mesh we are preparing the defines for.
  101768. * @param scene defines the scene the material belongs to.
  101769. */
  101770. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  101771. /**
  101772. * Binds the material data.
  101773. * @param uniformBuffer defines the Uniform buffer to fill in.
  101774. * @param scene defines the scene the material belongs to.
  101775. * @param isFrozen defines wether the material is frozen or not.
  101776. */
  101777. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  101778. /**
  101779. * Checks to see if a texture is used in the material.
  101780. * @param texture - Base texture to use.
  101781. * @returns - Boolean specifying if a texture is used in the material.
  101782. */
  101783. hasTexture(texture: BaseTexture): boolean;
  101784. /**
  101785. * Returns an array of the actively used textures.
  101786. * @param activeTextures Array of BaseTextures
  101787. */
  101788. getActiveTextures(activeTextures: BaseTexture[]): void;
  101789. /**
  101790. * Returns the animatable textures.
  101791. * @param animatables Array of animatable textures.
  101792. */
  101793. getAnimatables(animatables: IAnimatable[]): void;
  101794. /**
  101795. * Disposes the resources of the material.
  101796. * @param forceDisposeTextures - Forces the disposal of all textures.
  101797. */
  101798. dispose(forceDisposeTextures?: boolean): void;
  101799. /**
  101800. * Get the current class name of the texture useful for serialization or dynamic coding.
  101801. * @returns "PBRAnisotropicConfiguration"
  101802. */
  101803. getClassName(): string;
  101804. /**
  101805. * Add fallbacks to the effect fallbacks list.
  101806. * @param defines defines the Base texture to use.
  101807. * @param fallbacks defines the current fallback list.
  101808. * @param currentRank defines the current fallback rank.
  101809. * @returns the new fallback rank.
  101810. */
  101811. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  101812. /**
  101813. * Add the required uniforms to the current list.
  101814. * @param uniforms defines the current uniform list.
  101815. */
  101816. static AddUniforms(uniforms: string[]): void;
  101817. /**
  101818. * Add the required uniforms to the current buffer.
  101819. * @param uniformBuffer defines the current uniform buffer.
  101820. */
  101821. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  101822. /**
  101823. * Add the required samplers to the current list.
  101824. * @param samplers defines the current sampler list.
  101825. */
  101826. static AddSamplers(samplers: string[]): void;
  101827. /**
  101828. * Makes a duplicate of the current configuration into another one.
  101829. * @param anisotropicConfiguration define the config where to copy the info
  101830. */
  101831. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  101832. /**
  101833. * Serializes this anisotropy configuration.
  101834. * @returns - An object with the serialized config.
  101835. */
  101836. serialize(): any;
  101837. /**
  101838. * Parses a anisotropy Configuration from a serialized object.
  101839. * @param source - Serialized object.
  101840. */
  101841. parse(source: any): void;
  101842. }
  101843. }
  101844. declare module BABYLON {
  101845. /**
  101846. * @hidden
  101847. */
  101848. export interface IMaterialBRDFDefines {
  101849. BRDF_V_HEIGHT_CORRELATED: boolean;
  101850. MS_BRDF_ENERGY_CONSERVATION: boolean;
  101851. /** @hidden */
  101852. _areMiscDirty: boolean;
  101853. }
  101854. /**
  101855. * Define the code related to the BRDF parameters of the pbr material.
  101856. */
  101857. export class PBRBRDFConfiguration {
  101858. private _useEnergyConservation;
  101859. /**
  101860. * Defines if the material uses energy conservation.
  101861. */
  101862. useEnergyConservation: boolean;
  101863. private _useSmithVisibilityHeightCorrelated;
  101864. /**
  101865. * LEGACY Mode set to false
  101866. * Defines if the material uses height smith correlated visibility term.
  101867. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  101868. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  101869. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  101870. * Not relying on height correlated will also disable energy conservation.
  101871. */
  101872. useSmithVisibilityHeightCorrelated: boolean;
  101873. /** @hidden */
  101874. private _internalMarkAllSubMeshesAsMiscDirty;
  101875. /** @hidden */
  101876. _markAllSubMeshesAsMiscDirty(): void;
  101877. /**
  101878. * Instantiate a new istance of clear coat configuration.
  101879. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  101880. */
  101881. constructor(markAllSubMeshesAsMiscDirty: () => void);
  101882. /**
  101883. * Checks to see if a texture is used in the material.
  101884. * @param defines the list of "defines" to update.
  101885. */
  101886. prepareDefines(defines: IMaterialBRDFDefines): void;
  101887. /**
  101888. * Get the current class name of the texture useful for serialization or dynamic coding.
  101889. * @returns "PBRClearCoatConfiguration"
  101890. */
  101891. getClassName(): string;
  101892. /**
  101893. * Makes a duplicate of the current configuration into another one.
  101894. * @param brdfConfiguration define the config where to copy the info
  101895. */
  101896. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  101897. /**
  101898. * Serializes this BRDF configuration.
  101899. * @returns - An object with the serialized config.
  101900. */
  101901. serialize(): any;
  101902. /**
  101903. * Parses a BRDF Configuration from a serialized object.
  101904. * @param source - Serialized object.
  101905. */
  101906. parse(source: any): void;
  101907. }
  101908. }
  101909. declare module BABYLON {
  101910. /**
  101911. * @hidden
  101912. */
  101913. export interface IMaterialSheenDefines {
  101914. SHEEN: boolean;
  101915. SHEEN_TEXTURE: boolean;
  101916. SHEEN_TEXTUREDIRECTUV: number;
  101917. SHEEN_LINKWITHALBEDO: boolean;
  101918. /** @hidden */
  101919. _areTexturesDirty: boolean;
  101920. }
  101921. /**
  101922. * Define the code related to the Sheen parameters of the pbr material.
  101923. */
  101924. export class PBRSheenConfiguration {
  101925. private _isEnabled;
  101926. /**
  101927. * Defines if the material uses sheen.
  101928. */
  101929. isEnabled: boolean;
  101930. private _linkSheenWithAlbedo;
  101931. /**
  101932. * Defines if the sheen is linked to the sheen color.
  101933. */
  101934. linkSheenWithAlbedo: boolean;
  101935. /**
  101936. * Defines the sheen intensity.
  101937. */
  101938. intensity: number;
  101939. /**
  101940. * Defines the sheen color.
  101941. */
  101942. color: Color3;
  101943. private _texture;
  101944. /**
  101945. * Stores the sheen tint values in a texture.
  101946. * rgb is tint
  101947. * a is a intensity
  101948. */
  101949. texture: Nullable<BaseTexture>;
  101950. /** @hidden */
  101951. private _internalMarkAllSubMeshesAsTexturesDirty;
  101952. /** @hidden */
  101953. _markAllSubMeshesAsTexturesDirty(): void;
  101954. /**
  101955. * Instantiate a new istance of clear coat configuration.
  101956. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  101957. */
  101958. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  101959. /**
  101960. * Specifies that the submesh is ready to be used.
  101961. * @param defines the list of "defines" to update.
  101962. * @param scene defines the scene the material belongs to.
  101963. * @returns - boolean indicating that the submesh is ready or not.
  101964. */
  101965. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  101966. /**
  101967. * Checks to see if a texture is used in the material.
  101968. * @param defines the list of "defines" to update.
  101969. * @param scene defines the scene the material belongs to.
  101970. */
  101971. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  101972. /**
  101973. * Binds the material data.
  101974. * @param uniformBuffer defines the Uniform buffer to fill in.
  101975. * @param scene defines the scene the material belongs to.
  101976. * @param isFrozen defines wether the material is frozen or not.
  101977. */
  101978. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  101979. /**
  101980. * Checks to see if a texture is used in the material.
  101981. * @param texture - Base texture to use.
  101982. * @returns - Boolean specifying if a texture is used in the material.
  101983. */
  101984. hasTexture(texture: BaseTexture): boolean;
  101985. /**
  101986. * Returns an array of the actively used textures.
  101987. * @param activeTextures Array of BaseTextures
  101988. */
  101989. getActiveTextures(activeTextures: BaseTexture[]): void;
  101990. /**
  101991. * Returns the animatable textures.
  101992. * @param animatables Array of animatable textures.
  101993. */
  101994. getAnimatables(animatables: IAnimatable[]): void;
  101995. /**
  101996. * Disposes the resources of the material.
  101997. * @param forceDisposeTextures - Forces the disposal of all textures.
  101998. */
  101999. dispose(forceDisposeTextures?: boolean): void;
  102000. /**
  102001. * Get the current class name of the texture useful for serialization or dynamic coding.
  102002. * @returns "PBRSheenConfiguration"
  102003. */
  102004. getClassName(): string;
  102005. /**
  102006. * Add fallbacks to the effect fallbacks list.
  102007. * @param defines defines the Base texture to use.
  102008. * @param fallbacks defines the current fallback list.
  102009. * @param currentRank defines the current fallback rank.
  102010. * @returns the new fallback rank.
  102011. */
  102012. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  102013. /**
  102014. * Add the required uniforms to the current list.
  102015. * @param uniforms defines the current uniform list.
  102016. */
  102017. static AddUniforms(uniforms: string[]): void;
  102018. /**
  102019. * Add the required uniforms to the current buffer.
  102020. * @param uniformBuffer defines the current uniform buffer.
  102021. */
  102022. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  102023. /**
  102024. * Add the required samplers to the current list.
  102025. * @param samplers defines the current sampler list.
  102026. */
  102027. static AddSamplers(samplers: string[]): void;
  102028. /**
  102029. * Makes a duplicate of the current configuration into another one.
  102030. * @param sheenConfiguration define the config where to copy the info
  102031. */
  102032. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  102033. /**
  102034. * Serializes this BRDF configuration.
  102035. * @returns - An object with the serialized config.
  102036. */
  102037. serialize(): any;
  102038. /**
  102039. * Parses a Sheen Configuration from a serialized object.
  102040. * @param source - Serialized object.
  102041. */
  102042. parse(source: any): void;
  102043. }
  102044. }
  102045. declare module BABYLON {
  102046. /** @hidden */
  102047. export var pbrFragmentDeclaration: {
  102048. name: string;
  102049. shader: string;
  102050. };
  102051. }
  102052. declare module BABYLON {
  102053. /** @hidden */
  102054. export var pbrUboDeclaration: {
  102055. name: string;
  102056. shader: string;
  102057. };
  102058. }
  102059. declare module BABYLON {
  102060. /** @hidden */
  102061. export var pbrFragmentExtraDeclaration: {
  102062. name: string;
  102063. shader: string;
  102064. };
  102065. }
  102066. declare module BABYLON {
  102067. /** @hidden */
  102068. export var pbrFragmentSamplersDeclaration: {
  102069. name: string;
  102070. shader: string;
  102071. };
  102072. }
  102073. declare module BABYLON {
  102074. /** @hidden */
  102075. export var pbrHelperFunctions: {
  102076. name: string;
  102077. shader: string;
  102078. };
  102079. }
  102080. declare module BABYLON {
  102081. /** @hidden */
  102082. export var harmonicsFunctions: {
  102083. name: string;
  102084. shader: string;
  102085. };
  102086. }
  102087. declare module BABYLON {
  102088. /** @hidden */
  102089. export var pbrDirectLightingSetupFunctions: {
  102090. name: string;
  102091. shader: string;
  102092. };
  102093. }
  102094. declare module BABYLON {
  102095. /** @hidden */
  102096. export var pbrDirectLightingFalloffFunctions: {
  102097. name: string;
  102098. shader: string;
  102099. };
  102100. }
  102101. declare module BABYLON {
  102102. /** @hidden */
  102103. export var pbrBRDFFunctions: {
  102104. name: string;
  102105. shader: string;
  102106. };
  102107. }
  102108. declare module BABYLON {
  102109. /** @hidden */
  102110. export var pbrDirectLightingFunctions: {
  102111. name: string;
  102112. shader: string;
  102113. };
  102114. }
  102115. declare module BABYLON {
  102116. /** @hidden */
  102117. export var pbrIBLFunctions: {
  102118. name: string;
  102119. shader: string;
  102120. };
  102121. }
  102122. declare module BABYLON {
  102123. /** @hidden */
  102124. export var pbrDebug: {
  102125. name: string;
  102126. shader: string;
  102127. };
  102128. }
  102129. declare module BABYLON {
  102130. /** @hidden */
  102131. export var pbrPixelShader: {
  102132. name: string;
  102133. shader: string;
  102134. };
  102135. }
  102136. declare module BABYLON {
  102137. /** @hidden */
  102138. export var pbrVertexDeclaration: {
  102139. name: string;
  102140. shader: string;
  102141. };
  102142. }
  102143. declare module BABYLON {
  102144. /** @hidden */
  102145. export var pbrVertexShader: {
  102146. name: string;
  102147. shader: string;
  102148. };
  102149. }
  102150. declare module BABYLON {
  102151. /**
  102152. * The Physically based material base class of BJS.
  102153. *
  102154. * This offers the main features of a standard PBR material.
  102155. * For more information, please refer to the documentation :
  102156. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  102157. */
  102158. export abstract class PBRBaseMaterial extends PushMaterial {
  102159. /**
  102160. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  102161. */
  102162. static readonly PBRMATERIAL_OPAQUE: number;
  102163. /**
  102164. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  102165. */
  102166. static readonly PBRMATERIAL_ALPHATEST: number;
  102167. /**
  102168. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  102169. */
  102170. static readonly PBRMATERIAL_ALPHABLEND: number;
  102171. /**
  102172. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  102173. * They are also discarded below the alpha cutoff threshold to improve performances.
  102174. */
  102175. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  102176. /**
  102177. * Defines the default value of how much AO map is occluding the analytical lights
  102178. * (point spot...).
  102179. */
  102180. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  102181. /**
  102182. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  102183. */
  102184. static readonly LIGHTFALLOFF_PHYSICAL: number;
  102185. /**
  102186. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  102187. * to enhance interoperability with other engines.
  102188. */
  102189. static readonly LIGHTFALLOFF_GLTF: number;
  102190. /**
  102191. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  102192. * to enhance interoperability with other materials.
  102193. */
  102194. static readonly LIGHTFALLOFF_STANDARD: number;
  102195. /**
  102196. * Intensity of the direct lights e.g. the four lights available in your scene.
  102197. * This impacts both the direct diffuse and specular highlights.
  102198. */
  102199. protected _directIntensity: number;
  102200. /**
  102201. * Intensity of the emissive part of the material.
  102202. * This helps controlling the emissive effect without modifying the emissive color.
  102203. */
  102204. protected _emissiveIntensity: number;
  102205. /**
  102206. * Intensity of the environment e.g. how much the environment will light the object
  102207. * either through harmonics for rough material or through the refelction for shiny ones.
  102208. */
  102209. protected _environmentIntensity: number;
  102210. /**
  102211. * This is a special control allowing the reduction of the specular highlights coming from the
  102212. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  102213. */
  102214. protected _specularIntensity: number;
  102215. /**
  102216. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  102217. */
  102218. private _lightingInfos;
  102219. /**
  102220. * Debug Control allowing disabling the bump map on this material.
  102221. */
  102222. protected _disableBumpMap: boolean;
  102223. /**
  102224. * AKA Diffuse Texture in standard nomenclature.
  102225. */
  102226. protected _albedoTexture: BaseTexture;
  102227. /**
  102228. * AKA Occlusion Texture in other nomenclature.
  102229. */
  102230. protected _ambientTexture: BaseTexture;
  102231. /**
  102232. * AKA Occlusion Texture Intensity in other nomenclature.
  102233. */
  102234. protected _ambientTextureStrength: number;
  102235. /**
  102236. * Defines how much the AO map is occluding the analytical lights (point spot...).
  102237. * 1 means it completely occludes it
  102238. * 0 mean it has no impact
  102239. */
  102240. protected _ambientTextureImpactOnAnalyticalLights: number;
  102241. /**
  102242. * Stores the alpha values in a texture.
  102243. */
  102244. protected _opacityTexture: BaseTexture;
  102245. /**
  102246. * Stores the reflection values in a texture.
  102247. */
  102248. protected _reflectionTexture: BaseTexture;
  102249. /**
  102250. * Stores the refraction values in a texture.
  102251. */
  102252. protected _refractionTexture: BaseTexture;
  102253. /**
  102254. * Stores the emissive values in a texture.
  102255. */
  102256. protected _emissiveTexture: BaseTexture;
  102257. /**
  102258. * AKA Specular texture in other nomenclature.
  102259. */
  102260. protected _reflectivityTexture: BaseTexture;
  102261. /**
  102262. * Used to switch from specular/glossiness to metallic/roughness workflow.
  102263. */
  102264. protected _metallicTexture: BaseTexture;
  102265. /**
  102266. * Specifies the metallic scalar of the metallic/roughness workflow.
  102267. * Can also be used to scale the metalness values of the metallic texture.
  102268. */
  102269. protected _metallic: Nullable<number>;
  102270. /**
  102271. * Specifies the roughness scalar of the metallic/roughness workflow.
  102272. * Can also be used to scale the roughness values of the metallic texture.
  102273. */
  102274. protected _roughness: Nullable<number>;
  102275. /**
  102276. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  102277. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  102278. */
  102279. protected _microSurfaceTexture: BaseTexture;
  102280. /**
  102281. * Stores surface normal data used to displace a mesh in a texture.
  102282. */
  102283. protected _bumpTexture: BaseTexture;
  102284. /**
  102285. * Stores the pre-calculated light information of a mesh in a texture.
  102286. */
  102287. protected _lightmapTexture: BaseTexture;
  102288. /**
  102289. * The color of a material in ambient lighting.
  102290. */
  102291. protected _ambientColor: Color3;
  102292. /**
  102293. * AKA Diffuse Color in other nomenclature.
  102294. */
  102295. protected _albedoColor: Color3;
  102296. /**
  102297. * AKA Specular Color in other nomenclature.
  102298. */
  102299. protected _reflectivityColor: Color3;
  102300. /**
  102301. * The color applied when light is reflected from a material.
  102302. */
  102303. protected _reflectionColor: Color3;
  102304. /**
  102305. * The color applied when light is emitted from a material.
  102306. */
  102307. protected _emissiveColor: Color3;
  102308. /**
  102309. * AKA Glossiness in other nomenclature.
  102310. */
  102311. protected _microSurface: number;
  102312. /**
  102313. * source material index of refraction (IOR)' / 'destination material IOR.
  102314. */
  102315. protected _indexOfRefraction: number;
  102316. /**
  102317. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  102318. */
  102319. protected _invertRefractionY: boolean;
  102320. /**
  102321. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  102322. * Materials half opaque for instance using refraction could benefit from this control.
  102323. */
  102324. protected _linkRefractionWithTransparency: boolean;
  102325. /**
  102326. * Specifies that the material will use the light map as a show map.
  102327. */
  102328. protected _useLightmapAsShadowmap: boolean;
  102329. /**
  102330. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  102331. * makes the reflect vector face the model (under horizon).
  102332. */
  102333. protected _useHorizonOcclusion: boolean;
  102334. /**
  102335. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  102336. * too much the area relying on ambient texture to define their ambient occlusion.
  102337. */
  102338. protected _useRadianceOcclusion: boolean;
  102339. /**
  102340. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  102341. */
  102342. protected _useAlphaFromAlbedoTexture: boolean;
  102343. /**
  102344. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  102345. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  102346. */
  102347. protected _useSpecularOverAlpha: boolean;
  102348. /**
  102349. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  102350. */
  102351. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  102352. /**
  102353. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  102354. */
  102355. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  102356. /**
  102357. * Specifies if the metallic texture contains the roughness information in its green channel.
  102358. */
  102359. protected _useRoughnessFromMetallicTextureGreen: boolean;
  102360. /**
  102361. * Specifies if the metallic texture contains the metallness information in its blue channel.
  102362. */
  102363. protected _useMetallnessFromMetallicTextureBlue: boolean;
  102364. /**
  102365. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  102366. */
  102367. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  102368. /**
  102369. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  102370. */
  102371. protected _useAmbientInGrayScale: boolean;
  102372. /**
  102373. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  102374. * The material will try to infer what glossiness each pixel should be.
  102375. */
  102376. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  102377. /**
  102378. * Defines the falloff type used in this material.
  102379. * It by default is Physical.
  102380. */
  102381. protected _lightFalloff: number;
  102382. /**
  102383. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  102384. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  102385. */
  102386. protected _useRadianceOverAlpha: boolean;
  102387. /**
  102388. * Allows using an object space normal map (instead of tangent space).
  102389. */
  102390. protected _useObjectSpaceNormalMap: boolean;
  102391. /**
  102392. * Allows using the bump map in parallax mode.
  102393. */
  102394. protected _useParallax: boolean;
  102395. /**
  102396. * Allows using the bump map in parallax occlusion mode.
  102397. */
  102398. protected _useParallaxOcclusion: boolean;
  102399. /**
  102400. * Controls the scale bias of the parallax mode.
  102401. */
  102402. protected _parallaxScaleBias: number;
  102403. /**
  102404. * If sets to true, disables all the lights affecting the material.
  102405. */
  102406. protected _disableLighting: boolean;
  102407. /**
  102408. * Number of Simultaneous lights allowed on the material.
  102409. */
  102410. protected _maxSimultaneousLights: number;
  102411. /**
  102412. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  102413. */
  102414. protected _invertNormalMapX: boolean;
  102415. /**
  102416. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  102417. */
  102418. protected _invertNormalMapY: boolean;
  102419. /**
  102420. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  102421. */
  102422. protected _twoSidedLighting: boolean;
  102423. /**
  102424. * Defines the alpha limits in alpha test mode.
  102425. */
  102426. protected _alphaCutOff: number;
  102427. /**
  102428. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  102429. */
  102430. protected _forceAlphaTest: boolean;
  102431. /**
  102432. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  102433. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  102434. */
  102435. protected _useAlphaFresnel: boolean;
  102436. /**
  102437. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  102438. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  102439. */
  102440. protected _useLinearAlphaFresnel: boolean;
  102441. /**
  102442. * The transparency mode of the material.
  102443. */
  102444. protected _transparencyMode: Nullable<number>;
  102445. /**
  102446. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  102447. * from cos thetav and roughness:
  102448. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  102449. */
  102450. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  102451. /**
  102452. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  102453. */
  102454. protected _forceIrradianceInFragment: boolean;
  102455. /**
  102456. * Force normal to face away from face.
  102457. */
  102458. protected _forceNormalForward: boolean;
  102459. /**
  102460. * Enables specular anti aliasing in the PBR shader.
  102461. * It will both interacts on the Geometry for analytical and IBL lighting.
  102462. * It also prefilter the roughness map based on the bump values.
  102463. */
  102464. protected _enableSpecularAntiAliasing: boolean;
  102465. /**
  102466. * Default configuration related to image processing available in the PBR Material.
  102467. */
  102468. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102469. /**
  102470. * Keep track of the image processing observer to allow dispose and replace.
  102471. */
  102472. private _imageProcessingObserver;
  102473. /**
  102474. * Attaches a new image processing configuration to the PBR Material.
  102475. * @param configuration
  102476. */
  102477. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102478. /**
  102479. * Stores the available render targets.
  102480. */
  102481. private _renderTargets;
  102482. /**
  102483. * Sets the global ambient color for the material used in lighting calculations.
  102484. */
  102485. private _globalAmbientColor;
  102486. /**
  102487. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  102488. */
  102489. private _useLogarithmicDepth;
  102490. /**
  102491. * If set to true, no lighting calculations will be applied.
  102492. */
  102493. private _unlit;
  102494. private _debugMode;
  102495. /**
  102496. * @hidden
  102497. * This is reserved for the inspector.
  102498. * Defines the material debug mode.
  102499. * It helps seeing only some components of the material while troubleshooting.
  102500. */
  102501. debugMode: number;
  102502. /**
  102503. * @hidden
  102504. * This is reserved for the inspector.
  102505. * Specify from where on screen the debug mode should start.
  102506. * The value goes from -1 (full screen) to 1 (not visible)
  102507. * It helps with side by side comparison against the final render
  102508. * This defaults to -1
  102509. */
  102510. private debugLimit;
  102511. /**
  102512. * @hidden
  102513. * This is reserved for the inspector.
  102514. * As the default viewing range might not be enough (if the ambient is really small for instance)
  102515. * You can use the factor to better multiply the final value.
  102516. */
  102517. private debugFactor;
  102518. /**
  102519. * Defines the clear coat layer parameters for the material.
  102520. */
  102521. readonly clearCoat: PBRClearCoatConfiguration;
  102522. /**
  102523. * Defines the anisotropic parameters for the material.
  102524. */
  102525. readonly anisotropy: PBRAnisotropicConfiguration;
  102526. /**
  102527. * Defines the BRDF parameters for the material.
  102528. */
  102529. readonly brdf: PBRBRDFConfiguration;
  102530. /**
  102531. * Defines the Sheen parameters for the material.
  102532. */
  102533. readonly sheen: PBRSheenConfiguration;
  102534. /**
  102535. * Instantiates a new PBRMaterial instance.
  102536. *
  102537. * @param name The material name
  102538. * @param scene The scene the material will be use in.
  102539. */
  102540. constructor(name: string, scene: Scene);
  102541. /**
  102542. * Gets a boolean indicating that current material needs to register RTT
  102543. */
  102544. readonly hasRenderTargetTextures: boolean;
  102545. /**
  102546. * Gets the name of the material class.
  102547. */
  102548. getClassName(): string;
  102549. /**
  102550. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  102551. */
  102552. /**
  102553. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  102554. */
  102555. useLogarithmicDepth: boolean;
  102556. /**
  102557. * Gets the current transparency mode.
  102558. */
  102559. /**
  102560. * Sets the transparency mode of the material.
  102561. *
  102562. * | Value | Type | Description |
  102563. * | ----- | ----------------------------------- | ----------- |
  102564. * | 0 | OPAQUE | |
  102565. * | 1 | ALPHATEST | |
  102566. * | 2 | ALPHABLEND | |
  102567. * | 3 | ALPHATESTANDBLEND | |
  102568. *
  102569. */
  102570. transparencyMode: Nullable<number>;
  102571. /**
  102572. * Returns true if alpha blending should be disabled.
  102573. */
  102574. private readonly _disableAlphaBlending;
  102575. /**
  102576. * Specifies whether or not this material should be rendered in alpha blend mode.
  102577. */
  102578. needAlphaBlending(): boolean;
  102579. /**
  102580. * Specifies if the mesh will require alpha blending.
  102581. * @param mesh - BJS mesh.
  102582. */
  102583. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  102584. /**
  102585. * Specifies whether or not this material should be rendered in alpha test mode.
  102586. */
  102587. needAlphaTesting(): boolean;
  102588. /**
  102589. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  102590. */
  102591. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  102592. /**
  102593. * Gets the texture used for the alpha test.
  102594. */
  102595. getAlphaTestTexture(): BaseTexture;
  102596. /**
  102597. * Specifies that the submesh is ready to be used.
  102598. * @param mesh - BJS mesh.
  102599. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  102600. * @param useInstances - Specifies that instances should be used.
  102601. * @returns - boolean indicating that the submesh is ready or not.
  102602. */
  102603. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102604. /**
  102605. * Specifies if the material uses metallic roughness workflow.
  102606. * @returns boolean specifiying if the material uses metallic roughness workflow.
  102607. */
  102608. isMetallicWorkflow(): boolean;
  102609. private _prepareEffect;
  102610. private _prepareDefines;
  102611. /**
  102612. * Force shader compilation
  102613. */
  102614. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  102615. clipPlane: boolean;
  102616. }>): void;
  102617. /**
  102618. * Initializes the uniform buffer layout for the shader.
  102619. */
  102620. buildUniformLayout(): void;
  102621. /**
  102622. * Unbinds the textures.
  102623. */
  102624. unbind(): void;
  102625. /**
  102626. * Binds the submesh data.
  102627. * @param world - The world matrix.
  102628. * @param mesh - The BJS mesh.
  102629. * @param subMesh - A submesh of the BJS mesh.
  102630. */
  102631. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102632. /**
  102633. * Returns the animatable textures.
  102634. * @returns - Array of animatable textures.
  102635. */
  102636. getAnimatables(): IAnimatable[];
  102637. /**
  102638. * Returns the texture used for reflections.
  102639. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  102640. */
  102641. private _getReflectionTexture;
  102642. /**
  102643. * Returns the texture used for refraction or null if none is used.
  102644. * @returns - Refection texture if present. If no refraction texture and refraction
  102645. * is linked with transparency, returns environment texture. Otherwise, returns null.
  102646. */
  102647. private _getRefractionTexture;
  102648. /**
  102649. * Returns an array of the actively used textures.
  102650. * @returns - Array of BaseTextures
  102651. */
  102652. getActiveTextures(): BaseTexture[];
  102653. /**
  102654. * Checks to see if a texture is used in the material.
  102655. * @param texture - Base texture to use.
  102656. * @returns - Boolean specifying if a texture is used in the material.
  102657. */
  102658. hasTexture(texture: BaseTexture): boolean;
  102659. /**
  102660. * Disposes the resources of the material.
  102661. * @param forceDisposeEffect - Forces the disposal of effects.
  102662. * @param forceDisposeTextures - Forces the disposal of all textures.
  102663. */
  102664. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  102665. }
  102666. }
  102667. declare module BABYLON {
  102668. /**
  102669. * The Physically based material of BJS.
  102670. *
  102671. * This offers the main features of a standard PBR material.
  102672. * For more information, please refer to the documentation :
  102673. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  102674. */
  102675. export class PBRMaterial extends PBRBaseMaterial {
  102676. /**
  102677. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  102678. */
  102679. static readonly PBRMATERIAL_OPAQUE: number;
  102680. /**
  102681. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  102682. */
  102683. static readonly PBRMATERIAL_ALPHATEST: number;
  102684. /**
  102685. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  102686. */
  102687. static readonly PBRMATERIAL_ALPHABLEND: number;
  102688. /**
  102689. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  102690. * They are also discarded below the alpha cutoff threshold to improve performances.
  102691. */
  102692. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  102693. /**
  102694. * Defines the default value of how much AO map is occluding the analytical lights
  102695. * (point spot...).
  102696. */
  102697. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  102698. /**
  102699. * Intensity of the direct lights e.g. the four lights available in your scene.
  102700. * This impacts both the direct diffuse and specular highlights.
  102701. */
  102702. directIntensity: number;
  102703. /**
  102704. * Intensity of the emissive part of the material.
  102705. * This helps controlling the emissive effect without modifying the emissive color.
  102706. */
  102707. emissiveIntensity: number;
  102708. /**
  102709. * Intensity of the environment e.g. how much the environment will light the object
  102710. * either through harmonics for rough material or through the refelction for shiny ones.
  102711. */
  102712. environmentIntensity: number;
  102713. /**
  102714. * This is a special control allowing the reduction of the specular highlights coming from the
  102715. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  102716. */
  102717. specularIntensity: number;
  102718. /**
  102719. * Debug Control allowing disabling the bump map on this material.
  102720. */
  102721. disableBumpMap: boolean;
  102722. /**
  102723. * AKA Diffuse Texture in standard nomenclature.
  102724. */
  102725. albedoTexture: BaseTexture;
  102726. /**
  102727. * AKA Occlusion Texture in other nomenclature.
  102728. */
  102729. ambientTexture: BaseTexture;
  102730. /**
  102731. * AKA Occlusion Texture Intensity in other nomenclature.
  102732. */
  102733. ambientTextureStrength: number;
  102734. /**
  102735. * Defines how much the AO map is occluding the analytical lights (point spot...).
  102736. * 1 means it completely occludes it
  102737. * 0 mean it has no impact
  102738. */
  102739. ambientTextureImpactOnAnalyticalLights: number;
  102740. /**
  102741. * Stores the alpha values in a texture.
  102742. */
  102743. opacityTexture: BaseTexture;
  102744. /**
  102745. * Stores the reflection values in a texture.
  102746. */
  102747. reflectionTexture: Nullable<BaseTexture>;
  102748. /**
  102749. * Stores the emissive values in a texture.
  102750. */
  102751. emissiveTexture: BaseTexture;
  102752. /**
  102753. * AKA Specular texture in other nomenclature.
  102754. */
  102755. reflectivityTexture: BaseTexture;
  102756. /**
  102757. * Used to switch from specular/glossiness to metallic/roughness workflow.
  102758. */
  102759. metallicTexture: BaseTexture;
  102760. /**
  102761. * Specifies the metallic scalar of the metallic/roughness workflow.
  102762. * Can also be used to scale the metalness values of the metallic texture.
  102763. */
  102764. metallic: Nullable<number>;
  102765. /**
  102766. * Specifies the roughness scalar of the metallic/roughness workflow.
  102767. * Can also be used to scale the roughness values of the metallic texture.
  102768. */
  102769. roughness: Nullable<number>;
  102770. /**
  102771. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  102772. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  102773. */
  102774. microSurfaceTexture: BaseTexture;
  102775. /**
  102776. * Stores surface normal data used to displace a mesh in a texture.
  102777. */
  102778. bumpTexture: BaseTexture;
  102779. /**
  102780. * Stores the pre-calculated light information of a mesh in a texture.
  102781. */
  102782. lightmapTexture: BaseTexture;
  102783. /**
  102784. * Stores the refracted light information in a texture.
  102785. */
  102786. refractionTexture: BaseTexture;
  102787. /**
  102788. * The color of a material in ambient lighting.
  102789. */
  102790. ambientColor: Color3;
  102791. /**
  102792. * AKA Diffuse Color in other nomenclature.
  102793. */
  102794. albedoColor: Color3;
  102795. /**
  102796. * AKA Specular Color in other nomenclature.
  102797. */
  102798. reflectivityColor: Color3;
  102799. /**
  102800. * The color reflected from the material.
  102801. */
  102802. reflectionColor: Color3;
  102803. /**
  102804. * The color emitted from the material.
  102805. */
  102806. emissiveColor: Color3;
  102807. /**
  102808. * AKA Glossiness in other nomenclature.
  102809. */
  102810. microSurface: number;
  102811. /**
  102812. * source material index of refraction (IOR)' / 'destination material IOR.
  102813. */
  102814. indexOfRefraction: number;
  102815. /**
  102816. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  102817. */
  102818. invertRefractionY: boolean;
  102819. /**
  102820. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  102821. * Materials half opaque for instance using refraction could benefit from this control.
  102822. */
  102823. linkRefractionWithTransparency: boolean;
  102824. /**
  102825. * If true, the light map contains occlusion information instead of lighting info.
  102826. */
  102827. useLightmapAsShadowmap: boolean;
  102828. /**
  102829. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  102830. */
  102831. useAlphaFromAlbedoTexture: boolean;
  102832. /**
  102833. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  102834. */
  102835. forceAlphaTest: boolean;
  102836. /**
  102837. * Defines the alpha limits in alpha test mode.
  102838. */
  102839. alphaCutOff: number;
  102840. /**
  102841. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  102842. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  102843. */
  102844. useSpecularOverAlpha: boolean;
  102845. /**
  102846. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  102847. */
  102848. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  102849. /**
  102850. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  102851. */
  102852. useRoughnessFromMetallicTextureAlpha: boolean;
  102853. /**
  102854. * Specifies if the metallic texture contains the roughness information in its green channel.
  102855. */
  102856. useRoughnessFromMetallicTextureGreen: boolean;
  102857. /**
  102858. * Specifies if the metallic texture contains the metallness information in its blue channel.
  102859. */
  102860. useMetallnessFromMetallicTextureBlue: boolean;
  102861. /**
  102862. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  102863. */
  102864. useAmbientOcclusionFromMetallicTextureRed: boolean;
  102865. /**
  102866. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  102867. */
  102868. useAmbientInGrayScale: boolean;
  102869. /**
  102870. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  102871. * The material will try to infer what glossiness each pixel should be.
  102872. */
  102873. useAutoMicroSurfaceFromReflectivityMap: boolean;
  102874. /**
  102875. * BJS is using an harcoded light falloff based on a manually sets up range.
  102876. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  102877. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  102878. */
  102879. /**
  102880. * BJS is using an harcoded light falloff based on a manually sets up range.
  102881. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  102882. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  102883. */
  102884. usePhysicalLightFalloff: boolean;
  102885. /**
  102886. * In order to support the falloff compatibility with gltf, a special mode has been added
  102887. * to reproduce the gltf light falloff.
  102888. */
  102889. /**
  102890. * In order to support the falloff compatibility with gltf, a special mode has been added
  102891. * to reproduce the gltf light falloff.
  102892. */
  102893. useGLTFLightFalloff: boolean;
  102894. /**
  102895. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  102896. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  102897. */
  102898. useRadianceOverAlpha: boolean;
  102899. /**
  102900. * Allows using an object space normal map (instead of tangent space).
  102901. */
  102902. useObjectSpaceNormalMap: boolean;
  102903. /**
  102904. * Allows using the bump map in parallax mode.
  102905. */
  102906. useParallax: boolean;
  102907. /**
  102908. * Allows using the bump map in parallax occlusion mode.
  102909. */
  102910. useParallaxOcclusion: boolean;
  102911. /**
  102912. * Controls the scale bias of the parallax mode.
  102913. */
  102914. parallaxScaleBias: number;
  102915. /**
  102916. * If sets to true, disables all the lights affecting the material.
  102917. */
  102918. disableLighting: boolean;
  102919. /**
  102920. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  102921. */
  102922. forceIrradianceInFragment: boolean;
  102923. /**
  102924. * Number of Simultaneous lights allowed on the material.
  102925. */
  102926. maxSimultaneousLights: number;
  102927. /**
  102928. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  102929. */
  102930. invertNormalMapX: boolean;
  102931. /**
  102932. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  102933. */
  102934. invertNormalMapY: boolean;
  102935. /**
  102936. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  102937. */
  102938. twoSidedLighting: boolean;
  102939. /**
  102940. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  102941. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  102942. */
  102943. useAlphaFresnel: boolean;
  102944. /**
  102945. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  102946. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  102947. */
  102948. useLinearAlphaFresnel: boolean;
  102949. /**
  102950. * Let user defines the brdf lookup texture used for IBL.
  102951. * A default 8bit version is embedded but you could point at :
  102952. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  102953. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  102954. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  102955. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  102956. */
  102957. environmentBRDFTexture: Nullable<BaseTexture>;
  102958. /**
  102959. * Force normal to face away from face.
  102960. */
  102961. forceNormalForward: boolean;
  102962. /**
  102963. * Enables specular anti aliasing in the PBR shader.
  102964. * It will both interacts on the Geometry for analytical and IBL lighting.
  102965. * It also prefilter the roughness map based on the bump values.
  102966. */
  102967. enableSpecularAntiAliasing: boolean;
  102968. /**
  102969. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  102970. * makes the reflect vector face the model (under horizon).
  102971. */
  102972. useHorizonOcclusion: boolean;
  102973. /**
  102974. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  102975. * too much the area relying on ambient texture to define their ambient occlusion.
  102976. */
  102977. useRadianceOcclusion: boolean;
  102978. /**
  102979. * If set to true, no lighting calculations will be applied.
  102980. */
  102981. unlit: boolean;
  102982. /**
  102983. * Gets the image processing configuration used either in this material.
  102984. */
  102985. /**
  102986. * Sets the Default image processing configuration used either in the this material.
  102987. *
  102988. * If sets to null, the scene one is in use.
  102989. */
  102990. imageProcessingConfiguration: ImageProcessingConfiguration;
  102991. /**
  102992. * Gets wether the color curves effect is enabled.
  102993. */
  102994. /**
  102995. * Sets wether the color curves effect is enabled.
  102996. */
  102997. cameraColorCurvesEnabled: boolean;
  102998. /**
  102999. * Gets wether the color grading effect is enabled.
  103000. */
  103001. /**
  103002. * Gets wether the color grading effect is enabled.
  103003. */
  103004. cameraColorGradingEnabled: boolean;
  103005. /**
  103006. * Gets wether tonemapping is enabled or not.
  103007. */
  103008. /**
  103009. * Sets wether tonemapping is enabled or not
  103010. */
  103011. cameraToneMappingEnabled: boolean;
  103012. /**
  103013. * The camera exposure used on this material.
  103014. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103015. * This corresponds to a photographic exposure.
  103016. */
  103017. /**
  103018. * The camera exposure used on this material.
  103019. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103020. * This corresponds to a photographic exposure.
  103021. */
  103022. cameraExposure: number;
  103023. /**
  103024. * Gets The camera contrast used on this material.
  103025. */
  103026. /**
  103027. * Sets The camera contrast used on this material.
  103028. */
  103029. cameraContrast: number;
  103030. /**
  103031. * Gets the Color Grading 2D Lookup Texture.
  103032. */
  103033. /**
  103034. * Sets the Color Grading 2D Lookup Texture.
  103035. */
  103036. cameraColorGradingTexture: Nullable<BaseTexture>;
  103037. /**
  103038. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103039. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103040. * 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;
  103041. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103042. */
  103043. /**
  103044. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103045. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103046. * 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;
  103047. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103048. */
  103049. cameraColorCurves: Nullable<ColorCurves>;
  103050. /**
  103051. * Instantiates a new PBRMaterial instance.
  103052. *
  103053. * @param name The material name
  103054. * @param scene The scene the material will be use in.
  103055. */
  103056. constructor(name: string, scene: Scene);
  103057. /**
  103058. * Returns the name of this material class.
  103059. */
  103060. getClassName(): string;
  103061. /**
  103062. * Makes a duplicate of the current material.
  103063. * @param name - name to use for the new material.
  103064. */
  103065. clone(name: string): PBRMaterial;
  103066. /**
  103067. * Serializes this PBR Material.
  103068. * @returns - An object with the serialized material.
  103069. */
  103070. serialize(): any;
  103071. /**
  103072. * Parses a PBR Material from a serialized object.
  103073. * @param source - Serialized object.
  103074. * @param scene - BJS scene instance.
  103075. * @param rootUrl - url for the scene object
  103076. * @returns - PBRMaterial
  103077. */
  103078. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  103079. }
  103080. }
  103081. declare module BABYLON {
  103082. /**
  103083. * Direct draw surface info
  103084. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  103085. */
  103086. export interface DDSInfo {
  103087. /**
  103088. * Width of the texture
  103089. */
  103090. width: number;
  103091. /**
  103092. * Width of the texture
  103093. */
  103094. height: number;
  103095. /**
  103096. * Number of Mipmaps for the texture
  103097. * @see https://en.wikipedia.org/wiki/Mipmap
  103098. */
  103099. mipmapCount: number;
  103100. /**
  103101. * If the textures format is a known fourCC format
  103102. * @see https://www.fourcc.org/
  103103. */
  103104. isFourCC: boolean;
  103105. /**
  103106. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  103107. */
  103108. isRGB: boolean;
  103109. /**
  103110. * If the texture is a lumincance format
  103111. */
  103112. isLuminance: boolean;
  103113. /**
  103114. * If this is a cube texture
  103115. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  103116. */
  103117. isCube: boolean;
  103118. /**
  103119. * If the texture is a compressed format eg. FOURCC_DXT1
  103120. */
  103121. isCompressed: boolean;
  103122. /**
  103123. * The dxgiFormat of the texture
  103124. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  103125. */
  103126. dxgiFormat: number;
  103127. /**
  103128. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  103129. */
  103130. textureType: number;
  103131. /**
  103132. * Sphericle polynomial created for the dds texture
  103133. */
  103134. sphericalPolynomial?: SphericalPolynomial;
  103135. }
  103136. /**
  103137. * Class used to provide DDS decompression tools
  103138. */
  103139. export class DDSTools {
  103140. /**
  103141. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  103142. */
  103143. static StoreLODInAlphaChannel: boolean;
  103144. /**
  103145. * Gets DDS information from an array buffer
  103146. * @param arrayBuffer defines the array buffer to read data from
  103147. * @returns the DDS information
  103148. */
  103149. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  103150. private static _FloatView;
  103151. private static _Int32View;
  103152. private static _ToHalfFloat;
  103153. private static _FromHalfFloat;
  103154. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  103155. private static _GetHalfFloatRGBAArrayBuffer;
  103156. private static _GetFloatRGBAArrayBuffer;
  103157. private static _GetFloatAsUIntRGBAArrayBuffer;
  103158. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  103159. private static _GetRGBAArrayBuffer;
  103160. private static _ExtractLongWordOrder;
  103161. private static _GetRGBArrayBuffer;
  103162. private static _GetLuminanceArrayBuffer;
  103163. /**
  103164. * Uploads DDS Levels to a Babylon Texture
  103165. * @hidden
  103166. */
  103167. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  103168. }
  103169. interface Engine {
  103170. /**
  103171. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  103172. * @param rootUrl defines the url where the file to load is located
  103173. * @param scene defines the current scene
  103174. * @param lodScale defines scale to apply to the mip map selection
  103175. * @param lodOffset defines offset to apply to the mip map selection
  103176. * @param onLoad defines an optional callback raised when the texture is loaded
  103177. * @param onError defines an optional callback raised if there is an issue to load the texture
  103178. * @param format defines the format of the data
  103179. * @param forcedExtension defines the extension to use to pick the right loader
  103180. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  103181. * @returns the cube texture as an InternalTexture
  103182. */
  103183. 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;
  103184. }
  103185. }
  103186. declare module BABYLON {
  103187. /**
  103188. * Implementation of the DDS Texture Loader.
  103189. * @hidden
  103190. */
  103191. export class _DDSTextureLoader implements IInternalTextureLoader {
  103192. /**
  103193. * Defines wether the loader supports cascade loading the different faces.
  103194. */
  103195. readonly supportCascades: boolean;
  103196. /**
  103197. * This returns if the loader support the current file information.
  103198. * @param extension defines the file extension of the file being loaded
  103199. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103200. * @param fallback defines the fallback internal texture if any
  103201. * @param isBase64 defines whether the texture is encoded as a base64
  103202. * @param isBuffer defines whether the texture data are stored as a buffer
  103203. * @returns true if the loader can load the specified file
  103204. */
  103205. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  103206. /**
  103207. * Transform the url before loading if required.
  103208. * @param rootUrl the url of the texture
  103209. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103210. * @returns the transformed texture
  103211. */
  103212. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  103213. /**
  103214. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  103215. * @param rootUrl the url of the texture
  103216. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103217. * @returns the fallback texture
  103218. */
  103219. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  103220. /**
  103221. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  103222. * @param data contains the texture data
  103223. * @param texture defines the BabylonJS internal texture
  103224. * @param createPolynomials will be true if polynomials have been requested
  103225. * @param onLoad defines the callback to trigger once the texture is ready
  103226. * @param onError defines the callback to trigger in case of error
  103227. */
  103228. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  103229. /**
  103230. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  103231. * @param data contains the texture data
  103232. * @param texture defines the BabylonJS internal texture
  103233. * @param callback defines the method to call once ready to upload
  103234. */
  103235. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  103236. }
  103237. }
  103238. declare module BABYLON {
  103239. /** @hidden */
  103240. export var rgbdEncodePixelShader: {
  103241. name: string;
  103242. shader: string;
  103243. };
  103244. }
  103245. declare module BABYLON {
  103246. /** @hidden */
  103247. export var rgbdDecodePixelShader: {
  103248. name: string;
  103249. shader: string;
  103250. };
  103251. }
  103252. declare module BABYLON {
  103253. /**
  103254. * Raw texture data and descriptor sufficient for WebGL texture upload
  103255. */
  103256. export interface EnvironmentTextureInfo {
  103257. /**
  103258. * Version of the environment map
  103259. */
  103260. version: number;
  103261. /**
  103262. * Width of image
  103263. */
  103264. width: number;
  103265. /**
  103266. * Irradiance information stored in the file.
  103267. */
  103268. irradiance: any;
  103269. /**
  103270. * Specular information stored in the file.
  103271. */
  103272. specular: any;
  103273. }
  103274. /**
  103275. * Sets of helpers addressing the serialization and deserialization of environment texture
  103276. * stored in a BabylonJS env file.
  103277. * Those files are usually stored as .env files.
  103278. */
  103279. export class EnvironmentTextureTools {
  103280. /**
  103281. * Magic number identifying the env file.
  103282. */
  103283. private static _MagicBytes;
  103284. /**
  103285. * Gets the environment info from an env file.
  103286. * @param data The array buffer containing the .env bytes.
  103287. * @returns the environment file info (the json header) if successfully parsed.
  103288. */
  103289. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  103290. /**
  103291. * Creates an environment texture from a loaded cube texture.
  103292. * @param texture defines the cube texture to convert in env file
  103293. * @return a promise containing the environment data if succesfull.
  103294. */
  103295. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  103296. /**
  103297. * Creates a JSON representation of the spherical data.
  103298. * @param texture defines the texture containing the polynomials
  103299. * @return the JSON representation of the spherical info
  103300. */
  103301. private static _CreateEnvTextureIrradiance;
  103302. /**
  103303. * Uploads the texture info contained in the env file to the GPU.
  103304. * @param texture defines the internal texture to upload to
  103305. * @param arrayBuffer defines the buffer cotaining the data to load
  103306. * @param info defines the texture info retrieved through the GetEnvInfo method
  103307. * @returns a promise
  103308. */
  103309. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  103310. /**
  103311. * Uploads the levels of image data to the GPU.
  103312. * @param texture defines the internal texture to upload to
  103313. * @param imageData defines the array buffer views of image data [mipmap][face]
  103314. * @returns a promise
  103315. */
  103316. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  103317. /**
  103318. * Uploads spherical polynomials information to the texture.
  103319. * @param texture defines the texture we are trying to upload the information to
  103320. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  103321. */
  103322. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  103323. /** @hidden */
  103324. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  103325. }
  103326. }
  103327. declare module BABYLON {
  103328. /**
  103329. * Implementation of the ENV Texture Loader.
  103330. * @hidden
  103331. */
  103332. export class _ENVTextureLoader implements IInternalTextureLoader {
  103333. /**
  103334. * Defines wether the loader supports cascade loading the different faces.
  103335. */
  103336. readonly supportCascades: boolean;
  103337. /**
  103338. * This returns if the loader support the current file information.
  103339. * @param extension defines the file extension of the file being loaded
  103340. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103341. * @param fallback defines the fallback internal texture if any
  103342. * @param isBase64 defines whether the texture is encoded as a base64
  103343. * @param isBuffer defines whether the texture data are stored as a buffer
  103344. * @returns true if the loader can load the specified file
  103345. */
  103346. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  103347. /**
  103348. * Transform the url before loading if required.
  103349. * @param rootUrl the url of the texture
  103350. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103351. * @returns the transformed texture
  103352. */
  103353. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  103354. /**
  103355. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  103356. * @param rootUrl the url of the texture
  103357. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103358. * @returns the fallback texture
  103359. */
  103360. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  103361. /**
  103362. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  103363. * @param data contains the texture data
  103364. * @param texture defines the BabylonJS internal texture
  103365. * @param createPolynomials will be true if polynomials have been requested
  103366. * @param onLoad defines the callback to trigger once the texture is ready
  103367. * @param onError defines the callback to trigger in case of error
  103368. */
  103369. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  103370. /**
  103371. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  103372. * @param data contains the texture data
  103373. * @param texture defines the BabylonJS internal texture
  103374. * @param callback defines the method to call once ready to upload
  103375. */
  103376. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  103377. }
  103378. }
  103379. declare module BABYLON {
  103380. /**
  103381. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  103382. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  103383. */
  103384. export class KhronosTextureContainer {
  103385. /** contents of the KTX container file */
  103386. arrayBuffer: any;
  103387. private static HEADER_LEN;
  103388. private static COMPRESSED_2D;
  103389. private static COMPRESSED_3D;
  103390. private static TEX_2D;
  103391. private static TEX_3D;
  103392. /**
  103393. * Gets the openGL type
  103394. */
  103395. glType: number;
  103396. /**
  103397. * Gets the openGL type size
  103398. */
  103399. glTypeSize: number;
  103400. /**
  103401. * Gets the openGL format
  103402. */
  103403. glFormat: number;
  103404. /**
  103405. * Gets the openGL internal format
  103406. */
  103407. glInternalFormat: number;
  103408. /**
  103409. * Gets the base internal format
  103410. */
  103411. glBaseInternalFormat: number;
  103412. /**
  103413. * Gets image width in pixel
  103414. */
  103415. pixelWidth: number;
  103416. /**
  103417. * Gets image height in pixel
  103418. */
  103419. pixelHeight: number;
  103420. /**
  103421. * Gets image depth in pixels
  103422. */
  103423. pixelDepth: number;
  103424. /**
  103425. * Gets the number of array elements
  103426. */
  103427. numberOfArrayElements: number;
  103428. /**
  103429. * Gets the number of faces
  103430. */
  103431. numberOfFaces: number;
  103432. /**
  103433. * Gets the number of mipmap levels
  103434. */
  103435. numberOfMipmapLevels: number;
  103436. /**
  103437. * Gets the bytes of key value data
  103438. */
  103439. bytesOfKeyValueData: number;
  103440. /**
  103441. * Gets the load type
  103442. */
  103443. loadType: number;
  103444. /**
  103445. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  103446. */
  103447. isInvalid: boolean;
  103448. /**
  103449. * Creates a new KhronosTextureContainer
  103450. * @param arrayBuffer contents of the KTX container file
  103451. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  103452. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  103453. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  103454. */
  103455. constructor(
  103456. /** contents of the KTX container file */
  103457. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  103458. /**
  103459. * Uploads KTX content to a Babylon Texture.
  103460. * It is assumed that the texture has already been created & is currently bound
  103461. * @hidden
  103462. */
  103463. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  103464. private _upload2DCompressedLevels;
  103465. }
  103466. }
  103467. declare module BABYLON {
  103468. /**
  103469. * Implementation of the KTX Texture Loader.
  103470. * @hidden
  103471. */
  103472. export class _KTXTextureLoader implements IInternalTextureLoader {
  103473. /**
  103474. * Defines wether the loader supports cascade loading the different faces.
  103475. */
  103476. readonly supportCascades: boolean;
  103477. /**
  103478. * This returns if the loader support the current file information.
  103479. * @param extension defines the file extension of the file being loaded
  103480. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103481. * @param fallback defines the fallback internal texture if any
  103482. * @param isBase64 defines whether the texture is encoded as a base64
  103483. * @param isBuffer defines whether the texture data are stored as a buffer
  103484. * @returns true if the loader can load the specified file
  103485. */
  103486. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  103487. /**
  103488. * Transform the url before loading if required.
  103489. * @param rootUrl the url of the texture
  103490. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103491. * @returns the transformed texture
  103492. */
  103493. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  103494. /**
  103495. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  103496. * @param rootUrl the url of the texture
  103497. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103498. * @returns the fallback texture
  103499. */
  103500. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  103501. /**
  103502. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  103503. * @param data contains the texture data
  103504. * @param texture defines the BabylonJS internal texture
  103505. * @param createPolynomials will be true if polynomials have been requested
  103506. * @param onLoad defines the callback to trigger once the texture is ready
  103507. * @param onError defines the callback to trigger in case of error
  103508. */
  103509. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  103510. /**
  103511. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  103512. * @param data contains the texture data
  103513. * @param texture defines the BabylonJS internal texture
  103514. * @param callback defines the method to call once ready to upload
  103515. */
  103516. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  103517. }
  103518. }
  103519. declare module BABYLON {
  103520. /** @hidden */
  103521. export var _forceSceneHelpersToBundle: boolean;
  103522. interface Scene {
  103523. /**
  103524. * Creates a default light for the scene.
  103525. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  103526. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  103527. */
  103528. createDefaultLight(replace?: boolean): void;
  103529. /**
  103530. * Creates a default camera for the scene.
  103531. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  103532. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  103533. * @param replace has default false, when true replaces the active camera in the scene
  103534. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  103535. */
  103536. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  103537. /**
  103538. * Creates a default camera and a default light.
  103539. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  103540. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  103541. * @param replace has the default false, when true replaces the active camera/light in the scene
  103542. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  103543. */
  103544. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  103545. /**
  103546. * Creates a new sky box
  103547. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  103548. * @param environmentTexture defines the texture to use as environment texture
  103549. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  103550. * @param scale defines the overall scale of the skybox
  103551. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  103552. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  103553. * @returns a new mesh holding the sky box
  103554. */
  103555. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  103556. /**
  103557. * Creates a new environment
  103558. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  103559. * @param options defines the options you can use to configure the environment
  103560. * @returns the new EnvironmentHelper
  103561. */
  103562. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  103563. /**
  103564. * Creates a new VREXperienceHelper
  103565. * @see http://doc.babylonjs.com/how_to/webvr_helper
  103566. * @param webVROptions defines the options used to create the new VREXperienceHelper
  103567. * @returns a new VREXperienceHelper
  103568. */
  103569. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  103570. /**
  103571. * Creates a new XREXperienceHelper
  103572. * @see http://doc.babylonjs.com/how_to/webxr
  103573. * @returns a promise for a new XREXperienceHelper
  103574. */
  103575. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  103576. }
  103577. }
  103578. declare module BABYLON {
  103579. /**
  103580. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  103581. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  103582. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  103583. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  103584. */
  103585. export class VideoDome extends TransformNode {
  103586. /**
  103587. * Define the video source as a Monoscopic panoramic 360 video.
  103588. */
  103589. static readonly MODE_MONOSCOPIC: number;
  103590. /**
  103591. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  103592. */
  103593. static readonly MODE_TOPBOTTOM: number;
  103594. /**
  103595. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  103596. */
  103597. static readonly MODE_SIDEBYSIDE: number;
  103598. private _useDirectMapping;
  103599. /**
  103600. * The video texture being displayed on the sphere
  103601. */
  103602. protected _videoTexture: VideoTexture;
  103603. /**
  103604. * Gets the video texture being displayed on the sphere
  103605. */
  103606. readonly videoTexture: VideoTexture;
  103607. /**
  103608. * The skybox material
  103609. */
  103610. protected _material: BackgroundMaterial;
  103611. /**
  103612. * The surface used for the skybox
  103613. */
  103614. protected _mesh: Mesh;
  103615. /**
  103616. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  103617. * Also see the options.resolution property.
  103618. */
  103619. fovMultiplier: number;
  103620. private _videoMode;
  103621. /**
  103622. * Gets or set the current video mode for the video. It can be:
  103623. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  103624. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  103625. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  103626. */
  103627. videoMode: number;
  103628. /**
  103629. * Oberserver used in Stereoscopic VR Mode.
  103630. */
  103631. private _onBeforeCameraRenderObserver;
  103632. /**
  103633. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  103634. * @param name Element's name, child elements will append suffixes for their own names.
  103635. * @param urlsOrVideo defines the url(s) or the video element to use
  103636. * @param options An object containing optional or exposed sub element properties
  103637. */
  103638. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  103639. resolution?: number;
  103640. clickToPlay?: boolean;
  103641. autoPlay?: boolean;
  103642. loop?: boolean;
  103643. size?: number;
  103644. poster?: string;
  103645. faceForward?: boolean;
  103646. useDirectMapping?: boolean;
  103647. }, scene: Scene);
  103648. private _changeVideoMode;
  103649. /**
  103650. * Releases resources associated with this node.
  103651. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  103652. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  103653. */
  103654. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  103655. }
  103656. }
  103657. declare module BABYLON {
  103658. /**
  103659. * This class can be used to get instrumentation data from a Babylon engine
  103660. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  103661. */
  103662. export class EngineInstrumentation implements IDisposable {
  103663. /**
  103664. * Define the instrumented engine.
  103665. */
  103666. engine: Engine;
  103667. private _captureGPUFrameTime;
  103668. private _gpuFrameTimeToken;
  103669. private _gpuFrameTime;
  103670. private _captureShaderCompilationTime;
  103671. private _shaderCompilationTime;
  103672. private _onBeginFrameObserver;
  103673. private _onEndFrameObserver;
  103674. private _onBeforeShaderCompilationObserver;
  103675. private _onAfterShaderCompilationObserver;
  103676. /**
  103677. * Gets the perf counter used for GPU frame time
  103678. */
  103679. readonly gpuFrameTimeCounter: PerfCounter;
  103680. /**
  103681. * Gets the GPU frame time capture status
  103682. */
  103683. /**
  103684. * Enable or disable the GPU frame time capture
  103685. */
  103686. captureGPUFrameTime: boolean;
  103687. /**
  103688. * Gets the perf counter used for shader compilation time
  103689. */
  103690. readonly shaderCompilationTimeCounter: PerfCounter;
  103691. /**
  103692. * Gets the shader compilation time capture status
  103693. */
  103694. /**
  103695. * Enable or disable the shader compilation time capture
  103696. */
  103697. captureShaderCompilationTime: boolean;
  103698. /**
  103699. * Instantiates a new engine instrumentation.
  103700. * This class can be used to get instrumentation data from a Babylon engine
  103701. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  103702. * @param engine Defines the engine to instrument
  103703. */
  103704. constructor(
  103705. /**
  103706. * Define the instrumented engine.
  103707. */
  103708. engine: Engine);
  103709. /**
  103710. * Dispose and release associated resources.
  103711. */
  103712. dispose(): void;
  103713. }
  103714. }
  103715. declare module BABYLON {
  103716. /**
  103717. * This class can be used to get instrumentation data from a Babylon engine
  103718. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  103719. */
  103720. export class SceneInstrumentation implements IDisposable {
  103721. /**
  103722. * Defines the scene to instrument
  103723. */
  103724. scene: Scene;
  103725. private _captureActiveMeshesEvaluationTime;
  103726. private _activeMeshesEvaluationTime;
  103727. private _captureRenderTargetsRenderTime;
  103728. private _renderTargetsRenderTime;
  103729. private _captureFrameTime;
  103730. private _frameTime;
  103731. private _captureRenderTime;
  103732. private _renderTime;
  103733. private _captureInterFrameTime;
  103734. private _interFrameTime;
  103735. private _captureParticlesRenderTime;
  103736. private _particlesRenderTime;
  103737. private _captureSpritesRenderTime;
  103738. private _spritesRenderTime;
  103739. private _capturePhysicsTime;
  103740. private _physicsTime;
  103741. private _captureAnimationsTime;
  103742. private _animationsTime;
  103743. private _captureCameraRenderTime;
  103744. private _cameraRenderTime;
  103745. private _onBeforeActiveMeshesEvaluationObserver;
  103746. private _onAfterActiveMeshesEvaluationObserver;
  103747. private _onBeforeRenderTargetsRenderObserver;
  103748. private _onAfterRenderTargetsRenderObserver;
  103749. private _onAfterRenderObserver;
  103750. private _onBeforeDrawPhaseObserver;
  103751. private _onAfterDrawPhaseObserver;
  103752. private _onBeforeAnimationsObserver;
  103753. private _onBeforeParticlesRenderingObserver;
  103754. private _onAfterParticlesRenderingObserver;
  103755. private _onBeforeSpritesRenderingObserver;
  103756. private _onAfterSpritesRenderingObserver;
  103757. private _onBeforePhysicsObserver;
  103758. private _onAfterPhysicsObserver;
  103759. private _onAfterAnimationsObserver;
  103760. private _onBeforeCameraRenderObserver;
  103761. private _onAfterCameraRenderObserver;
  103762. /**
  103763. * Gets the perf counter used for active meshes evaluation time
  103764. */
  103765. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  103766. /**
  103767. * Gets the active meshes evaluation time capture status
  103768. */
  103769. /**
  103770. * Enable or disable the active meshes evaluation time capture
  103771. */
  103772. captureActiveMeshesEvaluationTime: boolean;
  103773. /**
  103774. * Gets the perf counter used for render targets render time
  103775. */
  103776. readonly renderTargetsRenderTimeCounter: PerfCounter;
  103777. /**
  103778. * Gets the render targets render time capture status
  103779. */
  103780. /**
  103781. * Enable or disable the render targets render time capture
  103782. */
  103783. captureRenderTargetsRenderTime: boolean;
  103784. /**
  103785. * Gets the perf counter used for particles render time
  103786. */
  103787. readonly particlesRenderTimeCounter: PerfCounter;
  103788. /**
  103789. * Gets the particles render time capture status
  103790. */
  103791. /**
  103792. * Enable or disable the particles render time capture
  103793. */
  103794. captureParticlesRenderTime: boolean;
  103795. /**
  103796. * Gets the perf counter used for sprites render time
  103797. */
  103798. readonly spritesRenderTimeCounter: PerfCounter;
  103799. /**
  103800. * Gets the sprites render time capture status
  103801. */
  103802. /**
  103803. * Enable or disable the sprites render time capture
  103804. */
  103805. captureSpritesRenderTime: boolean;
  103806. /**
  103807. * Gets the perf counter used for physics time
  103808. */
  103809. readonly physicsTimeCounter: PerfCounter;
  103810. /**
  103811. * Gets the physics time capture status
  103812. */
  103813. /**
  103814. * Enable or disable the physics time capture
  103815. */
  103816. capturePhysicsTime: boolean;
  103817. /**
  103818. * Gets the perf counter used for animations time
  103819. */
  103820. readonly animationsTimeCounter: PerfCounter;
  103821. /**
  103822. * Gets the animations time capture status
  103823. */
  103824. /**
  103825. * Enable or disable the animations time capture
  103826. */
  103827. captureAnimationsTime: boolean;
  103828. /**
  103829. * Gets the perf counter used for frame time capture
  103830. */
  103831. readonly frameTimeCounter: PerfCounter;
  103832. /**
  103833. * Gets the frame time capture status
  103834. */
  103835. /**
  103836. * Enable or disable the frame time capture
  103837. */
  103838. captureFrameTime: boolean;
  103839. /**
  103840. * Gets the perf counter used for inter-frames time capture
  103841. */
  103842. readonly interFrameTimeCounter: PerfCounter;
  103843. /**
  103844. * Gets the inter-frames time capture status
  103845. */
  103846. /**
  103847. * Enable or disable the inter-frames time capture
  103848. */
  103849. captureInterFrameTime: boolean;
  103850. /**
  103851. * Gets the perf counter used for render time capture
  103852. */
  103853. readonly renderTimeCounter: PerfCounter;
  103854. /**
  103855. * Gets the render time capture status
  103856. */
  103857. /**
  103858. * Enable or disable the render time capture
  103859. */
  103860. captureRenderTime: boolean;
  103861. /**
  103862. * Gets the perf counter used for camera render time capture
  103863. */
  103864. readonly cameraRenderTimeCounter: PerfCounter;
  103865. /**
  103866. * Gets the camera render time capture status
  103867. */
  103868. /**
  103869. * Enable or disable the camera render time capture
  103870. */
  103871. captureCameraRenderTime: boolean;
  103872. /**
  103873. * Gets the perf counter used for draw calls
  103874. */
  103875. readonly drawCallsCounter: PerfCounter;
  103876. /**
  103877. * Gets the perf counter used for texture collisions
  103878. */
  103879. readonly textureCollisionsCounter: PerfCounter;
  103880. /**
  103881. * Instantiates a new scene instrumentation.
  103882. * This class can be used to get instrumentation data from a Babylon engine
  103883. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  103884. * @param scene Defines the scene to instrument
  103885. */
  103886. constructor(
  103887. /**
  103888. * Defines the scene to instrument
  103889. */
  103890. scene: Scene);
  103891. /**
  103892. * Dispose and release associated resources.
  103893. */
  103894. dispose(): void;
  103895. }
  103896. }
  103897. declare module BABYLON {
  103898. /** @hidden */
  103899. export var glowMapGenerationPixelShader: {
  103900. name: string;
  103901. shader: string;
  103902. };
  103903. }
  103904. declare module BABYLON {
  103905. /** @hidden */
  103906. export var glowMapGenerationVertexShader: {
  103907. name: string;
  103908. shader: string;
  103909. };
  103910. }
  103911. declare module BABYLON {
  103912. /**
  103913. * Effect layer options. This helps customizing the behaviour
  103914. * of the effect layer.
  103915. */
  103916. export interface IEffectLayerOptions {
  103917. /**
  103918. * Multiplication factor apply to the canvas size to compute the render target size
  103919. * used to generated the objects (the smaller the faster).
  103920. */
  103921. mainTextureRatio: number;
  103922. /**
  103923. * Enforces a fixed size texture to ensure effect stability across devices.
  103924. */
  103925. mainTextureFixedSize?: number;
  103926. /**
  103927. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  103928. */
  103929. alphaBlendingMode: number;
  103930. /**
  103931. * The camera attached to the layer.
  103932. */
  103933. camera: Nullable<Camera>;
  103934. /**
  103935. * The rendering group to draw the layer in.
  103936. */
  103937. renderingGroupId: number;
  103938. }
  103939. /**
  103940. * The effect layer Helps adding post process effect blended with the main pass.
  103941. *
  103942. * This can be for instance use to generate glow or higlight effects on the scene.
  103943. *
  103944. * The effect layer class can not be used directly and is intented to inherited from to be
  103945. * customized per effects.
  103946. */
  103947. export abstract class EffectLayer {
  103948. private _vertexBuffers;
  103949. private _indexBuffer;
  103950. private _cachedDefines;
  103951. private _effectLayerMapGenerationEffect;
  103952. private _effectLayerOptions;
  103953. private _mergeEffect;
  103954. protected _scene: Scene;
  103955. protected _engine: Engine;
  103956. protected _maxSize: number;
  103957. protected _mainTextureDesiredSize: ISize;
  103958. protected _mainTexture: RenderTargetTexture;
  103959. protected _shouldRender: boolean;
  103960. protected _postProcesses: PostProcess[];
  103961. protected _textures: BaseTexture[];
  103962. protected _emissiveTextureAndColor: {
  103963. texture: Nullable<BaseTexture>;
  103964. color: Color4;
  103965. };
  103966. /**
  103967. * The name of the layer
  103968. */
  103969. name: string;
  103970. /**
  103971. * The clear color of the texture used to generate the glow map.
  103972. */
  103973. neutralColor: Color4;
  103974. /**
  103975. * Specifies wether the highlight layer is enabled or not.
  103976. */
  103977. isEnabled: boolean;
  103978. /**
  103979. * Gets the camera attached to the layer.
  103980. */
  103981. readonly camera: Nullable<Camera>;
  103982. /**
  103983. * Gets the rendering group id the layer should render in.
  103984. */
  103985. readonly renderingGroupId: number;
  103986. /**
  103987. * An event triggered when the effect layer has been disposed.
  103988. */
  103989. onDisposeObservable: Observable<EffectLayer>;
  103990. /**
  103991. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  103992. */
  103993. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  103994. /**
  103995. * An event triggered when the generated texture is being merged in the scene.
  103996. */
  103997. onBeforeComposeObservable: Observable<EffectLayer>;
  103998. /**
  103999. * An event triggered when the generated texture has been merged in the scene.
  104000. */
  104001. onAfterComposeObservable: Observable<EffectLayer>;
  104002. /**
  104003. * An event triggered when the efffect layer changes its size.
  104004. */
  104005. onSizeChangedObservable: Observable<EffectLayer>;
  104006. /** @hidden */
  104007. static _SceneComponentInitialization: (scene: Scene) => void;
  104008. /**
  104009. * Instantiates a new effect Layer and references it in the scene.
  104010. * @param name The name of the layer
  104011. * @param scene The scene to use the layer in
  104012. */
  104013. constructor(
  104014. /** The Friendly of the effect in the scene */
  104015. name: string, scene: Scene);
  104016. /**
  104017. * Get the effect name of the layer.
  104018. * @return The effect name
  104019. */
  104020. abstract getEffectName(): string;
  104021. /**
  104022. * Checks for the readiness of the element composing the layer.
  104023. * @param subMesh the mesh to check for
  104024. * @param useInstances specify wether or not to use instances to render the mesh
  104025. * @return true if ready otherwise, false
  104026. */
  104027. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  104028. /**
  104029. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  104030. * @returns true if the effect requires stencil during the main canvas render pass.
  104031. */
  104032. abstract needStencil(): boolean;
  104033. /**
  104034. * Create the merge effect. This is the shader use to blit the information back
  104035. * to the main canvas at the end of the scene rendering.
  104036. * @returns The effect containing the shader used to merge the effect on the main canvas
  104037. */
  104038. protected abstract _createMergeEffect(): Effect;
  104039. /**
  104040. * Creates the render target textures and post processes used in the effect layer.
  104041. */
  104042. protected abstract _createTextureAndPostProcesses(): void;
  104043. /**
  104044. * Implementation specific of rendering the generating effect on the main canvas.
  104045. * @param effect The effect used to render through
  104046. */
  104047. protected abstract _internalRender(effect: Effect): void;
  104048. /**
  104049. * Sets the required values for both the emissive texture and and the main color.
  104050. */
  104051. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  104052. /**
  104053. * Free any resources and references associated to a mesh.
  104054. * Internal use
  104055. * @param mesh The mesh to free.
  104056. */
  104057. abstract _disposeMesh(mesh: Mesh): void;
  104058. /**
  104059. * Serializes this layer (Glow or Highlight for example)
  104060. * @returns a serialized layer object
  104061. */
  104062. abstract serialize?(): any;
  104063. /**
  104064. * Initializes the effect layer with the required options.
  104065. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  104066. */
  104067. protected _init(options: Partial<IEffectLayerOptions>): void;
  104068. /**
  104069. * Generates the index buffer of the full screen quad blending to the main canvas.
  104070. */
  104071. private _generateIndexBuffer;
  104072. /**
  104073. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  104074. */
  104075. private _genrateVertexBuffer;
  104076. /**
  104077. * Sets the main texture desired size which is the closest power of two
  104078. * of the engine canvas size.
  104079. */
  104080. private _setMainTextureSize;
  104081. /**
  104082. * Creates the main texture for the effect layer.
  104083. */
  104084. protected _createMainTexture(): void;
  104085. /**
  104086. * Adds specific effects defines.
  104087. * @param defines The defines to add specifics to.
  104088. */
  104089. protected _addCustomEffectDefines(defines: string[]): void;
  104090. /**
  104091. * Checks for the readiness of the element composing the layer.
  104092. * @param subMesh the mesh to check for
  104093. * @param useInstances specify wether or not to use instances to render the mesh
  104094. * @param emissiveTexture the associated emissive texture used to generate the glow
  104095. * @return true if ready otherwise, false
  104096. */
  104097. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  104098. /**
  104099. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  104100. */
  104101. render(): void;
  104102. /**
  104103. * Determine if a given mesh will be used in the current effect.
  104104. * @param mesh mesh to test
  104105. * @returns true if the mesh will be used
  104106. */
  104107. hasMesh(mesh: AbstractMesh): boolean;
  104108. /**
  104109. * Returns true if the layer contains information to display, otherwise false.
  104110. * @returns true if the glow layer should be rendered
  104111. */
  104112. shouldRender(): boolean;
  104113. /**
  104114. * Returns true if the mesh should render, otherwise false.
  104115. * @param mesh The mesh to render
  104116. * @returns true if it should render otherwise false
  104117. */
  104118. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  104119. /**
  104120. * Returns true if the mesh can be rendered, otherwise false.
  104121. * @param mesh The mesh to render
  104122. * @param material The material used on the mesh
  104123. * @returns true if it can be rendered otherwise false
  104124. */
  104125. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  104126. /**
  104127. * Returns true if the mesh should render, otherwise false.
  104128. * @param mesh The mesh to render
  104129. * @returns true if it should render otherwise false
  104130. */
  104131. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  104132. /**
  104133. * Renders the submesh passed in parameter to the generation map.
  104134. */
  104135. protected _renderSubMesh(subMesh: SubMesh): void;
  104136. /**
  104137. * Rebuild the required buffers.
  104138. * @hidden Internal use only.
  104139. */
  104140. _rebuild(): void;
  104141. /**
  104142. * Dispose only the render target textures and post process.
  104143. */
  104144. private _disposeTextureAndPostProcesses;
  104145. /**
  104146. * Dispose the highlight layer and free resources.
  104147. */
  104148. dispose(): void;
  104149. /**
  104150. * Gets the class name of the effect layer
  104151. * @returns the string with the class name of the effect layer
  104152. */
  104153. getClassName(): string;
  104154. /**
  104155. * Creates an effect layer from parsed effect layer data
  104156. * @param parsedEffectLayer defines effect layer data
  104157. * @param scene defines the current scene
  104158. * @param rootUrl defines the root URL containing the effect layer information
  104159. * @returns a parsed effect Layer
  104160. */
  104161. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  104162. }
  104163. }
  104164. declare module BABYLON {
  104165. interface AbstractScene {
  104166. /**
  104167. * The list of effect layers (highlights/glow) added to the scene
  104168. * @see http://doc.babylonjs.com/how_to/highlight_layer
  104169. * @see http://doc.babylonjs.com/how_to/glow_layer
  104170. */
  104171. effectLayers: Array<EffectLayer>;
  104172. /**
  104173. * Removes the given effect layer from this scene.
  104174. * @param toRemove defines the effect layer to remove
  104175. * @returns the index of the removed effect layer
  104176. */
  104177. removeEffectLayer(toRemove: EffectLayer): number;
  104178. /**
  104179. * Adds the given effect layer to this scene
  104180. * @param newEffectLayer defines the effect layer to add
  104181. */
  104182. addEffectLayer(newEffectLayer: EffectLayer): void;
  104183. }
  104184. /**
  104185. * Defines the layer scene component responsible to manage any effect layers
  104186. * in a given scene.
  104187. */
  104188. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  104189. /**
  104190. * The component name helpfull to identify the component in the list of scene components.
  104191. */
  104192. readonly name: string;
  104193. /**
  104194. * The scene the component belongs to.
  104195. */
  104196. scene: Scene;
  104197. private _engine;
  104198. private _renderEffects;
  104199. private _needStencil;
  104200. private _previousStencilState;
  104201. /**
  104202. * Creates a new instance of the component for the given scene
  104203. * @param scene Defines the scene to register the component in
  104204. */
  104205. constructor(scene: Scene);
  104206. /**
  104207. * Registers the component in a given scene
  104208. */
  104209. register(): void;
  104210. /**
  104211. * Rebuilds the elements related to this component in case of
  104212. * context lost for instance.
  104213. */
  104214. rebuild(): void;
  104215. /**
  104216. * Serializes the component data to the specified json object
  104217. * @param serializationObject The object to serialize to
  104218. */
  104219. serialize(serializationObject: any): void;
  104220. /**
  104221. * Adds all the element from the container to the scene
  104222. * @param container the container holding the elements
  104223. */
  104224. addFromContainer(container: AbstractScene): void;
  104225. /**
  104226. * Removes all the elements in the container from the scene
  104227. * @param container contains the elements to remove
  104228. */
  104229. removeFromContainer(container: AbstractScene): void;
  104230. /**
  104231. * Disposes the component and the associated ressources.
  104232. */
  104233. dispose(): void;
  104234. private _isReadyForMesh;
  104235. private _renderMainTexture;
  104236. private _setStencil;
  104237. private _setStencilBack;
  104238. private _draw;
  104239. private _drawCamera;
  104240. private _drawRenderingGroup;
  104241. }
  104242. }
  104243. declare module BABYLON {
  104244. /** @hidden */
  104245. export var glowMapMergePixelShader: {
  104246. name: string;
  104247. shader: string;
  104248. };
  104249. }
  104250. declare module BABYLON {
  104251. /** @hidden */
  104252. export var glowMapMergeVertexShader: {
  104253. name: string;
  104254. shader: string;
  104255. };
  104256. }
  104257. declare module BABYLON {
  104258. interface AbstractScene {
  104259. /**
  104260. * Return a the first highlight layer of the scene with a given name.
  104261. * @param name The name of the highlight layer to look for.
  104262. * @return The highlight layer if found otherwise null.
  104263. */
  104264. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  104265. }
  104266. /**
  104267. * Glow layer options. This helps customizing the behaviour
  104268. * of the glow layer.
  104269. */
  104270. export interface IGlowLayerOptions {
  104271. /**
  104272. * Multiplication factor apply to the canvas size to compute the render target size
  104273. * used to generated the glowing objects (the smaller the faster).
  104274. */
  104275. mainTextureRatio: number;
  104276. /**
  104277. * Enforces a fixed size texture to ensure resize independant blur.
  104278. */
  104279. mainTextureFixedSize?: number;
  104280. /**
  104281. * How big is the kernel of the blur texture.
  104282. */
  104283. blurKernelSize: number;
  104284. /**
  104285. * The camera attached to the layer.
  104286. */
  104287. camera: Nullable<Camera>;
  104288. /**
  104289. * Enable MSAA by chosing the number of samples.
  104290. */
  104291. mainTextureSamples?: number;
  104292. /**
  104293. * The rendering group to draw the layer in.
  104294. */
  104295. renderingGroupId: number;
  104296. }
  104297. /**
  104298. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  104299. *
  104300. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  104301. * glowy meshes to your scene.
  104302. *
  104303. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  104304. */
  104305. export class GlowLayer extends EffectLayer {
  104306. /**
  104307. * Effect Name of the layer.
  104308. */
  104309. static readonly EffectName: string;
  104310. /**
  104311. * The default blur kernel size used for the glow.
  104312. */
  104313. static DefaultBlurKernelSize: number;
  104314. /**
  104315. * The default texture size ratio used for the glow.
  104316. */
  104317. static DefaultTextureRatio: number;
  104318. /**
  104319. * Sets the kernel size of the blur.
  104320. */
  104321. /**
  104322. * Gets the kernel size of the blur.
  104323. */
  104324. blurKernelSize: number;
  104325. /**
  104326. * Sets the glow intensity.
  104327. */
  104328. /**
  104329. * Gets the glow intensity.
  104330. */
  104331. intensity: number;
  104332. private _options;
  104333. private _intensity;
  104334. private _horizontalBlurPostprocess1;
  104335. private _verticalBlurPostprocess1;
  104336. private _horizontalBlurPostprocess2;
  104337. private _verticalBlurPostprocess2;
  104338. private _blurTexture1;
  104339. private _blurTexture2;
  104340. private _postProcesses1;
  104341. private _postProcesses2;
  104342. private _includedOnlyMeshes;
  104343. private _excludedMeshes;
  104344. /**
  104345. * Callback used to let the user override the color selection on a per mesh basis
  104346. */
  104347. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  104348. /**
  104349. * Callback used to let the user override the texture selection on a per mesh basis
  104350. */
  104351. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  104352. /**
  104353. * Instantiates a new glow Layer and references it to the scene.
  104354. * @param name The name of the layer
  104355. * @param scene The scene to use the layer in
  104356. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  104357. */
  104358. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  104359. /**
  104360. * Get the effect name of the layer.
  104361. * @return The effect name
  104362. */
  104363. getEffectName(): string;
  104364. /**
  104365. * Create the merge effect. This is the shader use to blit the information back
  104366. * to the main canvas at the end of the scene rendering.
  104367. */
  104368. protected _createMergeEffect(): Effect;
  104369. /**
  104370. * Creates the render target textures and post processes used in the glow layer.
  104371. */
  104372. protected _createTextureAndPostProcesses(): void;
  104373. /**
  104374. * Checks for the readiness of the element composing the layer.
  104375. * @param subMesh the mesh to check for
  104376. * @param useInstances specify wether or not to use instances to render the mesh
  104377. * @param emissiveTexture the associated emissive texture used to generate the glow
  104378. * @return true if ready otherwise, false
  104379. */
  104380. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  104381. /**
  104382. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  104383. */
  104384. needStencil(): boolean;
  104385. /**
  104386. * Returns true if the mesh can be rendered, otherwise false.
  104387. * @param mesh The mesh to render
  104388. * @param material The material used on the mesh
  104389. * @returns true if it can be rendered otherwise false
  104390. */
  104391. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  104392. /**
  104393. * Implementation specific of rendering the generating effect on the main canvas.
  104394. * @param effect The effect used to render through
  104395. */
  104396. protected _internalRender(effect: Effect): void;
  104397. /**
  104398. * Sets the required values for both the emissive texture and and the main color.
  104399. */
  104400. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  104401. /**
  104402. * Returns true if the mesh should render, otherwise false.
  104403. * @param mesh The mesh to render
  104404. * @returns true if it should render otherwise false
  104405. */
  104406. protected _shouldRenderMesh(mesh: Mesh): boolean;
  104407. /**
  104408. * Adds specific effects defines.
  104409. * @param defines The defines to add specifics to.
  104410. */
  104411. protected _addCustomEffectDefines(defines: string[]): void;
  104412. /**
  104413. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  104414. * @param mesh The mesh to exclude from the glow layer
  104415. */
  104416. addExcludedMesh(mesh: Mesh): void;
  104417. /**
  104418. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  104419. * @param mesh The mesh to remove
  104420. */
  104421. removeExcludedMesh(mesh: Mesh): void;
  104422. /**
  104423. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  104424. * @param mesh The mesh to include in the glow layer
  104425. */
  104426. addIncludedOnlyMesh(mesh: Mesh): void;
  104427. /**
  104428. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  104429. * @param mesh The mesh to remove
  104430. */
  104431. removeIncludedOnlyMesh(mesh: Mesh): void;
  104432. /**
  104433. * Determine if a given mesh will be used in the glow layer
  104434. * @param mesh The mesh to test
  104435. * @returns true if the mesh will be highlighted by the current glow layer
  104436. */
  104437. hasMesh(mesh: AbstractMesh): boolean;
  104438. /**
  104439. * Free any resources and references associated to a mesh.
  104440. * Internal use
  104441. * @param mesh The mesh to free.
  104442. * @hidden
  104443. */
  104444. _disposeMesh(mesh: Mesh): void;
  104445. /**
  104446. * Gets the class name of the effect layer
  104447. * @returns the string with the class name of the effect layer
  104448. */
  104449. getClassName(): string;
  104450. /**
  104451. * Serializes this glow layer
  104452. * @returns a serialized glow layer object
  104453. */
  104454. serialize(): any;
  104455. /**
  104456. * Creates a Glow Layer from parsed glow layer data
  104457. * @param parsedGlowLayer defines glow layer data
  104458. * @param scene defines the current scene
  104459. * @param rootUrl defines the root URL containing the glow layer information
  104460. * @returns a parsed Glow Layer
  104461. */
  104462. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  104463. }
  104464. }
  104465. declare module BABYLON {
  104466. /** @hidden */
  104467. export var glowBlurPostProcessPixelShader: {
  104468. name: string;
  104469. shader: string;
  104470. };
  104471. }
  104472. declare module BABYLON {
  104473. interface AbstractScene {
  104474. /**
  104475. * Return a the first highlight layer of the scene with a given name.
  104476. * @param name The name of the highlight layer to look for.
  104477. * @return The highlight layer if found otherwise null.
  104478. */
  104479. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  104480. }
  104481. /**
  104482. * Highlight layer options. This helps customizing the behaviour
  104483. * of the highlight layer.
  104484. */
  104485. export interface IHighlightLayerOptions {
  104486. /**
  104487. * Multiplication factor apply to the canvas size to compute the render target size
  104488. * used to generated the glowing objects (the smaller the faster).
  104489. */
  104490. mainTextureRatio: number;
  104491. /**
  104492. * Enforces a fixed size texture to ensure resize independant blur.
  104493. */
  104494. mainTextureFixedSize?: number;
  104495. /**
  104496. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  104497. * of the picture to blur (the smaller the faster).
  104498. */
  104499. blurTextureSizeRatio: number;
  104500. /**
  104501. * How big in texel of the blur texture is the vertical blur.
  104502. */
  104503. blurVerticalSize: number;
  104504. /**
  104505. * How big in texel of the blur texture is the horizontal blur.
  104506. */
  104507. blurHorizontalSize: number;
  104508. /**
  104509. * Alpha blending mode used to apply the blur. Default is combine.
  104510. */
  104511. alphaBlendingMode: number;
  104512. /**
  104513. * The camera attached to the layer.
  104514. */
  104515. camera: Nullable<Camera>;
  104516. /**
  104517. * Should we display highlight as a solid stroke?
  104518. */
  104519. isStroke?: boolean;
  104520. /**
  104521. * The rendering group to draw the layer in.
  104522. */
  104523. renderingGroupId: number;
  104524. }
  104525. /**
  104526. * The highlight layer Helps adding a glow effect around a mesh.
  104527. *
  104528. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  104529. * glowy meshes to your scene.
  104530. *
  104531. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  104532. */
  104533. export class HighlightLayer extends EffectLayer {
  104534. name: string;
  104535. /**
  104536. * Effect Name of the highlight layer.
  104537. */
  104538. static readonly EffectName: string;
  104539. /**
  104540. * The neutral color used during the preparation of the glow effect.
  104541. * This is black by default as the blend operation is a blend operation.
  104542. */
  104543. static NeutralColor: Color4;
  104544. /**
  104545. * Stencil value used for glowing meshes.
  104546. */
  104547. static GlowingMeshStencilReference: number;
  104548. /**
  104549. * Stencil value used for the other meshes in the scene.
  104550. */
  104551. static NormalMeshStencilReference: number;
  104552. /**
  104553. * Specifies whether or not the inner glow is ACTIVE in the layer.
  104554. */
  104555. innerGlow: boolean;
  104556. /**
  104557. * Specifies whether or not the outer glow is ACTIVE in the layer.
  104558. */
  104559. outerGlow: boolean;
  104560. /**
  104561. * Specifies the horizontal size of the blur.
  104562. */
  104563. /**
  104564. * Gets the horizontal size of the blur.
  104565. */
  104566. blurHorizontalSize: number;
  104567. /**
  104568. * Specifies the vertical size of the blur.
  104569. */
  104570. /**
  104571. * Gets the vertical size of the blur.
  104572. */
  104573. blurVerticalSize: number;
  104574. /**
  104575. * An event triggered when the highlight layer is being blurred.
  104576. */
  104577. onBeforeBlurObservable: Observable<HighlightLayer>;
  104578. /**
  104579. * An event triggered when the highlight layer has been blurred.
  104580. */
  104581. onAfterBlurObservable: Observable<HighlightLayer>;
  104582. private _instanceGlowingMeshStencilReference;
  104583. private _options;
  104584. private _downSamplePostprocess;
  104585. private _horizontalBlurPostprocess;
  104586. private _verticalBlurPostprocess;
  104587. private _blurTexture;
  104588. private _meshes;
  104589. private _excludedMeshes;
  104590. /**
  104591. * Instantiates a new highlight Layer and references it to the scene..
  104592. * @param name The name of the layer
  104593. * @param scene The scene to use the layer in
  104594. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  104595. */
  104596. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  104597. /**
  104598. * Get the effect name of the layer.
  104599. * @return The effect name
  104600. */
  104601. getEffectName(): string;
  104602. /**
  104603. * Create the merge effect. This is the shader use to blit the information back
  104604. * to the main canvas at the end of the scene rendering.
  104605. */
  104606. protected _createMergeEffect(): Effect;
  104607. /**
  104608. * Creates the render target textures and post processes used in the highlight layer.
  104609. */
  104610. protected _createTextureAndPostProcesses(): void;
  104611. /**
  104612. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  104613. */
  104614. needStencil(): boolean;
  104615. /**
  104616. * Checks for the readiness of the element composing the layer.
  104617. * @param subMesh the mesh to check for
  104618. * @param useInstances specify wether or not to use instances to render the mesh
  104619. * @param emissiveTexture the associated emissive texture used to generate the glow
  104620. * @return true if ready otherwise, false
  104621. */
  104622. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  104623. /**
  104624. * Implementation specific of rendering the generating effect on the main canvas.
  104625. * @param effect The effect used to render through
  104626. */
  104627. protected _internalRender(effect: Effect): void;
  104628. /**
  104629. * Returns true if the layer contains information to display, otherwise false.
  104630. */
  104631. shouldRender(): boolean;
  104632. /**
  104633. * Returns true if the mesh should render, otherwise false.
  104634. * @param mesh The mesh to render
  104635. * @returns true if it should render otherwise false
  104636. */
  104637. protected _shouldRenderMesh(mesh: Mesh): boolean;
  104638. /**
  104639. * Sets the required values for both the emissive texture and and the main color.
  104640. */
  104641. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  104642. /**
  104643. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  104644. * @param mesh The mesh to exclude from the highlight layer
  104645. */
  104646. addExcludedMesh(mesh: Mesh): void;
  104647. /**
  104648. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  104649. * @param mesh The mesh to highlight
  104650. */
  104651. removeExcludedMesh(mesh: Mesh): void;
  104652. /**
  104653. * Determine if a given mesh will be highlighted by the current HighlightLayer
  104654. * @param mesh mesh to test
  104655. * @returns true if the mesh will be highlighted by the current HighlightLayer
  104656. */
  104657. hasMesh(mesh: AbstractMesh): boolean;
  104658. /**
  104659. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  104660. * @param mesh The mesh to highlight
  104661. * @param color The color of the highlight
  104662. * @param glowEmissiveOnly Extract the glow from the emissive texture
  104663. */
  104664. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  104665. /**
  104666. * Remove a mesh from the highlight layer in order to make it stop glowing.
  104667. * @param mesh The mesh to highlight
  104668. */
  104669. removeMesh(mesh: Mesh): void;
  104670. /**
  104671. * Force the stencil to the normal expected value for none glowing parts
  104672. */
  104673. private _defaultStencilReference;
  104674. /**
  104675. * Free any resources and references associated to a mesh.
  104676. * Internal use
  104677. * @param mesh The mesh to free.
  104678. * @hidden
  104679. */
  104680. _disposeMesh(mesh: Mesh): void;
  104681. /**
  104682. * Dispose the highlight layer and free resources.
  104683. */
  104684. dispose(): void;
  104685. /**
  104686. * Gets the class name of the effect layer
  104687. * @returns the string with the class name of the effect layer
  104688. */
  104689. getClassName(): string;
  104690. /**
  104691. * Serializes this Highlight layer
  104692. * @returns a serialized Highlight layer object
  104693. */
  104694. serialize(): any;
  104695. /**
  104696. * Creates a Highlight layer from parsed Highlight layer data
  104697. * @param parsedHightlightLayer defines the Highlight layer data
  104698. * @param scene defines the current scene
  104699. * @param rootUrl defines the root URL containing the Highlight layer information
  104700. * @returns a parsed Highlight layer
  104701. */
  104702. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  104703. }
  104704. }
  104705. declare module BABYLON {
  104706. /** @hidden */
  104707. export var lensFlarePixelShader: {
  104708. name: string;
  104709. shader: string;
  104710. };
  104711. }
  104712. declare module BABYLON {
  104713. /** @hidden */
  104714. export var lensFlareVertexShader: {
  104715. name: string;
  104716. shader: string;
  104717. };
  104718. }
  104719. declare module BABYLON {
  104720. /**
  104721. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  104722. * It is usually composed of several `lensFlare`.
  104723. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  104724. */
  104725. export class LensFlareSystem {
  104726. /**
  104727. * Define the name of the lens flare system
  104728. */
  104729. name: string;
  104730. /**
  104731. * List of lens flares used in this system.
  104732. */
  104733. lensFlares: LensFlare[];
  104734. /**
  104735. * Define a limit from the border the lens flare can be visible.
  104736. */
  104737. borderLimit: number;
  104738. /**
  104739. * Define a viewport border we do not want to see the lens flare in.
  104740. */
  104741. viewportBorder: number;
  104742. /**
  104743. * Define a predicate which could limit the list of meshes able to occlude the effect.
  104744. */
  104745. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  104746. /**
  104747. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  104748. */
  104749. layerMask: number;
  104750. /**
  104751. * Define the id of the lens flare system in the scene.
  104752. * (equal to name by default)
  104753. */
  104754. id: string;
  104755. private _scene;
  104756. private _emitter;
  104757. private _vertexBuffers;
  104758. private _indexBuffer;
  104759. private _effect;
  104760. private _positionX;
  104761. private _positionY;
  104762. private _isEnabled;
  104763. /** @hidden */
  104764. static _SceneComponentInitialization: (scene: Scene) => void;
  104765. /**
  104766. * Instantiates a lens flare system.
  104767. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  104768. * It is usually composed of several `lensFlare`.
  104769. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  104770. * @param name Define the name of the lens flare system in the scene
  104771. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  104772. * @param scene Define the scene the lens flare system belongs to
  104773. */
  104774. constructor(
  104775. /**
  104776. * Define the name of the lens flare system
  104777. */
  104778. name: string, emitter: any, scene: Scene);
  104779. /**
  104780. * Define if the lens flare system is enabled.
  104781. */
  104782. isEnabled: boolean;
  104783. /**
  104784. * Get the scene the effects belongs to.
  104785. * @returns the scene holding the lens flare system
  104786. */
  104787. getScene(): Scene;
  104788. /**
  104789. * Get the emitter of the lens flare system.
  104790. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  104791. * @returns the emitter of the lens flare system
  104792. */
  104793. getEmitter(): any;
  104794. /**
  104795. * Set the emitter of the lens flare system.
  104796. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  104797. * @param newEmitter Define the new emitter of the system
  104798. */
  104799. setEmitter(newEmitter: any): void;
  104800. /**
  104801. * Get the lens flare system emitter position.
  104802. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  104803. * @returns the position
  104804. */
  104805. getEmitterPosition(): Vector3;
  104806. /**
  104807. * @hidden
  104808. */
  104809. computeEffectivePosition(globalViewport: Viewport): boolean;
  104810. /** @hidden */
  104811. _isVisible(): boolean;
  104812. /**
  104813. * @hidden
  104814. */
  104815. render(): boolean;
  104816. /**
  104817. * Dispose and release the lens flare with its associated resources.
  104818. */
  104819. dispose(): void;
  104820. /**
  104821. * Parse a lens flare system from a JSON repressentation
  104822. * @param parsedLensFlareSystem Define the JSON to parse
  104823. * @param scene Define the scene the parsed system should be instantiated in
  104824. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  104825. * @returns the parsed system
  104826. */
  104827. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  104828. /**
  104829. * Serialize the current Lens Flare System into a JSON representation.
  104830. * @returns the serialized JSON
  104831. */
  104832. serialize(): any;
  104833. }
  104834. }
  104835. declare module BABYLON {
  104836. /**
  104837. * This represents one of the lens effect in a `lensFlareSystem`.
  104838. * It controls one of the indiviual texture used in the effect.
  104839. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  104840. */
  104841. export class LensFlare {
  104842. /**
  104843. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  104844. */
  104845. size: number;
  104846. /**
  104847. * 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.
  104848. */
  104849. position: number;
  104850. /**
  104851. * Define the lens color.
  104852. */
  104853. color: Color3;
  104854. /**
  104855. * Define the lens texture.
  104856. */
  104857. texture: Nullable<Texture>;
  104858. /**
  104859. * Define the alpha mode to render this particular lens.
  104860. */
  104861. alphaMode: number;
  104862. private _system;
  104863. /**
  104864. * Creates a new Lens Flare.
  104865. * This represents one of the lens effect in a `lensFlareSystem`.
  104866. * It controls one of the indiviual texture used in the effect.
  104867. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  104868. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  104869. * @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.
  104870. * @param color Define the lens color
  104871. * @param imgUrl Define the lens texture url
  104872. * @param system Define the `lensFlareSystem` this flare is part of
  104873. * @returns The newly created Lens Flare
  104874. */
  104875. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  104876. /**
  104877. * Instantiates a new Lens Flare.
  104878. * This represents one of the lens effect in a `lensFlareSystem`.
  104879. * It controls one of the indiviual texture used in the effect.
  104880. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  104881. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  104882. * @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.
  104883. * @param color Define the lens color
  104884. * @param imgUrl Define the lens texture url
  104885. * @param system Define the `lensFlareSystem` this flare is part of
  104886. */
  104887. constructor(
  104888. /**
  104889. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  104890. */
  104891. size: number,
  104892. /**
  104893. * 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.
  104894. */
  104895. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  104896. /**
  104897. * Dispose and release the lens flare with its associated resources.
  104898. */
  104899. dispose(): void;
  104900. }
  104901. }
  104902. declare module BABYLON {
  104903. interface AbstractScene {
  104904. /**
  104905. * The list of lens flare system added to the scene
  104906. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  104907. */
  104908. lensFlareSystems: Array<LensFlareSystem>;
  104909. /**
  104910. * Removes the given lens flare system from this scene.
  104911. * @param toRemove The lens flare system to remove
  104912. * @returns The index of the removed lens flare system
  104913. */
  104914. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  104915. /**
  104916. * Adds the given lens flare system to this scene
  104917. * @param newLensFlareSystem The lens flare system to add
  104918. */
  104919. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  104920. /**
  104921. * Gets a lens flare system using its name
  104922. * @param name defines the name to look for
  104923. * @returns the lens flare system or null if not found
  104924. */
  104925. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  104926. /**
  104927. * Gets a lens flare system using its id
  104928. * @param id defines the id to look for
  104929. * @returns the lens flare system or null if not found
  104930. */
  104931. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  104932. }
  104933. /**
  104934. * Defines the lens flare scene component responsible to manage any lens flares
  104935. * in a given scene.
  104936. */
  104937. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  104938. /**
  104939. * The component name helpfull to identify the component in the list of scene components.
  104940. */
  104941. readonly name: string;
  104942. /**
  104943. * The scene the component belongs to.
  104944. */
  104945. scene: Scene;
  104946. /**
  104947. * Creates a new instance of the component for the given scene
  104948. * @param scene Defines the scene to register the component in
  104949. */
  104950. constructor(scene: Scene);
  104951. /**
  104952. * Registers the component in a given scene
  104953. */
  104954. register(): void;
  104955. /**
  104956. * Rebuilds the elements related to this component in case of
  104957. * context lost for instance.
  104958. */
  104959. rebuild(): void;
  104960. /**
  104961. * Adds all the element from the container to the scene
  104962. * @param container the container holding the elements
  104963. */
  104964. addFromContainer(container: AbstractScene): void;
  104965. /**
  104966. * Removes all the elements in the container from the scene
  104967. * @param container contains the elements to remove
  104968. */
  104969. removeFromContainer(container: AbstractScene): void;
  104970. /**
  104971. * Serializes the component data to the specified json object
  104972. * @param serializationObject The object to serialize to
  104973. */
  104974. serialize(serializationObject: any): void;
  104975. /**
  104976. * Disposes the component and the associated ressources.
  104977. */
  104978. dispose(): void;
  104979. private _draw;
  104980. }
  104981. }
  104982. declare module BABYLON {
  104983. /**
  104984. * Defines the shadow generator component responsible to manage any shadow generators
  104985. * in a given scene.
  104986. */
  104987. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  104988. /**
  104989. * The component name helpfull to identify the component in the list of scene components.
  104990. */
  104991. readonly name: string;
  104992. /**
  104993. * The scene the component belongs to.
  104994. */
  104995. scene: Scene;
  104996. /**
  104997. * Creates a new instance of the component for the given scene
  104998. * @param scene Defines the scene to register the component in
  104999. */
  105000. constructor(scene: Scene);
  105001. /**
  105002. * Registers the component in a given scene
  105003. */
  105004. register(): void;
  105005. /**
  105006. * Rebuilds the elements related to this component in case of
  105007. * context lost for instance.
  105008. */
  105009. rebuild(): void;
  105010. /**
  105011. * Serializes the component data to the specified json object
  105012. * @param serializationObject The object to serialize to
  105013. */
  105014. serialize(serializationObject: any): void;
  105015. /**
  105016. * Adds all the element from the container to the scene
  105017. * @param container the container holding the elements
  105018. */
  105019. addFromContainer(container: AbstractScene): void;
  105020. /**
  105021. * Removes all the elements in the container from the scene
  105022. * @param container contains the elements to remove
  105023. */
  105024. removeFromContainer(container: AbstractScene): void;
  105025. /**
  105026. * Rebuilds the elements related to this component in case of
  105027. * context lost for instance.
  105028. */
  105029. dispose(): void;
  105030. private _gatherRenderTargets;
  105031. }
  105032. }
  105033. declare module BABYLON {
  105034. /**
  105035. * A directional light is defined by a direction (what a surprise!).
  105036. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  105037. * 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.
  105038. * Documentation: https://doc.babylonjs.com/babylon101/lights
  105039. */
  105040. export class DirectionalLight extends ShadowLight {
  105041. private _shadowFrustumSize;
  105042. /**
  105043. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  105044. */
  105045. /**
  105046. * Specifies a fix frustum size for the shadow generation.
  105047. */
  105048. shadowFrustumSize: number;
  105049. private _shadowOrthoScale;
  105050. /**
  105051. * Gets the shadow projection scale against the optimal computed one.
  105052. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  105053. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  105054. */
  105055. /**
  105056. * Sets the shadow projection scale against the optimal computed one.
  105057. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  105058. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  105059. */
  105060. shadowOrthoScale: number;
  105061. /**
  105062. * Automatically compute the projection matrix to best fit (including all the casters)
  105063. * on each frame.
  105064. */
  105065. autoUpdateExtends: boolean;
  105066. private _orthoLeft;
  105067. private _orthoRight;
  105068. private _orthoTop;
  105069. private _orthoBottom;
  105070. /**
  105071. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  105072. * The directional light is emitted from everywhere in the given direction.
  105073. * It can cast shadows.
  105074. * Documentation : https://doc.babylonjs.com/babylon101/lights
  105075. * @param name The friendly name of the light
  105076. * @param direction The direction of the light
  105077. * @param scene The scene the light belongs to
  105078. */
  105079. constructor(name: string, direction: Vector3, scene: Scene);
  105080. /**
  105081. * Returns the string "DirectionalLight".
  105082. * @return The class name
  105083. */
  105084. getClassName(): string;
  105085. /**
  105086. * Returns the integer 1.
  105087. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  105088. */
  105089. getTypeID(): number;
  105090. /**
  105091. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  105092. * Returns the DirectionalLight Shadow projection matrix.
  105093. */
  105094. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  105095. /**
  105096. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  105097. * Returns the DirectionalLight Shadow projection matrix.
  105098. */
  105099. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  105100. /**
  105101. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  105102. * Returns the DirectionalLight Shadow projection matrix.
  105103. */
  105104. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  105105. protected _buildUniformLayout(): void;
  105106. /**
  105107. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  105108. * @param effect The effect to update
  105109. * @param lightIndex The index of the light in the effect to update
  105110. * @returns The directional light
  105111. */
  105112. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  105113. /**
  105114. * Gets the minZ used for shadow according to both the scene and the light.
  105115. *
  105116. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  105117. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  105118. * @param activeCamera The camera we are returning the min for
  105119. * @returns the depth min z
  105120. */
  105121. getDepthMinZ(activeCamera: Camera): number;
  105122. /**
  105123. * Gets the maxZ used for shadow according to both the scene and the light.
  105124. *
  105125. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  105126. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  105127. * @param activeCamera The camera we are returning the max for
  105128. * @returns the depth max z
  105129. */
  105130. getDepthMaxZ(activeCamera: Camera): number;
  105131. /**
  105132. * Prepares the list of defines specific to the light type.
  105133. * @param defines the list of defines
  105134. * @param lightIndex defines the index of the light for the effect
  105135. */
  105136. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  105137. }
  105138. }
  105139. declare module BABYLON {
  105140. /**
  105141. * A point light is a light defined by an unique point in world space.
  105142. * The light is emitted in every direction from this point.
  105143. * A good example of a point light is a standard light bulb.
  105144. * Documentation: https://doc.babylonjs.com/babylon101/lights
  105145. */
  105146. export class PointLight extends ShadowLight {
  105147. private _shadowAngle;
  105148. /**
  105149. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  105150. * This specifies what angle the shadow will use to be created.
  105151. *
  105152. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  105153. */
  105154. /**
  105155. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  105156. * This specifies what angle the shadow will use to be created.
  105157. *
  105158. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  105159. */
  105160. shadowAngle: number;
  105161. /**
  105162. * Gets the direction if it has been set.
  105163. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  105164. */
  105165. /**
  105166. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  105167. */
  105168. direction: Vector3;
  105169. /**
  105170. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  105171. * A PointLight emits the light in every direction.
  105172. * It can cast shadows.
  105173. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  105174. * ```javascript
  105175. * var pointLight = new PointLight("pl", camera.position, scene);
  105176. * ```
  105177. * Documentation : https://doc.babylonjs.com/babylon101/lights
  105178. * @param name The light friendly name
  105179. * @param position The position of the point light in the scene
  105180. * @param scene The scene the lights belongs to
  105181. */
  105182. constructor(name: string, position: Vector3, scene: Scene);
  105183. /**
  105184. * Returns the string "PointLight"
  105185. * @returns the class name
  105186. */
  105187. getClassName(): string;
  105188. /**
  105189. * Returns the integer 0.
  105190. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  105191. */
  105192. getTypeID(): number;
  105193. /**
  105194. * Specifies wether or not the shadowmap should be a cube texture.
  105195. * @returns true if the shadowmap needs to be a cube texture.
  105196. */
  105197. needCube(): boolean;
  105198. /**
  105199. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  105200. * @param faceIndex The index of the face we are computed the direction to generate shadow
  105201. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  105202. */
  105203. getShadowDirection(faceIndex?: number): Vector3;
  105204. /**
  105205. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  105206. * - fov = PI / 2
  105207. * - aspect ratio : 1.0
  105208. * - z-near and far equal to the active camera minZ and maxZ.
  105209. * Returns the PointLight.
  105210. */
  105211. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  105212. protected _buildUniformLayout(): void;
  105213. /**
  105214. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  105215. * @param effect The effect to update
  105216. * @param lightIndex The index of the light in the effect to update
  105217. * @returns The point light
  105218. */
  105219. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  105220. /**
  105221. * Prepares the list of defines specific to the light type.
  105222. * @param defines the list of defines
  105223. * @param lightIndex defines the index of the light for the effect
  105224. */
  105225. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  105226. }
  105227. }
  105228. declare module BABYLON {
  105229. /**
  105230. * A spot light is defined by a position, a direction, an angle, and an exponent.
  105231. * These values define a cone of light starting from the position, emitting toward the direction.
  105232. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  105233. * and the exponent defines the speed of the decay of the light with distance (reach).
  105234. * Documentation: https://doc.babylonjs.com/babylon101/lights
  105235. */
  105236. export class SpotLight extends ShadowLight {
  105237. private _angle;
  105238. private _innerAngle;
  105239. private _cosHalfAngle;
  105240. private _lightAngleScale;
  105241. private _lightAngleOffset;
  105242. /**
  105243. * Gets the cone angle of the spot light in Radians.
  105244. */
  105245. /**
  105246. * Sets the cone angle of the spot light in Radians.
  105247. */
  105248. angle: number;
  105249. /**
  105250. * Only used in gltf falloff mode, this defines the angle where
  105251. * the directional falloff will start before cutting at angle which could be seen
  105252. * as outer angle.
  105253. */
  105254. /**
  105255. * Only used in gltf falloff mode, this defines the angle where
  105256. * the directional falloff will start before cutting at angle which could be seen
  105257. * as outer angle.
  105258. */
  105259. innerAngle: number;
  105260. private _shadowAngleScale;
  105261. /**
  105262. * Allows scaling the angle of the light for shadow generation only.
  105263. */
  105264. /**
  105265. * Allows scaling the angle of the light for shadow generation only.
  105266. */
  105267. shadowAngleScale: number;
  105268. /**
  105269. * The light decay speed with the distance from the emission spot.
  105270. */
  105271. exponent: number;
  105272. private _projectionTextureMatrix;
  105273. /**
  105274. * Allows reading the projecton texture
  105275. */
  105276. readonly projectionTextureMatrix: Matrix;
  105277. protected _projectionTextureLightNear: number;
  105278. /**
  105279. * Gets the near clip of the Spotlight for texture projection.
  105280. */
  105281. /**
  105282. * Sets the near clip of the Spotlight for texture projection.
  105283. */
  105284. projectionTextureLightNear: number;
  105285. protected _projectionTextureLightFar: number;
  105286. /**
  105287. * Gets the far clip of the Spotlight for texture projection.
  105288. */
  105289. /**
  105290. * Sets the far clip of the Spotlight for texture projection.
  105291. */
  105292. projectionTextureLightFar: number;
  105293. protected _projectionTextureUpDirection: Vector3;
  105294. /**
  105295. * Gets the Up vector of the Spotlight for texture projection.
  105296. */
  105297. /**
  105298. * Sets the Up vector of the Spotlight for texture projection.
  105299. */
  105300. projectionTextureUpDirection: Vector3;
  105301. private _projectionTexture;
  105302. /**
  105303. * Gets the projection texture of the light.
  105304. */
  105305. /**
  105306. * Sets the projection texture of the light.
  105307. */
  105308. projectionTexture: Nullable<BaseTexture>;
  105309. private _projectionTextureViewLightDirty;
  105310. private _projectionTextureProjectionLightDirty;
  105311. private _projectionTextureDirty;
  105312. private _projectionTextureViewTargetVector;
  105313. private _projectionTextureViewLightMatrix;
  105314. private _projectionTextureProjectionLightMatrix;
  105315. private _projectionTextureScalingMatrix;
  105316. /**
  105317. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  105318. * It can cast shadows.
  105319. * Documentation : https://doc.babylonjs.com/babylon101/lights
  105320. * @param name The light friendly name
  105321. * @param position The position of the spot light in the scene
  105322. * @param direction The direction of the light in the scene
  105323. * @param angle The cone angle of the light in Radians
  105324. * @param exponent The light decay speed with the distance from the emission spot
  105325. * @param scene The scene the lights belongs to
  105326. */
  105327. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  105328. /**
  105329. * Returns the string "SpotLight".
  105330. * @returns the class name
  105331. */
  105332. getClassName(): string;
  105333. /**
  105334. * Returns the integer 2.
  105335. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  105336. */
  105337. getTypeID(): number;
  105338. /**
  105339. * Overrides the direction setter to recompute the projection texture view light Matrix.
  105340. */
  105341. protected _setDirection(value: Vector3): void;
  105342. /**
  105343. * Overrides the position setter to recompute the projection texture view light Matrix.
  105344. */
  105345. protected _setPosition(value: Vector3): void;
  105346. /**
  105347. * 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.
  105348. * Returns the SpotLight.
  105349. */
  105350. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  105351. protected _computeProjectionTextureViewLightMatrix(): void;
  105352. protected _computeProjectionTextureProjectionLightMatrix(): void;
  105353. /**
  105354. * Main function for light texture projection matrix computing.
  105355. */
  105356. protected _computeProjectionTextureMatrix(): void;
  105357. protected _buildUniformLayout(): void;
  105358. private _computeAngleValues;
  105359. /**
  105360. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  105361. * @param effect The effect to update
  105362. * @param lightIndex The index of the light in the effect to update
  105363. * @returns The spot light
  105364. */
  105365. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  105366. /**
  105367. * Disposes the light and the associated resources.
  105368. */
  105369. dispose(): void;
  105370. /**
  105371. * Prepares the list of defines specific to the light type.
  105372. * @param defines the list of defines
  105373. * @param lightIndex defines the index of the light for the effect
  105374. */
  105375. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  105376. }
  105377. }
  105378. declare module BABYLON {
  105379. /**
  105380. * Header information of HDR texture files.
  105381. */
  105382. export interface HDRInfo {
  105383. /**
  105384. * The height of the texture in pixels.
  105385. */
  105386. height: number;
  105387. /**
  105388. * The width of the texture in pixels.
  105389. */
  105390. width: number;
  105391. /**
  105392. * The index of the beginning of the data in the binary file.
  105393. */
  105394. dataPosition: number;
  105395. }
  105396. /**
  105397. * This groups tools to convert HDR texture to native colors array.
  105398. */
  105399. export class HDRTools {
  105400. private static Ldexp;
  105401. private static Rgbe2float;
  105402. private static readStringLine;
  105403. /**
  105404. * Reads header information from an RGBE texture stored in a native array.
  105405. * More information on this format are available here:
  105406. * https://en.wikipedia.org/wiki/RGBE_image_format
  105407. *
  105408. * @param uint8array The binary file stored in native array.
  105409. * @return The header information.
  105410. */
  105411. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  105412. /**
  105413. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  105414. * This RGBE texture needs to store the information as a panorama.
  105415. *
  105416. * More information on this format are available here:
  105417. * https://en.wikipedia.org/wiki/RGBE_image_format
  105418. *
  105419. * @param buffer The binary file stored in an array buffer.
  105420. * @param size The expected size of the extracted cubemap.
  105421. * @return The Cube Map information.
  105422. */
  105423. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  105424. /**
  105425. * Returns the pixels data extracted from an RGBE texture.
  105426. * This pixels will be stored left to right up to down in the R G B order in one array.
  105427. *
  105428. * More information on this format are available here:
  105429. * https://en.wikipedia.org/wiki/RGBE_image_format
  105430. *
  105431. * @param uint8array The binary file stored in an array buffer.
  105432. * @param hdrInfo The header information of the file.
  105433. * @return The pixels data in RGB right to left up to down order.
  105434. */
  105435. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  105436. private static RGBE_ReadPixels_RLE;
  105437. }
  105438. }
  105439. declare module BABYLON {
  105440. /**
  105441. * This represents a texture coming from an HDR input.
  105442. *
  105443. * The only supported format is currently panorama picture stored in RGBE format.
  105444. * Example of such files can be found on HDRLib: http://hdrlib.com/
  105445. */
  105446. export class HDRCubeTexture extends BaseTexture {
  105447. private static _facesMapping;
  105448. private _generateHarmonics;
  105449. private _noMipmap;
  105450. private _textureMatrix;
  105451. private _size;
  105452. private _onLoad;
  105453. private _onError;
  105454. /**
  105455. * The texture URL.
  105456. */
  105457. url: string;
  105458. /**
  105459. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  105460. */
  105461. coordinatesMode: number;
  105462. protected _isBlocking: boolean;
  105463. /**
  105464. * Sets wether or not the texture is blocking during loading.
  105465. */
  105466. /**
  105467. * Gets wether or not the texture is blocking during loading.
  105468. */
  105469. isBlocking: boolean;
  105470. protected _rotationY: number;
  105471. /**
  105472. * Sets texture matrix rotation angle around Y axis in radians.
  105473. */
  105474. /**
  105475. * Gets texture matrix rotation angle around Y axis radians.
  105476. */
  105477. rotationY: number;
  105478. /**
  105479. * Gets or sets the center of the bounding box associated with the cube texture
  105480. * It must define where the camera used to render the texture was set
  105481. */
  105482. boundingBoxPosition: Vector3;
  105483. private _boundingBoxSize;
  105484. /**
  105485. * Gets or sets the size of the bounding box associated with the cube texture
  105486. * When defined, the cubemap will switch to local mode
  105487. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  105488. * @example https://www.babylonjs-playground.com/#RNASML
  105489. */
  105490. boundingBoxSize: Vector3;
  105491. /**
  105492. * Instantiates an HDRTexture from the following parameters.
  105493. *
  105494. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  105495. * @param scene The scene the texture will be used in
  105496. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  105497. * @param noMipmap Forces to not generate the mipmap if true
  105498. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  105499. * @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)
  105500. * @param reserved Reserved flag for internal use.
  105501. */
  105502. 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>);
  105503. /**
  105504. * Get the current class name of the texture useful for serialization or dynamic coding.
  105505. * @returns "HDRCubeTexture"
  105506. */
  105507. getClassName(): string;
  105508. /**
  105509. * Occurs when the file is raw .hdr file.
  105510. */
  105511. private loadTexture;
  105512. clone(): HDRCubeTexture;
  105513. delayLoad(): void;
  105514. /**
  105515. * Get the texture reflection matrix used to rotate/transform the reflection.
  105516. * @returns the reflection matrix
  105517. */
  105518. getReflectionTextureMatrix(): Matrix;
  105519. /**
  105520. * Set the texture reflection matrix used to rotate/transform the reflection.
  105521. * @param value Define the reflection matrix to set
  105522. */
  105523. setReflectionTextureMatrix(value: Matrix): void;
  105524. /**
  105525. * Parses a JSON representation of an HDR Texture in order to create the texture
  105526. * @param parsedTexture Define the JSON representation
  105527. * @param scene Define the scene the texture should be created in
  105528. * @param rootUrl Define the root url in case we need to load relative dependencies
  105529. * @returns the newly created texture after parsing
  105530. */
  105531. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  105532. serialize(): any;
  105533. }
  105534. }
  105535. declare module BABYLON {
  105536. /**
  105537. * Class used to control physics engine
  105538. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  105539. */
  105540. export class PhysicsEngine implements IPhysicsEngine {
  105541. private _physicsPlugin;
  105542. /**
  105543. * Global value used to control the smallest number supported by the simulation
  105544. */
  105545. static Epsilon: number;
  105546. private _impostors;
  105547. private _joints;
  105548. /**
  105549. * Gets the gravity vector used by the simulation
  105550. */
  105551. gravity: Vector3;
  105552. /**
  105553. * Factory used to create the default physics plugin.
  105554. * @returns The default physics plugin
  105555. */
  105556. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  105557. /**
  105558. * Creates a new Physics Engine
  105559. * @param gravity defines the gravity vector used by the simulation
  105560. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  105561. */
  105562. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  105563. /**
  105564. * Sets the gravity vector used by the simulation
  105565. * @param gravity defines the gravity vector to use
  105566. */
  105567. setGravity(gravity: Vector3): void;
  105568. /**
  105569. * Set the time step of the physics engine.
  105570. * Default is 1/60.
  105571. * To slow it down, enter 1/600 for example.
  105572. * To speed it up, 1/30
  105573. * @param newTimeStep defines the new timestep to apply to this world.
  105574. */
  105575. setTimeStep(newTimeStep?: number): void;
  105576. /**
  105577. * Get the time step of the physics engine.
  105578. * @returns the current time step
  105579. */
  105580. getTimeStep(): number;
  105581. /**
  105582. * Release all resources
  105583. */
  105584. dispose(): void;
  105585. /**
  105586. * Gets the name of the current physics plugin
  105587. * @returns the name of the plugin
  105588. */
  105589. getPhysicsPluginName(): string;
  105590. /**
  105591. * Adding a new impostor for the impostor tracking.
  105592. * This will be done by the impostor itself.
  105593. * @param impostor the impostor to add
  105594. */
  105595. addImpostor(impostor: PhysicsImpostor): void;
  105596. /**
  105597. * Remove an impostor from the engine.
  105598. * This impostor and its mesh will not longer be updated by the physics engine.
  105599. * @param impostor the impostor to remove
  105600. */
  105601. removeImpostor(impostor: PhysicsImpostor): void;
  105602. /**
  105603. * Add a joint to the physics engine
  105604. * @param mainImpostor defines the main impostor to which the joint is added.
  105605. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  105606. * @param joint defines the joint that will connect both impostors.
  105607. */
  105608. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  105609. /**
  105610. * Removes a joint from the simulation
  105611. * @param mainImpostor defines the impostor used with the joint
  105612. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  105613. * @param joint defines the joint to remove
  105614. */
  105615. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  105616. /**
  105617. * Called by the scene. No need to call it.
  105618. * @param delta defines the timespam between frames
  105619. */
  105620. _step(delta: number): void;
  105621. /**
  105622. * Gets the current plugin used to run the simulation
  105623. * @returns current plugin
  105624. */
  105625. getPhysicsPlugin(): IPhysicsEnginePlugin;
  105626. /**
  105627. * Gets the list of physic impostors
  105628. * @returns an array of PhysicsImpostor
  105629. */
  105630. getImpostors(): Array<PhysicsImpostor>;
  105631. /**
  105632. * Gets the impostor for a physics enabled object
  105633. * @param object defines the object impersonated by the impostor
  105634. * @returns the PhysicsImpostor or null if not found
  105635. */
  105636. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  105637. /**
  105638. * Gets the impostor for a physics body object
  105639. * @param body defines physics body used by the impostor
  105640. * @returns the PhysicsImpostor or null if not found
  105641. */
  105642. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  105643. /**
  105644. * Does a raycast in the physics world
  105645. * @param from when should the ray start?
  105646. * @param to when should the ray end?
  105647. * @returns PhysicsRaycastResult
  105648. */
  105649. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  105650. }
  105651. }
  105652. declare module BABYLON {
  105653. /** @hidden */
  105654. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  105655. private _useDeltaForWorldStep;
  105656. world: any;
  105657. name: string;
  105658. private _physicsMaterials;
  105659. private _fixedTimeStep;
  105660. private _cannonRaycastResult;
  105661. private _raycastResult;
  105662. BJSCANNON: any;
  105663. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  105664. setGravity(gravity: Vector3): void;
  105665. setTimeStep(timeStep: number): void;
  105666. getTimeStep(): number;
  105667. executeStep(delta: number): void;
  105668. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105669. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105670. generatePhysicsBody(impostor: PhysicsImpostor): void;
  105671. private _processChildMeshes;
  105672. removePhysicsBody(impostor: PhysicsImpostor): void;
  105673. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  105674. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  105675. private _addMaterial;
  105676. private _checkWithEpsilon;
  105677. private _createShape;
  105678. private _createHeightmap;
  105679. private _minus90X;
  105680. private _plus90X;
  105681. private _tmpPosition;
  105682. private _tmpDeltaPosition;
  105683. private _tmpUnityRotation;
  105684. private _updatePhysicsBodyTransformation;
  105685. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  105686. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  105687. isSupported(): boolean;
  105688. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  105689. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  105690. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  105691. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  105692. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  105693. getBodyMass(impostor: PhysicsImpostor): number;
  105694. getBodyFriction(impostor: PhysicsImpostor): number;
  105695. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  105696. getBodyRestitution(impostor: PhysicsImpostor): number;
  105697. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  105698. sleepBody(impostor: PhysicsImpostor): void;
  105699. wakeUpBody(impostor: PhysicsImpostor): void;
  105700. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  105701. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  105702. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  105703. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  105704. getRadius(impostor: PhysicsImpostor): number;
  105705. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  105706. dispose(): void;
  105707. private _extendNamespace;
  105708. /**
  105709. * Does a raycast in the physics world
  105710. * @param from when should the ray start?
  105711. * @param to when should the ray end?
  105712. * @returns PhysicsRaycastResult
  105713. */
  105714. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  105715. }
  105716. }
  105717. declare module BABYLON {
  105718. /** @hidden */
  105719. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  105720. world: any;
  105721. name: string;
  105722. BJSOIMO: any;
  105723. private _raycastResult;
  105724. constructor(iterations?: number, oimoInjection?: any);
  105725. setGravity(gravity: Vector3): void;
  105726. setTimeStep(timeStep: number): void;
  105727. getTimeStep(): number;
  105728. private _tmpImpostorsArray;
  105729. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  105730. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105731. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105732. generatePhysicsBody(impostor: PhysicsImpostor): void;
  105733. private _tmpPositionVector;
  105734. removePhysicsBody(impostor: PhysicsImpostor): void;
  105735. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  105736. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  105737. isSupported(): boolean;
  105738. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  105739. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  105740. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  105741. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  105742. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  105743. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  105744. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  105745. getBodyMass(impostor: PhysicsImpostor): number;
  105746. getBodyFriction(impostor: PhysicsImpostor): number;
  105747. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  105748. getBodyRestitution(impostor: PhysicsImpostor): number;
  105749. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  105750. sleepBody(impostor: PhysicsImpostor): void;
  105751. wakeUpBody(impostor: PhysicsImpostor): void;
  105752. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  105753. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  105754. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  105755. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  105756. getRadius(impostor: PhysicsImpostor): number;
  105757. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  105758. dispose(): void;
  105759. /**
  105760. * Does a raycast in the physics world
  105761. * @param from when should the ray start?
  105762. * @param to when should the ray end?
  105763. * @returns PhysicsRaycastResult
  105764. */
  105765. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  105766. }
  105767. }
  105768. declare module BABYLON {
  105769. interface AbstractScene {
  105770. /**
  105771. * The list of reflection probes added to the scene
  105772. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  105773. */
  105774. reflectionProbes: Array<ReflectionProbe>;
  105775. /**
  105776. * Removes the given reflection probe from this scene.
  105777. * @param toRemove The reflection probe to remove
  105778. * @returns The index of the removed reflection probe
  105779. */
  105780. removeReflectionProbe(toRemove: ReflectionProbe): number;
  105781. /**
  105782. * Adds the given reflection probe to this scene.
  105783. * @param newReflectionProbe The reflection probe to add
  105784. */
  105785. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  105786. }
  105787. /**
  105788. * Class used to generate realtime reflection / refraction cube textures
  105789. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  105790. */
  105791. export class ReflectionProbe {
  105792. /** defines the name of the probe */
  105793. name: string;
  105794. private _scene;
  105795. private _renderTargetTexture;
  105796. private _projectionMatrix;
  105797. private _viewMatrix;
  105798. private _target;
  105799. private _add;
  105800. private _attachedMesh;
  105801. private _invertYAxis;
  105802. /** Gets or sets probe position (center of the cube map) */
  105803. position: Vector3;
  105804. /**
  105805. * Creates a new reflection probe
  105806. * @param name defines the name of the probe
  105807. * @param size defines the texture resolution (for each face)
  105808. * @param scene defines the hosting scene
  105809. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  105810. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  105811. */
  105812. constructor(
  105813. /** defines the name of the probe */
  105814. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  105815. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  105816. samples: number;
  105817. /** Gets or sets the refresh rate to use (on every frame by default) */
  105818. refreshRate: number;
  105819. /**
  105820. * Gets the hosting scene
  105821. * @returns a Scene
  105822. */
  105823. getScene(): Scene;
  105824. /** Gets the internal CubeTexture used to render to */
  105825. readonly cubeTexture: RenderTargetTexture;
  105826. /** Gets the list of meshes to render */
  105827. readonly renderList: Nullable<AbstractMesh[]>;
  105828. /**
  105829. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  105830. * @param mesh defines the mesh to attach to
  105831. */
  105832. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  105833. /**
  105834. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  105835. * @param renderingGroupId The rendering group id corresponding to its index
  105836. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  105837. */
  105838. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  105839. /**
  105840. * Clean all associated resources
  105841. */
  105842. dispose(): void;
  105843. /**
  105844. * Converts the reflection probe information to a readable string for debug purpose.
  105845. * @param fullDetails Supports for multiple levels of logging within scene loading
  105846. * @returns the human readable reflection probe info
  105847. */
  105848. toString(fullDetails?: boolean): string;
  105849. /**
  105850. * Get the class name of the relfection probe.
  105851. * @returns "ReflectionProbe"
  105852. */
  105853. getClassName(): string;
  105854. /**
  105855. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  105856. * @returns The JSON representation of the texture
  105857. */
  105858. serialize(): any;
  105859. /**
  105860. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  105861. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  105862. * @param scene Define the scene the parsed reflection probe should be instantiated in
  105863. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  105864. * @returns The parsed reflection probe if successful
  105865. */
  105866. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  105867. }
  105868. }
  105869. declare module BABYLON {
  105870. /** @hidden */
  105871. export var _BabylonLoaderRegistered: boolean;
  105872. }
  105873. declare module BABYLON {
  105874. /**
  105875. * The Physically based simple base material of BJS.
  105876. *
  105877. * This enables better naming and convention enforcements on top of the pbrMaterial.
  105878. * It is used as the base class for both the specGloss and metalRough conventions.
  105879. */
  105880. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  105881. /**
  105882. * Number of Simultaneous lights allowed on the material.
  105883. */
  105884. maxSimultaneousLights: number;
  105885. /**
  105886. * If sets to true, disables all the lights affecting the material.
  105887. */
  105888. disableLighting: boolean;
  105889. /**
  105890. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  105891. */
  105892. environmentTexture: BaseTexture;
  105893. /**
  105894. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  105895. */
  105896. invertNormalMapX: boolean;
  105897. /**
  105898. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  105899. */
  105900. invertNormalMapY: boolean;
  105901. /**
  105902. * Normal map used in the model.
  105903. */
  105904. normalTexture: BaseTexture;
  105905. /**
  105906. * Emissivie color used to self-illuminate the model.
  105907. */
  105908. emissiveColor: Color3;
  105909. /**
  105910. * Emissivie texture used to self-illuminate the model.
  105911. */
  105912. emissiveTexture: BaseTexture;
  105913. /**
  105914. * Occlusion Channel Strenght.
  105915. */
  105916. occlusionStrength: number;
  105917. /**
  105918. * Occlusion Texture of the material (adding extra occlusion effects).
  105919. */
  105920. occlusionTexture: BaseTexture;
  105921. /**
  105922. * Defines the alpha limits in alpha test mode.
  105923. */
  105924. alphaCutOff: number;
  105925. /**
  105926. * Gets the current double sided mode.
  105927. */
  105928. /**
  105929. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  105930. */
  105931. doubleSided: boolean;
  105932. /**
  105933. * Stores the pre-calculated light information of a mesh in a texture.
  105934. */
  105935. lightmapTexture: BaseTexture;
  105936. /**
  105937. * If true, the light map contains occlusion information instead of lighting info.
  105938. */
  105939. useLightmapAsShadowmap: boolean;
  105940. /**
  105941. * Instantiates a new PBRMaterial instance.
  105942. *
  105943. * @param name The material name
  105944. * @param scene The scene the material will be use in.
  105945. */
  105946. constructor(name: string, scene: Scene);
  105947. getClassName(): string;
  105948. }
  105949. }
  105950. declare module BABYLON {
  105951. /**
  105952. * The PBR material of BJS following the metal roughness convention.
  105953. *
  105954. * This fits to the PBR convention in the GLTF definition:
  105955. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  105956. */
  105957. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  105958. /**
  105959. * The base color has two different interpretations depending on the value of metalness.
  105960. * When the material is a metal, the base color is the specific measured reflectance value
  105961. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  105962. * of the material.
  105963. */
  105964. baseColor: Color3;
  105965. /**
  105966. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  105967. * well as opacity information in the alpha channel.
  105968. */
  105969. baseTexture: BaseTexture;
  105970. /**
  105971. * Specifies the metallic scalar value of the material.
  105972. * Can also be used to scale the metalness values of the metallic texture.
  105973. */
  105974. metallic: number;
  105975. /**
  105976. * Specifies the roughness scalar value of the material.
  105977. * Can also be used to scale the roughness values of the metallic texture.
  105978. */
  105979. roughness: number;
  105980. /**
  105981. * Texture containing both the metallic value in the B channel and the
  105982. * roughness value in the G channel to keep better precision.
  105983. */
  105984. metallicRoughnessTexture: BaseTexture;
  105985. /**
  105986. * Instantiates a new PBRMetalRoughnessMaterial instance.
  105987. *
  105988. * @param name The material name
  105989. * @param scene The scene the material will be use in.
  105990. */
  105991. constructor(name: string, scene: Scene);
  105992. /**
  105993. * Return the currrent class name of the material.
  105994. */
  105995. getClassName(): string;
  105996. /**
  105997. * Makes a duplicate of the current material.
  105998. * @param name - name to use for the new material.
  105999. */
  106000. clone(name: string): PBRMetallicRoughnessMaterial;
  106001. /**
  106002. * Serialize the material to a parsable JSON object.
  106003. */
  106004. serialize(): any;
  106005. /**
  106006. * Parses a JSON object correponding to the serialize function.
  106007. */
  106008. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  106009. }
  106010. }
  106011. declare module BABYLON {
  106012. /**
  106013. * The PBR material of BJS following the specular glossiness convention.
  106014. *
  106015. * This fits to the PBR convention in the GLTF definition:
  106016. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  106017. */
  106018. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  106019. /**
  106020. * Specifies the diffuse color of the material.
  106021. */
  106022. diffuseColor: Color3;
  106023. /**
  106024. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  106025. * channel.
  106026. */
  106027. diffuseTexture: BaseTexture;
  106028. /**
  106029. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  106030. */
  106031. specularColor: Color3;
  106032. /**
  106033. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  106034. */
  106035. glossiness: number;
  106036. /**
  106037. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  106038. */
  106039. specularGlossinessTexture: BaseTexture;
  106040. /**
  106041. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  106042. *
  106043. * @param name The material name
  106044. * @param scene The scene the material will be use in.
  106045. */
  106046. constructor(name: string, scene: Scene);
  106047. /**
  106048. * Return the currrent class name of the material.
  106049. */
  106050. getClassName(): string;
  106051. /**
  106052. * Makes a duplicate of the current material.
  106053. * @param name - name to use for the new material.
  106054. */
  106055. clone(name: string): PBRSpecularGlossinessMaterial;
  106056. /**
  106057. * Serialize the material to a parsable JSON object.
  106058. */
  106059. serialize(): any;
  106060. /**
  106061. * Parses a JSON object correponding to the serialize function.
  106062. */
  106063. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  106064. }
  106065. }
  106066. declare module BABYLON {
  106067. /**
  106068. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  106069. * It can help converting any input color in a desired output one. This can then be used to create effects
  106070. * from sepia, black and white to sixties or futuristic rendering...
  106071. *
  106072. * The only supported format is currently 3dl.
  106073. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  106074. */
  106075. export class ColorGradingTexture extends BaseTexture {
  106076. /**
  106077. * The current texture matrix. (will always be identity in color grading texture)
  106078. */
  106079. private _textureMatrix;
  106080. /**
  106081. * The texture URL.
  106082. */
  106083. url: string;
  106084. /**
  106085. * Empty line regex stored for GC.
  106086. */
  106087. private static _noneEmptyLineRegex;
  106088. private _engine;
  106089. /**
  106090. * Instantiates a ColorGradingTexture from the following parameters.
  106091. *
  106092. * @param url The location of the color gradind data (currently only supporting 3dl)
  106093. * @param scene The scene the texture will be used in
  106094. */
  106095. constructor(url: string, scene: Scene);
  106096. /**
  106097. * Returns the texture matrix used in most of the material.
  106098. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  106099. */
  106100. getTextureMatrix(): Matrix;
  106101. /**
  106102. * Occurs when the file being loaded is a .3dl LUT file.
  106103. */
  106104. private load3dlTexture;
  106105. /**
  106106. * Starts the loading process of the texture.
  106107. */
  106108. private loadTexture;
  106109. /**
  106110. * Clones the color gradind texture.
  106111. */
  106112. clone(): ColorGradingTexture;
  106113. /**
  106114. * Called during delayed load for textures.
  106115. */
  106116. delayLoad(): void;
  106117. /**
  106118. * Parses a color grading texture serialized by Babylon.
  106119. * @param parsedTexture The texture information being parsedTexture
  106120. * @param scene The scene to load the texture in
  106121. * @param rootUrl The root url of the data assets to load
  106122. * @return A color gradind texture
  106123. */
  106124. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  106125. /**
  106126. * Serializes the LUT texture to json format.
  106127. */
  106128. serialize(): any;
  106129. }
  106130. }
  106131. declare module BABYLON {
  106132. /**
  106133. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  106134. */
  106135. export class EquiRectangularCubeTexture extends BaseTexture {
  106136. /** The six faces of the cube. */
  106137. private static _FacesMapping;
  106138. private _noMipmap;
  106139. private _onLoad;
  106140. private _onError;
  106141. /** The size of the cubemap. */
  106142. private _size;
  106143. /** The buffer of the image. */
  106144. private _buffer;
  106145. /** The width of the input image. */
  106146. private _width;
  106147. /** The height of the input image. */
  106148. private _height;
  106149. /** The URL to the image. */
  106150. url: string;
  106151. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  106152. coordinatesMode: number;
  106153. /**
  106154. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  106155. * @param url The location of the image
  106156. * @param scene The scene the texture will be used in
  106157. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  106158. * @param noMipmap Forces to not generate the mipmap if true
  106159. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  106160. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  106161. * @param onLoad — defines a callback called when texture is loaded
  106162. * @param onError — defines a callback called if there is an error
  106163. */
  106164. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  106165. /**
  106166. * Load the image data, by putting the image on a canvas and extracting its buffer.
  106167. */
  106168. private loadImage;
  106169. /**
  106170. * Convert the image buffer into a cubemap and create a CubeTexture.
  106171. */
  106172. private loadTexture;
  106173. /**
  106174. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  106175. * @param buffer The ArrayBuffer that should be converted.
  106176. * @returns The buffer as Float32Array.
  106177. */
  106178. private getFloat32ArrayFromArrayBuffer;
  106179. /**
  106180. * Get the current class name of the texture useful for serialization or dynamic coding.
  106181. * @returns "EquiRectangularCubeTexture"
  106182. */
  106183. getClassName(): string;
  106184. /**
  106185. * Create a clone of the current EquiRectangularCubeTexture and return it.
  106186. * @returns A clone of the current EquiRectangularCubeTexture.
  106187. */
  106188. clone(): EquiRectangularCubeTexture;
  106189. }
  106190. }
  106191. declare module BABYLON {
  106192. /**
  106193. * Based on jsTGALoader - Javascript loader for TGA file
  106194. * By Vincent Thibault
  106195. * @see http://blog.robrowser.com/javascript-tga-loader.html
  106196. */
  106197. export class TGATools {
  106198. private static _TYPE_INDEXED;
  106199. private static _TYPE_RGB;
  106200. private static _TYPE_GREY;
  106201. private static _TYPE_RLE_INDEXED;
  106202. private static _TYPE_RLE_RGB;
  106203. private static _TYPE_RLE_GREY;
  106204. private static _ORIGIN_MASK;
  106205. private static _ORIGIN_SHIFT;
  106206. private static _ORIGIN_BL;
  106207. private static _ORIGIN_BR;
  106208. private static _ORIGIN_UL;
  106209. private static _ORIGIN_UR;
  106210. /**
  106211. * Gets the header of a TGA file
  106212. * @param data defines the TGA data
  106213. * @returns the header
  106214. */
  106215. static GetTGAHeader(data: Uint8Array): any;
  106216. /**
  106217. * Uploads TGA content to a Babylon Texture
  106218. * @hidden
  106219. */
  106220. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  106221. /** @hidden */
  106222. 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;
  106223. /** @hidden */
  106224. 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;
  106225. /** @hidden */
  106226. 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;
  106227. /** @hidden */
  106228. 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;
  106229. /** @hidden */
  106230. 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;
  106231. /** @hidden */
  106232. 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;
  106233. }
  106234. }
  106235. declare module BABYLON {
  106236. /**
  106237. * Implementation of the TGA Texture Loader.
  106238. * @hidden
  106239. */
  106240. export class _TGATextureLoader implements IInternalTextureLoader {
  106241. /**
  106242. * Defines wether the loader supports cascade loading the different faces.
  106243. */
  106244. readonly supportCascades: boolean;
  106245. /**
  106246. * This returns if the loader support the current file information.
  106247. * @param extension defines the file extension of the file being loaded
  106248. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106249. * @param fallback defines the fallback internal texture if any
  106250. * @param isBase64 defines whether the texture is encoded as a base64
  106251. * @param isBuffer defines whether the texture data are stored as a buffer
  106252. * @returns true if the loader can load the specified file
  106253. */
  106254. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  106255. /**
  106256. * Transform the url before loading if required.
  106257. * @param rootUrl the url of the texture
  106258. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106259. * @returns the transformed texture
  106260. */
  106261. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  106262. /**
  106263. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  106264. * @param rootUrl the url of the texture
  106265. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106266. * @returns the fallback texture
  106267. */
  106268. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  106269. /**
  106270. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  106271. * @param data contains the texture data
  106272. * @param texture defines the BabylonJS internal texture
  106273. * @param createPolynomials will be true if polynomials have been requested
  106274. * @param onLoad defines the callback to trigger once the texture is ready
  106275. * @param onError defines the callback to trigger in case of error
  106276. */
  106277. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  106278. /**
  106279. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  106280. * @param data contains the texture data
  106281. * @param texture defines the BabylonJS internal texture
  106282. * @param callback defines the method to call once ready to upload
  106283. */
  106284. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  106285. }
  106286. }
  106287. declare module BABYLON {
  106288. /**
  106289. * 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.
  106290. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  106291. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  106292. */
  106293. export class CustomProceduralTexture extends ProceduralTexture {
  106294. private _animate;
  106295. private _time;
  106296. private _config;
  106297. private _texturePath;
  106298. /**
  106299. * Instantiates a new Custom Procedural Texture.
  106300. * 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.
  106301. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  106302. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  106303. * @param name Define the name of the texture
  106304. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  106305. * @param size Define the size of the texture to create
  106306. * @param scene Define the scene the texture belongs to
  106307. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  106308. * @param generateMipMaps Define if the texture should creates mip maps or not
  106309. */
  106310. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  106311. private _loadJson;
  106312. /**
  106313. * Is the texture ready to be used ? (rendered at least once)
  106314. * @returns true if ready, otherwise, false.
  106315. */
  106316. isReady(): boolean;
  106317. /**
  106318. * Render the texture to its associated render target.
  106319. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  106320. */
  106321. render(useCameraPostProcess?: boolean): void;
  106322. /**
  106323. * Update the list of dependant textures samplers in the shader.
  106324. */
  106325. updateTextures(): void;
  106326. /**
  106327. * Update the uniform values of the procedural texture in the shader.
  106328. */
  106329. updateShaderUniforms(): void;
  106330. /**
  106331. * Define if the texture animates or not.
  106332. */
  106333. animate: boolean;
  106334. }
  106335. }
  106336. declare module BABYLON {
  106337. /** @hidden */
  106338. export var noisePixelShader: {
  106339. name: string;
  106340. shader: string;
  106341. };
  106342. }
  106343. declare module BABYLON {
  106344. /**
  106345. * Class used to generate noise procedural textures
  106346. */
  106347. export class NoiseProceduralTexture extends ProceduralTexture {
  106348. private _time;
  106349. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  106350. brightness: number;
  106351. /** Defines the number of octaves to process */
  106352. octaves: number;
  106353. /** Defines the level of persistence (0.8 by default) */
  106354. persistence: number;
  106355. /** Gets or sets animation speed factor (default is 1) */
  106356. animationSpeedFactor: number;
  106357. /**
  106358. * Creates a new NoiseProceduralTexture
  106359. * @param name defines the name fo the texture
  106360. * @param size defines the size of the texture (default is 256)
  106361. * @param scene defines the hosting scene
  106362. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  106363. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  106364. */
  106365. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  106366. private _updateShaderUniforms;
  106367. protected _getDefines(): string;
  106368. /** Generate the current state of the procedural texture */
  106369. render(useCameraPostProcess?: boolean): void;
  106370. /**
  106371. * Serializes this noise procedural texture
  106372. * @returns a serialized noise procedural texture object
  106373. */
  106374. serialize(): any;
  106375. /**
  106376. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  106377. * @param parsedTexture defines parsed texture data
  106378. * @param scene defines the current scene
  106379. * @param rootUrl defines the root URL containing noise procedural texture information
  106380. * @returns a parsed NoiseProceduralTexture
  106381. */
  106382. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  106383. }
  106384. }
  106385. declare module BABYLON {
  106386. /**
  106387. * Raw cube texture where the raw buffers are passed in
  106388. */
  106389. export class RawCubeTexture extends CubeTexture {
  106390. /**
  106391. * Creates a cube texture where the raw buffers are passed in.
  106392. * @param scene defines the scene the texture is attached to
  106393. * @param data defines the array of data to use to create each face
  106394. * @param size defines the size of the textures
  106395. * @param format defines the format of the data
  106396. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  106397. * @param generateMipMaps defines if the engine should generate the mip levels
  106398. * @param invertY defines if data must be stored with Y axis inverted
  106399. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  106400. * @param compression defines the compression used (null by default)
  106401. */
  106402. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  106403. /**
  106404. * Updates the raw cube texture.
  106405. * @param data defines the data to store
  106406. * @param format defines the data format
  106407. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  106408. * @param invertY defines if data must be stored with Y axis inverted
  106409. * @param compression defines the compression used (null by default)
  106410. * @param level defines which level of the texture to update
  106411. */
  106412. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  106413. /**
  106414. * Updates a raw cube texture with RGBD encoded data.
  106415. * @param data defines the array of data [mipmap][face] to use to create each face
  106416. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  106417. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  106418. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  106419. * @returns a promsie that resolves when the operation is complete
  106420. */
  106421. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  106422. /**
  106423. * Clones the raw cube texture.
  106424. * @return a new cube texture
  106425. */
  106426. clone(): CubeTexture;
  106427. /** @hidden */
  106428. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  106429. }
  106430. }
  106431. declare module BABYLON {
  106432. /**
  106433. * Class used to store 3D textures containing user data
  106434. */
  106435. export class RawTexture3D extends Texture {
  106436. /** Gets or sets the texture format to use */
  106437. format: number;
  106438. private _engine;
  106439. /**
  106440. * Create a new RawTexture3D
  106441. * @param data defines the data of the texture
  106442. * @param width defines the width of the texture
  106443. * @param height defines the height of the texture
  106444. * @param depth defines the depth of the texture
  106445. * @param format defines the texture format to use
  106446. * @param scene defines the hosting scene
  106447. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  106448. * @param invertY defines if texture must be stored with Y axis inverted
  106449. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  106450. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  106451. */
  106452. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  106453. /** Gets or sets the texture format to use */
  106454. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  106455. /**
  106456. * Update the texture with new data
  106457. * @param data defines the data to store in the texture
  106458. */
  106459. update(data: ArrayBufferView): void;
  106460. }
  106461. }
  106462. declare module BABYLON {
  106463. /**
  106464. * Creates a refraction texture used by refraction channel of the standard material.
  106465. * It is like a mirror but to see through a material.
  106466. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  106467. */
  106468. export class RefractionTexture extends RenderTargetTexture {
  106469. /**
  106470. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  106471. * 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.
  106472. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  106473. */
  106474. refractionPlane: Plane;
  106475. /**
  106476. * Define how deep under the surface we should see.
  106477. */
  106478. depth: number;
  106479. /**
  106480. * Creates a refraction texture used by refraction channel of the standard material.
  106481. * It is like a mirror but to see through a material.
  106482. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  106483. * @param name Define the texture name
  106484. * @param size Define the size of the underlying texture
  106485. * @param scene Define the scene the refraction belongs to
  106486. * @param generateMipMaps Define if we need to generate mips level for the refraction
  106487. */
  106488. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  106489. /**
  106490. * Clone the refraction texture.
  106491. * @returns the cloned texture
  106492. */
  106493. clone(): RefractionTexture;
  106494. /**
  106495. * Serialize the texture to a JSON representation you could use in Parse later on
  106496. * @returns the serialized JSON representation
  106497. */
  106498. serialize(): any;
  106499. }
  106500. }
  106501. declare module BABYLON {
  106502. /**
  106503. * Configuration for Draco compression
  106504. */
  106505. export interface IDracoCompressionConfiguration {
  106506. /**
  106507. * Configuration for the decoder.
  106508. */
  106509. decoder?: {
  106510. /**
  106511. * The url to the WebAssembly module.
  106512. */
  106513. wasmUrl?: string;
  106514. /**
  106515. * The url to the WebAssembly binary.
  106516. */
  106517. wasmBinaryUrl?: string;
  106518. /**
  106519. * The url to the fallback JavaScript module.
  106520. */
  106521. fallbackUrl?: string;
  106522. };
  106523. }
  106524. /**
  106525. * Draco compression (https://google.github.io/draco/)
  106526. *
  106527. * This class wraps the Draco module.
  106528. *
  106529. * **Encoder**
  106530. *
  106531. * The encoder is not currently implemented.
  106532. *
  106533. * **Decoder**
  106534. *
  106535. * 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.
  106536. *
  106537. * To update the configuration, use the following code:
  106538. * ```javascript
  106539. * DracoCompression.Configuration = {
  106540. * decoder: {
  106541. * wasmUrl: "<url to the WebAssembly library>",
  106542. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  106543. * fallbackUrl: "<url to the fallback JavaScript library>",
  106544. * }
  106545. * };
  106546. * ```
  106547. *
  106548. * 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.
  106549. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  106550. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  106551. *
  106552. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  106553. * ```javascript
  106554. * var dracoCompression = new DracoCompression();
  106555. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  106556. * [VertexBuffer.PositionKind]: 0
  106557. * });
  106558. * ```
  106559. *
  106560. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  106561. */
  106562. export class DracoCompression implements IDisposable {
  106563. private static _DecoderModulePromise;
  106564. /**
  106565. * The configuration. Defaults to the following urls:
  106566. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  106567. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  106568. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  106569. */
  106570. static Configuration: IDracoCompressionConfiguration;
  106571. /**
  106572. * Returns true if the decoder is available.
  106573. */
  106574. static readonly DecoderAvailable: boolean;
  106575. /**
  106576. * Constructor
  106577. */
  106578. constructor();
  106579. /**
  106580. * Stop all async operations and release resources.
  106581. */
  106582. dispose(): void;
  106583. /**
  106584. * Decode Draco compressed mesh data to vertex data.
  106585. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  106586. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  106587. * @returns A promise that resolves with the decoded vertex data
  106588. */
  106589. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  106590. [kind: string]: number;
  106591. }): Promise<VertexData>;
  106592. private static _GetDecoderModule;
  106593. private static _LoadScriptAsync;
  106594. private static _LoadFileAsync;
  106595. }
  106596. }
  106597. declare module BABYLON {
  106598. /**
  106599. * Class for building Constructive Solid Geometry
  106600. */
  106601. export class CSG {
  106602. private polygons;
  106603. /**
  106604. * The world matrix
  106605. */
  106606. matrix: Matrix;
  106607. /**
  106608. * Stores the position
  106609. */
  106610. position: Vector3;
  106611. /**
  106612. * Stores the rotation
  106613. */
  106614. rotation: Vector3;
  106615. /**
  106616. * Stores the rotation quaternion
  106617. */
  106618. rotationQuaternion: Nullable<Quaternion>;
  106619. /**
  106620. * Stores the scaling vector
  106621. */
  106622. scaling: Vector3;
  106623. /**
  106624. * Convert the Mesh to CSG
  106625. * @param mesh The Mesh to convert to CSG
  106626. * @returns A new CSG from the Mesh
  106627. */
  106628. static FromMesh(mesh: Mesh): CSG;
  106629. /**
  106630. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  106631. * @param polygons Polygons used to construct a CSG solid
  106632. */
  106633. private static FromPolygons;
  106634. /**
  106635. * Clones, or makes a deep copy, of the CSG
  106636. * @returns A new CSG
  106637. */
  106638. clone(): CSG;
  106639. /**
  106640. * Unions this CSG with another CSG
  106641. * @param csg The CSG to union against this CSG
  106642. * @returns The unioned CSG
  106643. */
  106644. union(csg: CSG): CSG;
  106645. /**
  106646. * Unions this CSG with another CSG in place
  106647. * @param csg The CSG to union against this CSG
  106648. */
  106649. unionInPlace(csg: CSG): void;
  106650. /**
  106651. * Subtracts this CSG with another CSG
  106652. * @param csg The CSG to subtract against this CSG
  106653. * @returns A new CSG
  106654. */
  106655. subtract(csg: CSG): CSG;
  106656. /**
  106657. * Subtracts this CSG with another CSG in place
  106658. * @param csg The CSG to subtact against this CSG
  106659. */
  106660. subtractInPlace(csg: CSG): void;
  106661. /**
  106662. * Intersect this CSG with another CSG
  106663. * @param csg The CSG to intersect against this CSG
  106664. * @returns A new CSG
  106665. */
  106666. intersect(csg: CSG): CSG;
  106667. /**
  106668. * Intersects this CSG with another CSG in place
  106669. * @param csg The CSG to intersect against this CSG
  106670. */
  106671. intersectInPlace(csg: CSG): void;
  106672. /**
  106673. * Return a new CSG solid with solid and empty space switched. This solid is
  106674. * not modified.
  106675. * @returns A new CSG solid with solid and empty space switched
  106676. */
  106677. inverse(): CSG;
  106678. /**
  106679. * Inverses the CSG in place
  106680. */
  106681. inverseInPlace(): void;
  106682. /**
  106683. * This is used to keep meshes transformations so they can be restored
  106684. * when we build back a Babylon Mesh
  106685. * NB : All CSG operations are performed in world coordinates
  106686. * @param csg The CSG to copy the transform attributes from
  106687. * @returns This CSG
  106688. */
  106689. copyTransformAttributes(csg: CSG): CSG;
  106690. /**
  106691. * Build Raw mesh from CSG
  106692. * Coordinates here are in world space
  106693. * @param name The name of the mesh geometry
  106694. * @param scene The Scene
  106695. * @param keepSubMeshes Specifies if the submeshes should be kept
  106696. * @returns A new Mesh
  106697. */
  106698. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  106699. /**
  106700. * Build Mesh from CSG taking material and transforms into account
  106701. * @param name The name of the Mesh
  106702. * @param material The material of the Mesh
  106703. * @param scene The Scene
  106704. * @param keepSubMeshes Specifies if submeshes should be kept
  106705. * @returns The new Mesh
  106706. */
  106707. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  106708. }
  106709. }
  106710. declare module BABYLON {
  106711. /**
  106712. * Class used to create a trail following a mesh
  106713. */
  106714. export class TrailMesh extends Mesh {
  106715. private _generator;
  106716. private _autoStart;
  106717. private _running;
  106718. private _diameter;
  106719. private _length;
  106720. private _sectionPolygonPointsCount;
  106721. private _sectionVectors;
  106722. private _sectionNormalVectors;
  106723. private _beforeRenderObserver;
  106724. /**
  106725. * @constructor
  106726. * @param name The value used by scene.getMeshByName() to do a lookup.
  106727. * @param generator The mesh to generate a trail.
  106728. * @param scene The scene to add this mesh to.
  106729. * @param diameter Diameter of trailing mesh. Default is 1.
  106730. * @param length Length of trailing mesh. Default is 60.
  106731. * @param autoStart Automatically start trailing mesh. Default true.
  106732. */
  106733. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  106734. /**
  106735. * "TrailMesh"
  106736. * @returns "TrailMesh"
  106737. */
  106738. getClassName(): string;
  106739. private _createMesh;
  106740. /**
  106741. * Start trailing mesh.
  106742. */
  106743. start(): void;
  106744. /**
  106745. * Stop trailing mesh.
  106746. */
  106747. stop(): void;
  106748. /**
  106749. * Update trailing mesh geometry.
  106750. */
  106751. update(): void;
  106752. /**
  106753. * Returns a new TrailMesh object.
  106754. * @param name is a string, the name given to the new mesh
  106755. * @param newGenerator use new generator object for cloned trail mesh
  106756. * @returns a new mesh
  106757. */
  106758. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  106759. /**
  106760. * Serializes this trail mesh
  106761. * @param serializationObject object to write serialization to
  106762. */
  106763. serialize(serializationObject: any): void;
  106764. /**
  106765. * Parses a serialized trail mesh
  106766. * @param parsedMesh the serialized mesh
  106767. * @param scene the scene to create the trail mesh in
  106768. * @returns the created trail mesh
  106769. */
  106770. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  106771. }
  106772. }
  106773. declare module BABYLON {
  106774. /**
  106775. * Class containing static functions to help procedurally build meshes
  106776. */
  106777. export class RibbonBuilder {
  106778. /**
  106779. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  106780. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  106781. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  106782. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  106783. * * 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
  106784. * * 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
  106785. * * 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
  106786. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106787. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106788. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106789. * * 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
  106790. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  106791. * * 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
  106792. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  106793. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106794. * @param name defines the name of the mesh
  106795. * @param options defines the options used to create the mesh
  106796. * @param scene defines the hosting scene
  106797. * @returns the ribbon mesh
  106798. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  106799. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106800. */
  106801. static CreateRibbon(name: string, options: {
  106802. pathArray: Vector3[][];
  106803. closeArray?: boolean;
  106804. closePath?: boolean;
  106805. offset?: number;
  106806. updatable?: boolean;
  106807. sideOrientation?: number;
  106808. frontUVs?: Vector4;
  106809. backUVs?: Vector4;
  106810. instance?: Mesh;
  106811. invertUV?: boolean;
  106812. uvs?: Vector2[];
  106813. colors?: Color4[];
  106814. }, scene?: Nullable<Scene>): Mesh;
  106815. }
  106816. }
  106817. declare module BABYLON {
  106818. /**
  106819. * Class containing static functions to help procedurally build meshes
  106820. */
  106821. export class TorusKnotBuilder {
  106822. /**
  106823. * Creates a torus knot mesh
  106824. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  106825. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  106826. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  106827. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  106828. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106829. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106830. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106831. * @param name defines the name of the mesh
  106832. * @param options defines the options used to create the mesh
  106833. * @param scene defines the hosting scene
  106834. * @returns the torus knot mesh
  106835. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  106836. */
  106837. static CreateTorusKnot(name: string, options: {
  106838. radius?: number;
  106839. tube?: number;
  106840. radialSegments?: number;
  106841. tubularSegments?: number;
  106842. p?: number;
  106843. q?: number;
  106844. updatable?: boolean;
  106845. sideOrientation?: number;
  106846. frontUVs?: Vector4;
  106847. backUVs?: Vector4;
  106848. }, scene: any): Mesh;
  106849. }
  106850. }
  106851. declare module BABYLON {
  106852. /**
  106853. * Polygon
  106854. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  106855. */
  106856. export class Polygon {
  106857. /**
  106858. * Creates a rectangle
  106859. * @param xmin bottom X coord
  106860. * @param ymin bottom Y coord
  106861. * @param xmax top X coord
  106862. * @param ymax top Y coord
  106863. * @returns points that make the resulting rectation
  106864. */
  106865. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  106866. /**
  106867. * Creates a circle
  106868. * @param radius radius of circle
  106869. * @param cx scale in x
  106870. * @param cy scale in y
  106871. * @param numberOfSides number of sides that make up the circle
  106872. * @returns points that make the resulting circle
  106873. */
  106874. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  106875. /**
  106876. * Creates a polygon from input string
  106877. * @param input Input polygon data
  106878. * @returns the parsed points
  106879. */
  106880. static Parse(input: string): Vector2[];
  106881. /**
  106882. * Starts building a polygon from x and y coordinates
  106883. * @param x x coordinate
  106884. * @param y y coordinate
  106885. * @returns the started path2
  106886. */
  106887. static StartingAt(x: number, y: number): Path2;
  106888. }
  106889. /**
  106890. * Builds a polygon
  106891. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  106892. */
  106893. export class PolygonMeshBuilder {
  106894. private _points;
  106895. private _outlinepoints;
  106896. private _holes;
  106897. private _name;
  106898. private _scene;
  106899. private _epoints;
  106900. private _eholes;
  106901. private _addToepoint;
  106902. /**
  106903. * Babylon reference to the earcut plugin.
  106904. */
  106905. bjsEarcut: any;
  106906. /**
  106907. * Creates a PolygonMeshBuilder
  106908. * @param name name of the builder
  106909. * @param contours Path of the polygon
  106910. * @param scene scene to add to when creating the mesh
  106911. * @param earcutInjection can be used to inject your own earcut reference
  106912. */
  106913. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  106914. /**
  106915. * Adds a whole within the polygon
  106916. * @param hole Array of points defining the hole
  106917. * @returns this
  106918. */
  106919. addHole(hole: Vector2[]): PolygonMeshBuilder;
  106920. /**
  106921. * Creates the polygon
  106922. * @param updatable If the mesh should be updatable
  106923. * @param depth The depth of the mesh created
  106924. * @returns the created mesh
  106925. */
  106926. build(updatable?: boolean, depth?: number): Mesh;
  106927. /**
  106928. * Creates the polygon
  106929. * @param depth The depth of the mesh created
  106930. * @returns the created VertexData
  106931. */
  106932. buildVertexData(depth?: number): VertexData;
  106933. /**
  106934. * Adds a side to the polygon
  106935. * @param positions points that make the polygon
  106936. * @param normals normals of the polygon
  106937. * @param uvs uvs of the polygon
  106938. * @param indices indices of the polygon
  106939. * @param bounds bounds of the polygon
  106940. * @param points points of the polygon
  106941. * @param depth depth of the polygon
  106942. * @param flip flip of the polygon
  106943. */
  106944. private addSide;
  106945. }
  106946. }
  106947. declare module BABYLON {
  106948. /**
  106949. * Class containing static functions to help procedurally build meshes
  106950. */
  106951. export class PolygonBuilder {
  106952. /**
  106953. * Creates a polygon mesh
  106954. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  106955. * * 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
  106956. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106957. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106958. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  106959. * * Remember you can only change the shape positions, not their number when updating a polygon
  106960. * @param name defines the name of the mesh
  106961. * @param options defines the options used to create the mesh
  106962. * @param scene defines the hosting scene
  106963. * @param earcutInjection can be used to inject your own earcut reference
  106964. * @returns the polygon mesh
  106965. */
  106966. static CreatePolygon(name: string, options: {
  106967. shape: Vector3[];
  106968. holes?: Vector3[][];
  106969. depth?: number;
  106970. faceUV?: Vector4[];
  106971. faceColors?: Color4[];
  106972. updatable?: boolean;
  106973. sideOrientation?: number;
  106974. frontUVs?: Vector4;
  106975. backUVs?: Vector4;
  106976. }, scene: Scene, earcutInjection?: any): Mesh;
  106977. /**
  106978. * Creates an extruded polygon mesh, with depth in the Y direction.
  106979. * * 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)
  106980. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  106981. * @param name defines the name of the mesh
  106982. * @param options defines the options used to create the mesh
  106983. * @param scene defines the hosting scene
  106984. * @param earcutInjection can be used to inject your own earcut reference
  106985. * @returns the polygon mesh
  106986. */
  106987. static ExtrudePolygon(name: string, options: {
  106988. shape: Vector3[];
  106989. holes?: Vector3[][];
  106990. depth?: number;
  106991. faceUV?: Vector4[];
  106992. faceColors?: Color4[];
  106993. updatable?: boolean;
  106994. sideOrientation?: number;
  106995. frontUVs?: Vector4;
  106996. backUVs?: Vector4;
  106997. }, scene: Scene, earcutInjection?: any): Mesh;
  106998. }
  106999. }
  107000. declare module BABYLON {
  107001. /**
  107002. * Class containing static functions to help procedurally build meshes
  107003. */
  107004. export class ShapeBuilder {
  107005. /**
  107006. * 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.
  107007. * * 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.
  107008. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  107009. * * 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.
  107010. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  107011. * * 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
  107012. * * 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
  107013. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  107014. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107015. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107016. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  107017. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107018. * @param name defines the name of the mesh
  107019. * @param options defines the options used to create the mesh
  107020. * @param scene defines the hosting scene
  107021. * @returns the extruded shape mesh
  107022. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107023. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107024. */
  107025. static ExtrudeShape(name: string, options: {
  107026. shape: Vector3[];
  107027. path: Vector3[];
  107028. scale?: number;
  107029. rotation?: number;
  107030. cap?: number;
  107031. updatable?: boolean;
  107032. sideOrientation?: number;
  107033. frontUVs?: Vector4;
  107034. backUVs?: Vector4;
  107035. instance?: Mesh;
  107036. invertUV?: boolean;
  107037. }, scene?: Nullable<Scene>): Mesh;
  107038. /**
  107039. * Creates an custom extruded shape mesh.
  107040. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  107041. * * 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.
  107042. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  107043. * * 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
  107044. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  107045. * * 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
  107046. * * It must returns a float value that will be the scale value applied to the shape on each path point
  107047. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  107048. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  107049. * * 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
  107050. * * 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
  107051. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  107052. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107053. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107054. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107056. * @param name defines the name of the mesh
  107057. * @param options defines the options used to create the mesh
  107058. * @param scene defines the hosting scene
  107059. * @returns the custom extruded shape mesh
  107060. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  107061. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107062. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107063. */
  107064. static ExtrudeShapeCustom(name: string, options: {
  107065. shape: Vector3[];
  107066. path: Vector3[];
  107067. scaleFunction?: any;
  107068. rotationFunction?: any;
  107069. ribbonCloseArray?: boolean;
  107070. ribbonClosePath?: boolean;
  107071. cap?: number;
  107072. updatable?: boolean;
  107073. sideOrientation?: number;
  107074. frontUVs?: Vector4;
  107075. backUVs?: Vector4;
  107076. instance?: Mesh;
  107077. invertUV?: boolean;
  107078. }, scene: Scene): Mesh;
  107079. private static _ExtrudeShapeGeneric;
  107080. }
  107081. }
  107082. declare module BABYLON {
  107083. /**
  107084. * Class containing static functions to help procedurally build meshes
  107085. */
  107086. export class LatheBuilder {
  107087. /**
  107088. * Creates lathe mesh.
  107089. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  107090. * * 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
  107091. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  107092. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  107093. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  107094. * * 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
  107095. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  107096. * * 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
  107097. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107098. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107099. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107100. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107101. * @param name defines the name of the mesh
  107102. * @param options defines the options used to create the mesh
  107103. * @param scene defines the hosting scene
  107104. * @returns the lathe mesh
  107105. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  107106. */
  107107. static CreateLathe(name: string, options: {
  107108. shape: Vector3[];
  107109. radius?: number;
  107110. tessellation?: number;
  107111. clip?: number;
  107112. arc?: number;
  107113. closed?: boolean;
  107114. updatable?: boolean;
  107115. sideOrientation?: number;
  107116. frontUVs?: Vector4;
  107117. backUVs?: Vector4;
  107118. cap?: number;
  107119. invertUV?: boolean;
  107120. }, scene: Scene): Mesh;
  107121. }
  107122. }
  107123. declare module BABYLON {
  107124. /**
  107125. * Class containing static functions to help procedurally build meshes
  107126. */
  107127. export class TubeBuilder {
  107128. /**
  107129. * Creates a tube mesh.
  107130. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  107131. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  107132. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  107133. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  107134. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  107135. * * 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)
  107136. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  107137. * * 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
  107138. * * 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
  107139. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107140. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107141. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107142. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107143. * @param name defines the name of the mesh
  107144. * @param options defines the options used to create the mesh
  107145. * @param scene defines the hosting scene
  107146. * @returns the tube mesh
  107147. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107148. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  107149. */
  107150. static CreateTube(name: string, options: {
  107151. path: Vector3[];
  107152. radius?: number;
  107153. tessellation?: number;
  107154. radiusFunction?: {
  107155. (i: number, distance: number): number;
  107156. };
  107157. cap?: number;
  107158. arc?: number;
  107159. updatable?: boolean;
  107160. sideOrientation?: number;
  107161. frontUVs?: Vector4;
  107162. backUVs?: Vector4;
  107163. instance?: Mesh;
  107164. invertUV?: boolean;
  107165. }, scene: Scene): Mesh;
  107166. }
  107167. }
  107168. declare module BABYLON {
  107169. /**
  107170. * Class containing static functions to help procedurally build meshes
  107171. */
  107172. export class IcoSphereBuilder {
  107173. /**
  107174. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  107175. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  107176. * * 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`)
  107177. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  107178. * * 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
  107179. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107180. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107181. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107182. * @param name defines the name of the mesh
  107183. * @param options defines the options used to create the mesh
  107184. * @param scene defines the hosting scene
  107185. * @returns the icosahedron mesh
  107186. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  107187. */
  107188. static CreateIcoSphere(name: string, options: {
  107189. radius?: number;
  107190. radiusX?: number;
  107191. radiusY?: number;
  107192. radiusZ?: number;
  107193. flat?: boolean;
  107194. subdivisions?: number;
  107195. sideOrientation?: number;
  107196. frontUVs?: Vector4;
  107197. backUVs?: Vector4;
  107198. updatable?: boolean;
  107199. }, scene: Scene): Mesh;
  107200. }
  107201. }
  107202. declare module BABYLON {
  107203. /**
  107204. * Class containing static functions to help procedurally build meshes
  107205. */
  107206. export class DecalBuilder {
  107207. /**
  107208. * Creates a decal mesh.
  107209. * 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
  107210. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  107211. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  107212. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  107213. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  107214. * @param name defines the name of the mesh
  107215. * @param sourceMesh defines the mesh where the decal must be applied
  107216. * @param options defines the options used to create the mesh
  107217. * @param scene defines the hosting scene
  107218. * @returns the decal mesh
  107219. * @see https://doc.babylonjs.com/how_to/decals
  107220. */
  107221. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  107222. position?: Vector3;
  107223. normal?: Vector3;
  107224. size?: Vector3;
  107225. angle?: number;
  107226. }): Mesh;
  107227. }
  107228. }
  107229. declare module BABYLON {
  107230. /**
  107231. * Class containing static functions to help procedurally build meshes
  107232. */
  107233. export class MeshBuilder {
  107234. /**
  107235. * Creates a box mesh
  107236. * * The parameter `size` sets the size (float) of each box side (default 1)
  107237. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  107238. * * 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)
  107239. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  107240. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107241. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107242. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107243. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  107244. * @param name defines the name of the mesh
  107245. * @param options defines the options used to create the mesh
  107246. * @param scene defines the hosting scene
  107247. * @returns the box mesh
  107248. */
  107249. static CreateBox(name: string, options: {
  107250. size?: number;
  107251. width?: number;
  107252. height?: number;
  107253. depth?: number;
  107254. faceUV?: Vector4[];
  107255. faceColors?: Color4[];
  107256. sideOrientation?: number;
  107257. frontUVs?: Vector4;
  107258. backUVs?: Vector4;
  107259. updatable?: boolean;
  107260. }, scene?: Nullable<Scene>): Mesh;
  107261. /**
  107262. * Creates a sphere mesh
  107263. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  107264. * * 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`)
  107265. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  107266. * * 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
  107267. * * 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)
  107268. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107269. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107270. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107271. * @param name defines the name of the mesh
  107272. * @param options defines the options used to create the mesh
  107273. * @param scene defines the hosting scene
  107274. * @returns the sphere mesh
  107275. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  107276. */
  107277. static CreateSphere(name: string, options: {
  107278. segments?: number;
  107279. diameter?: number;
  107280. diameterX?: number;
  107281. diameterY?: number;
  107282. diameterZ?: number;
  107283. arc?: number;
  107284. slice?: number;
  107285. sideOrientation?: number;
  107286. frontUVs?: Vector4;
  107287. backUVs?: Vector4;
  107288. updatable?: boolean;
  107289. }, scene: any): Mesh;
  107290. /**
  107291. * Creates a plane polygonal mesh. By default, this is a disc
  107292. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  107293. * * 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
  107294. * * 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
  107295. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107296. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107297. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107298. * @param name defines the name of the mesh
  107299. * @param options defines the options used to create the mesh
  107300. * @param scene defines the hosting scene
  107301. * @returns the plane polygonal mesh
  107302. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  107303. */
  107304. static CreateDisc(name: string, options: {
  107305. radius?: number;
  107306. tessellation?: number;
  107307. arc?: number;
  107308. updatable?: boolean;
  107309. sideOrientation?: number;
  107310. frontUVs?: Vector4;
  107311. backUVs?: Vector4;
  107312. }, scene?: Nullable<Scene>): Mesh;
  107313. /**
  107314. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  107315. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  107316. * * 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`)
  107317. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  107318. * * 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
  107319. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107320. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107321. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107322. * @param name defines the name of the mesh
  107323. * @param options defines the options used to create the mesh
  107324. * @param scene defines the hosting scene
  107325. * @returns the icosahedron mesh
  107326. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  107327. */
  107328. static CreateIcoSphere(name: string, options: {
  107329. radius?: number;
  107330. radiusX?: number;
  107331. radiusY?: number;
  107332. radiusZ?: number;
  107333. flat?: boolean;
  107334. subdivisions?: number;
  107335. sideOrientation?: number;
  107336. frontUVs?: Vector4;
  107337. backUVs?: Vector4;
  107338. updatable?: boolean;
  107339. }, scene: Scene): Mesh;
  107340. /**
  107341. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  107342. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  107343. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  107344. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  107345. * * 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
  107346. * * 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
  107347. * * 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
  107348. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107349. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107350. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107351. * * 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
  107352. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  107353. * * 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
  107354. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  107355. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107356. * @param name defines the name of the mesh
  107357. * @param options defines the options used to create the mesh
  107358. * @param scene defines the hosting scene
  107359. * @returns the ribbon mesh
  107360. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  107361. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107362. */
  107363. static CreateRibbon(name: string, options: {
  107364. pathArray: Vector3[][];
  107365. closeArray?: boolean;
  107366. closePath?: boolean;
  107367. offset?: number;
  107368. updatable?: boolean;
  107369. sideOrientation?: number;
  107370. frontUVs?: Vector4;
  107371. backUVs?: Vector4;
  107372. instance?: Mesh;
  107373. invertUV?: boolean;
  107374. uvs?: Vector2[];
  107375. colors?: Color4[];
  107376. }, scene?: Nullable<Scene>): Mesh;
  107377. /**
  107378. * Creates a cylinder or a cone mesh
  107379. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  107380. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  107381. * * 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.
  107382. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  107383. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  107384. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  107385. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  107386. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  107387. * * 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).
  107388. * * 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
  107389. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  107390. * * 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
  107391. * * 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.
  107392. * * If `enclose` is false, a ring surface is one element.
  107393. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  107394. * * 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
  107395. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107396. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107397. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107398. * @param name defines the name of the mesh
  107399. * @param options defines the options used to create the mesh
  107400. * @param scene defines the hosting scene
  107401. * @returns the cylinder mesh
  107402. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  107403. */
  107404. static CreateCylinder(name: string, options: {
  107405. height?: number;
  107406. diameterTop?: number;
  107407. diameterBottom?: number;
  107408. diameter?: number;
  107409. tessellation?: number;
  107410. subdivisions?: number;
  107411. arc?: number;
  107412. faceColors?: Color4[];
  107413. faceUV?: Vector4[];
  107414. updatable?: boolean;
  107415. hasRings?: boolean;
  107416. enclose?: boolean;
  107417. sideOrientation?: number;
  107418. frontUVs?: Vector4;
  107419. backUVs?: Vector4;
  107420. }, scene: any): Mesh;
  107421. /**
  107422. * Creates a torus mesh
  107423. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  107424. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  107425. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  107426. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107427. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107428. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107429. * @param name defines the name of the mesh
  107430. * @param options defines the options used to create the mesh
  107431. * @param scene defines the hosting scene
  107432. * @returns the torus mesh
  107433. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  107434. */
  107435. static CreateTorus(name: string, options: {
  107436. diameter?: number;
  107437. thickness?: number;
  107438. tessellation?: number;
  107439. updatable?: boolean;
  107440. sideOrientation?: number;
  107441. frontUVs?: Vector4;
  107442. backUVs?: Vector4;
  107443. }, scene: any): Mesh;
  107444. /**
  107445. * Creates a torus knot mesh
  107446. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  107447. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  107448. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  107449. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  107450. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107451. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107453. * @param name defines the name of the mesh
  107454. * @param options defines the options used to create the mesh
  107455. * @param scene defines the hosting scene
  107456. * @returns the torus knot mesh
  107457. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  107458. */
  107459. static CreateTorusKnot(name: string, options: {
  107460. radius?: number;
  107461. tube?: number;
  107462. radialSegments?: number;
  107463. tubularSegments?: number;
  107464. p?: number;
  107465. q?: number;
  107466. updatable?: boolean;
  107467. sideOrientation?: number;
  107468. frontUVs?: Vector4;
  107469. backUVs?: Vector4;
  107470. }, scene: any): Mesh;
  107471. /**
  107472. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  107473. * * 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
  107474. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  107475. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  107476. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  107477. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  107478. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  107479. * * 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
  107480. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  107481. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107482. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  107483. * @param name defines the name of the new line system
  107484. * @param options defines the options used to create the line system
  107485. * @param scene defines the hosting scene
  107486. * @returns a new line system mesh
  107487. */
  107488. static CreateLineSystem(name: string, options: {
  107489. lines: Vector3[][];
  107490. updatable?: boolean;
  107491. instance?: Nullable<LinesMesh>;
  107492. colors?: Nullable<Color4[][]>;
  107493. useVertexAlpha?: boolean;
  107494. }, scene: Nullable<Scene>): LinesMesh;
  107495. /**
  107496. * Creates a line mesh
  107497. * 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
  107498. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  107499. * * The parameter `points` is an array successive Vector3
  107500. * * 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
  107501. * * The optional parameter `colors` is an array of successive Color4, one per line point
  107502. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  107503. * * When updating an instance, remember that only point positions can change, not the number of points
  107504. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107505. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  107506. * @param name defines the name of the new line system
  107507. * @param options defines the options used to create the line system
  107508. * @param scene defines the hosting scene
  107509. * @returns a new line mesh
  107510. */
  107511. static CreateLines(name: string, options: {
  107512. points: Vector3[];
  107513. updatable?: boolean;
  107514. instance?: Nullable<LinesMesh>;
  107515. colors?: Color4[];
  107516. useVertexAlpha?: boolean;
  107517. }, scene?: Nullable<Scene>): LinesMesh;
  107518. /**
  107519. * Creates a dashed line mesh
  107520. * * 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
  107521. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  107522. * * The parameter `points` is an array successive Vector3
  107523. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  107524. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  107525. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  107526. * * 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
  107527. * * When updating an instance, remember that only point positions can change, not the number of points
  107528. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107529. * @param name defines the name of the mesh
  107530. * @param options defines the options used to create the mesh
  107531. * @param scene defines the hosting scene
  107532. * @returns the dashed line mesh
  107533. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  107534. */
  107535. static CreateDashedLines(name: string, options: {
  107536. points: Vector3[];
  107537. dashSize?: number;
  107538. gapSize?: number;
  107539. dashNb?: number;
  107540. updatable?: boolean;
  107541. instance?: LinesMesh;
  107542. }, scene?: Nullable<Scene>): LinesMesh;
  107543. /**
  107544. * 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.
  107545. * * 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.
  107546. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  107547. * * 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.
  107548. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  107549. * * 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
  107550. * * 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
  107551. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  107552. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107553. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107554. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  107555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107556. * @param name defines the name of the mesh
  107557. * @param options defines the options used to create the mesh
  107558. * @param scene defines the hosting scene
  107559. * @returns the extruded shape mesh
  107560. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107561. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107562. */
  107563. static ExtrudeShape(name: string, options: {
  107564. shape: Vector3[];
  107565. path: Vector3[];
  107566. scale?: number;
  107567. rotation?: number;
  107568. cap?: number;
  107569. updatable?: boolean;
  107570. sideOrientation?: number;
  107571. frontUVs?: Vector4;
  107572. backUVs?: Vector4;
  107573. instance?: Mesh;
  107574. invertUV?: boolean;
  107575. }, scene?: Nullable<Scene>): Mesh;
  107576. /**
  107577. * Creates an custom extruded shape mesh.
  107578. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  107579. * * 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.
  107580. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  107581. * * 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
  107582. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  107583. * * 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
  107584. * * It must returns a float value that will be the scale value applied to the shape on each path point
  107585. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  107586. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  107587. * * 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
  107588. * * 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
  107589. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  107590. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107591. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107592. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107593. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107594. * @param name defines the name of the mesh
  107595. * @param options defines the options used to create the mesh
  107596. * @param scene defines the hosting scene
  107597. * @returns the custom extruded shape mesh
  107598. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  107599. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107600. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107601. */
  107602. static ExtrudeShapeCustom(name: string, options: {
  107603. shape: Vector3[];
  107604. path: Vector3[];
  107605. scaleFunction?: any;
  107606. rotationFunction?: any;
  107607. ribbonCloseArray?: boolean;
  107608. ribbonClosePath?: boolean;
  107609. cap?: number;
  107610. updatable?: boolean;
  107611. sideOrientation?: number;
  107612. frontUVs?: Vector4;
  107613. backUVs?: Vector4;
  107614. instance?: Mesh;
  107615. invertUV?: boolean;
  107616. }, scene: Scene): Mesh;
  107617. /**
  107618. * Creates lathe mesh.
  107619. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  107620. * * 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
  107621. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  107622. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  107623. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  107624. * * 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
  107625. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  107626. * * 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
  107627. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107628. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107629. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107630. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107631. * @param name defines the name of the mesh
  107632. * @param options defines the options used to create the mesh
  107633. * @param scene defines the hosting scene
  107634. * @returns the lathe mesh
  107635. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  107636. */
  107637. static CreateLathe(name: string, options: {
  107638. shape: Vector3[];
  107639. radius?: number;
  107640. tessellation?: number;
  107641. clip?: number;
  107642. arc?: number;
  107643. closed?: boolean;
  107644. updatable?: boolean;
  107645. sideOrientation?: number;
  107646. frontUVs?: Vector4;
  107647. backUVs?: Vector4;
  107648. cap?: number;
  107649. invertUV?: boolean;
  107650. }, scene: Scene): Mesh;
  107651. /**
  107652. * Creates a plane mesh
  107653. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  107654. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  107655. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  107656. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107657. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107659. * @param name defines the name of the mesh
  107660. * @param options defines the options used to create the mesh
  107661. * @param scene defines the hosting scene
  107662. * @returns the plane mesh
  107663. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  107664. */
  107665. static CreatePlane(name: string, options: {
  107666. size?: number;
  107667. width?: number;
  107668. height?: number;
  107669. sideOrientation?: number;
  107670. frontUVs?: Vector4;
  107671. backUVs?: Vector4;
  107672. updatable?: boolean;
  107673. sourcePlane?: Plane;
  107674. }, scene: Scene): Mesh;
  107675. /**
  107676. * Creates a ground mesh
  107677. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  107678. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  107679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107680. * @param name defines the name of the mesh
  107681. * @param options defines the options used to create the mesh
  107682. * @param scene defines the hosting scene
  107683. * @returns the ground mesh
  107684. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  107685. */
  107686. static CreateGround(name: string, options: {
  107687. width?: number;
  107688. height?: number;
  107689. subdivisions?: number;
  107690. subdivisionsX?: number;
  107691. subdivisionsY?: number;
  107692. updatable?: boolean;
  107693. }, scene: any): Mesh;
  107694. /**
  107695. * Creates a tiled ground mesh
  107696. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  107697. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  107698. * * 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
  107699. * * 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
  107700. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107701. * @param name defines the name of the mesh
  107702. * @param options defines the options used to create the mesh
  107703. * @param scene defines the hosting scene
  107704. * @returns the tiled ground mesh
  107705. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  107706. */
  107707. static CreateTiledGround(name: string, options: {
  107708. xmin: number;
  107709. zmin: number;
  107710. xmax: number;
  107711. zmax: number;
  107712. subdivisions?: {
  107713. w: number;
  107714. h: number;
  107715. };
  107716. precision?: {
  107717. w: number;
  107718. h: number;
  107719. };
  107720. updatable?: boolean;
  107721. }, scene: Scene): Mesh;
  107722. /**
  107723. * Creates a ground mesh from a height map
  107724. * * The parameter `url` sets the URL of the height map image resource.
  107725. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  107726. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  107727. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  107728. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  107729. * * 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.
  107730. * * 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).
  107731. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  107732. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107733. * @param name defines the name of the mesh
  107734. * @param url defines the url to the height map
  107735. * @param options defines the options used to create the mesh
  107736. * @param scene defines the hosting scene
  107737. * @returns the ground mesh
  107738. * @see https://doc.babylonjs.com/babylon101/height_map
  107739. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  107740. */
  107741. static CreateGroundFromHeightMap(name: string, url: string, options: {
  107742. width?: number;
  107743. height?: number;
  107744. subdivisions?: number;
  107745. minHeight?: number;
  107746. maxHeight?: number;
  107747. colorFilter?: Color3;
  107748. alphaFilter?: number;
  107749. updatable?: boolean;
  107750. onReady?: (mesh: GroundMesh) => void;
  107751. }, scene: Scene): GroundMesh;
  107752. /**
  107753. * Creates a polygon mesh
  107754. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  107755. * * 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
  107756. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  107757. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107758. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  107759. * * Remember you can only change the shape positions, not their number when updating a polygon
  107760. * @param name defines the name of the mesh
  107761. * @param options defines the options used to create the mesh
  107762. * @param scene defines the hosting scene
  107763. * @param earcutInjection can be used to inject your own earcut reference
  107764. * @returns the polygon mesh
  107765. */
  107766. static CreatePolygon(name: string, options: {
  107767. shape: Vector3[];
  107768. holes?: Vector3[][];
  107769. depth?: number;
  107770. faceUV?: Vector4[];
  107771. faceColors?: Color4[];
  107772. updatable?: boolean;
  107773. sideOrientation?: number;
  107774. frontUVs?: Vector4;
  107775. backUVs?: Vector4;
  107776. }, scene: Scene, earcutInjection?: any): Mesh;
  107777. /**
  107778. * Creates an extruded polygon mesh, with depth in the Y direction.
  107779. * * 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)
  107780. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  107781. * @param name defines the name of the mesh
  107782. * @param options defines the options used to create the mesh
  107783. * @param scene defines the hosting scene
  107784. * @param earcutInjection can be used to inject your own earcut reference
  107785. * @returns the polygon mesh
  107786. */
  107787. static ExtrudePolygon(name: string, options: {
  107788. shape: Vector3[];
  107789. holes?: Vector3[][];
  107790. depth?: number;
  107791. faceUV?: Vector4[];
  107792. faceColors?: Color4[];
  107793. updatable?: boolean;
  107794. sideOrientation?: number;
  107795. frontUVs?: Vector4;
  107796. backUVs?: Vector4;
  107797. }, scene: Scene, earcutInjection?: any): Mesh;
  107798. /**
  107799. * Creates a tube mesh.
  107800. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  107801. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  107802. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  107803. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  107804. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  107805. * * 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)
  107806. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  107807. * * 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
  107808. * * 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
  107809. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107810. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107811. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107812. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107813. * @param name defines the name of the mesh
  107814. * @param options defines the options used to create the mesh
  107815. * @param scene defines the hosting scene
  107816. * @returns the tube mesh
  107817. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107818. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  107819. */
  107820. static CreateTube(name: string, options: {
  107821. path: Vector3[];
  107822. radius?: number;
  107823. tessellation?: number;
  107824. radiusFunction?: {
  107825. (i: number, distance: number): number;
  107826. };
  107827. cap?: number;
  107828. arc?: number;
  107829. updatable?: boolean;
  107830. sideOrientation?: number;
  107831. frontUVs?: Vector4;
  107832. backUVs?: Vector4;
  107833. instance?: Mesh;
  107834. invertUV?: boolean;
  107835. }, scene: Scene): Mesh;
  107836. /**
  107837. * Creates a polyhedron mesh
  107838. * * 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
  107839. * * The parameter `size` (positive float, default 1) sets the polygon size
  107840. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  107841. * * 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`
  107842. * * 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
  107843. * * 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)`)
  107844. * * 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
  107845. * * 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
  107846. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107847. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107848. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107849. * @param name defines the name of the mesh
  107850. * @param options defines the options used to create the mesh
  107851. * @param scene defines the hosting scene
  107852. * @returns the polyhedron mesh
  107853. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  107854. */
  107855. static CreatePolyhedron(name: string, options: {
  107856. type?: number;
  107857. size?: number;
  107858. sizeX?: number;
  107859. sizeY?: number;
  107860. sizeZ?: number;
  107861. custom?: any;
  107862. faceUV?: Vector4[];
  107863. faceColors?: Color4[];
  107864. flat?: boolean;
  107865. updatable?: boolean;
  107866. sideOrientation?: number;
  107867. frontUVs?: Vector4;
  107868. backUVs?: Vector4;
  107869. }, scene: Scene): Mesh;
  107870. /**
  107871. * Creates a decal mesh.
  107872. * 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
  107873. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  107874. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  107875. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  107876. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  107877. * @param name defines the name of the mesh
  107878. * @param sourceMesh defines the mesh where the decal must be applied
  107879. * @param options defines the options used to create the mesh
  107880. * @param scene defines the hosting scene
  107881. * @returns the decal mesh
  107882. * @see https://doc.babylonjs.com/how_to/decals
  107883. */
  107884. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  107885. position?: Vector3;
  107886. normal?: Vector3;
  107887. size?: Vector3;
  107888. angle?: number;
  107889. }): Mesh;
  107890. }
  107891. }
  107892. declare module BABYLON {
  107893. /**
  107894. * A simplifier interface for future simplification implementations
  107895. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  107896. */
  107897. export interface ISimplifier {
  107898. /**
  107899. * Simplification of a given mesh according to the given settings.
  107900. * Since this requires computation, it is assumed that the function runs async.
  107901. * @param settings The settings of the simplification, including quality and distance
  107902. * @param successCallback A callback that will be called after the mesh was simplified.
  107903. * @param errorCallback in case of an error, this callback will be called. optional.
  107904. */
  107905. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  107906. }
  107907. /**
  107908. * Expected simplification settings.
  107909. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  107910. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  107911. */
  107912. export interface ISimplificationSettings {
  107913. /**
  107914. * Gets or sets the expected quality
  107915. */
  107916. quality: number;
  107917. /**
  107918. * Gets or sets the distance when this optimized version should be used
  107919. */
  107920. distance: number;
  107921. /**
  107922. * Gets an already optimized mesh
  107923. */
  107924. optimizeMesh?: boolean;
  107925. }
  107926. /**
  107927. * Class used to specify simplification options
  107928. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  107929. */
  107930. export class SimplificationSettings implements ISimplificationSettings {
  107931. /** expected quality */
  107932. quality: number;
  107933. /** distance when this optimized version should be used */
  107934. distance: number;
  107935. /** already optimized mesh */
  107936. optimizeMesh?: boolean | undefined;
  107937. /**
  107938. * Creates a SimplificationSettings
  107939. * @param quality expected quality
  107940. * @param distance distance when this optimized version should be used
  107941. * @param optimizeMesh already optimized mesh
  107942. */
  107943. constructor(
  107944. /** expected quality */
  107945. quality: number,
  107946. /** distance when this optimized version should be used */
  107947. distance: number,
  107948. /** already optimized mesh */
  107949. optimizeMesh?: boolean | undefined);
  107950. }
  107951. /**
  107952. * Interface used to define a simplification task
  107953. */
  107954. export interface ISimplificationTask {
  107955. /**
  107956. * Array of settings
  107957. */
  107958. settings: Array<ISimplificationSettings>;
  107959. /**
  107960. * Simplification type
  107961. */
  107962. simplificationType: SimplificationType;
  107963. /**
  107964. * Mesh to simplify
  107965. */
  107966. mesh: Mesh;
  107967. /**
  107968. * Callback called on success
  107969. */
  107970. successCallback?: () => void;
  107971. /**
  107972. * Defines if parallel processing can be used
  107973. */
  107974. parallelProcessing: boolean;
  107975. }
  107976. /**
  107977. * Queue used to order the simplification tasks
  107978. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  107979. */
  107980. export class SimplificationQueue {
  107981. private _simplificationArray;
  107982. /**
  107983. * Gets a boolean indicating that the process is still running
  107984. */
  107985. running: boolean;
  107986. /**
  107987. * Creates a new queue
  107988. */
  107989. constructor();
  107990. /**
  107991. * Adds a new simplification task
  107992. * @param task defines a task to add
  107993. */
  107994. addTask(task: ISimplificationTask): void;
  107995. /**
  107996. * Execute next task
  107997. */
  107998. executeNext(): void;
  107999. /**
  108000. * Execute a simplification task
  108001. * @param task defines the task to run
  108002. */
  108003. runSimplification(task: ISimplificationTask): void;
  108004. private getSimplifier;
  108005. }
  108006. /**
  108007. * The implemented types of simplification
  108008. * At the moment only Quadratic Error Decimation is implemented
  108009. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  108010. */
  108011. export enum SimplificationType {
  108012. /** Quadratic error decimation */
  108013. QUADRATIC = 0
  108014. }
  108015. }
  108016. declare module BABYLON {
  108017. interface Scene {
  108018. /** @hidden (Backing field) */
  108019. _simplificationQueue: SimplificationQueue;
  108020. /**
  108021. * Gets or sets the simplification queue attached to the scene
  108022. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  108023. */
  108024. simplificationQueue: SimplificationQueue;
  108025. }
  108026. interface Mesh {
  108027. /**
  108028. * Simplify the mesh according to the given array of settings.
  108029. * Function will return immediately and will simplify async
  108030. * @param settings a collection of simplification settings
  108031. * @param parallelProcessing should all levels calculate parallel or one after the other
  108032. * @param simplificationType the type of simplification to run
  108033. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  108034. * @returns the current mesh
  108035. */
  108036. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  108037. }
  108038. /**
  108039. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  108040. * created in a scene
  108041. */
  108042. export class SimplicationQueueSceneComponent implements ISceneComponent {
  108043. /**
  108044. * The component name helpfull to identify the component in the list of scene components.
  108045. */
  108046. readonly name: string;
  108047. /**
  108048. * The scene the component belongs to.
  108049. */
  108050. scene: Scene;
  108051. /**
  108052. * Creates a new instance of the component for the given scene
  108053. * @param scene Defines the scene to register the component in
  108054. */
  108055. constructor(scene: Scene);
  108056. /**
  108057. * Registers the component in a given scene
  108058. */
  108059. register(): void;
  108060. /**
  108061. * Rebuilds the elements related to this component in case of
  108062. * context lost for instance.
  108063. */
  108064. rebuild(): void;
  108065. /**
  108066. * Disposes the component and the associated ressources
  108067. */
  108068. dispose(): void;
  108069. private _beforeCameraUpdate;
  108070. }
  108071. }
  108072. declare module BABYLON {
  108073. /**
  108074. * Class used to enable access to IndexedDB
  108075. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  108076. */
  108077. export class Database implements IOfflineProvider {
  108078. private _callbackManifestChecked;
  108079. private _currentSceneUrl;
  108080. private _db;
  108081. private _enableSceneOffline;
  108082. private _enableTexturesOffline;
  108083. private _manifestVersionFound;
  108084. private _mustUpdateRessources;
  108085. private _hasReachedQuota;
  108086. private _isSupported;
  108087. private _idbFactory;
  108088. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  108089. private static IsUASupportingBlobStorage;
  108090. /**
  108091. * Gets a boolean indicating if Database storate is enabled (off by default)
  108092. */
  108093. static IDBStorageEnabled: boolean;
  108094. /**
  108095. * Gets a boolean indicating if scene must be saved in the database
  108096. */
  108097. readonly enableSceneOffline: boolean;
  108098. /**
  108099. * Gets a boolean indicating if textures must be saved in the database
  108100. */
  108101. readonly enableTexturesOffline: boolean;
  108102. /**
  108103. * Creates a new Database
  108104. * @param urlToScene defines the url to load the scene
  108105. * @param callbackManifestChecked defines the callback to use when manifest is checked
  108106. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  108107. */
  108108. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  108109. private static _ParseURL;
  108110. private static _ReturnFullUrlLocation;
  108111. private _checkManifestFile;
  108112. /**
  108113. * Open the database and make it available
  108114. * @param successCallback defines the callback to call on success
  108115. * @param errorCallback defines the callback to call on error
  108116. */
  108117. open(successCallback: () => void, errorCallback: () => void): void;
  108118. /**
  108119. * Loads an image from the database
  108120. * @param url defines the url to load from
  108121. * @param image defines the target DOM image
  108122. */
  108123. loadImage(url: string, image: HTMLImageElement): void;
  108124. private _loadImageFromDBAsync;
  108125. private _saveImageIntoDBAsync;
  108126. private _checkVersionFromDB;
  108127. private _loadVersionFromDBAsync;
  108128. private _saveVersionIntoDBAsync;
  108129. /**
  108130. * Loads a file from database
  108131. * @param url defines the URL to load from
  108132. * @param sceneLoaded defines a callback to call on success
  108133. * @param progressCallBack defines a callback to call when progress changed
  108134. * @param errorCallback defines a callback to call on error
  108135. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  108136. */
  108137. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  108138. private _loadFileAsync;
  108139. private _saveFileAsync;
  108140. /**
  108141. * Validates if xhr data is correct
  108142. * @param xhr defines the request to validate
  108143. * @param dataType defines the expected data type
  108144. * @returns true if data is correct
  108145. */
  108146. private static _ValidateXHRData;
  108147. }
  108148. }
  108149. declare module BABYLON {
  108150. /** @hidden */
  108151. export var gpuUpdateParticlesPixelShader: {
  108152. name: string;
  108153. shader: string;
  108154. };
  108155. }
  108156. declare module BABYLON {
  108157. /** @hidden */
  108158. export var gpuUpdateParticlesVertexShader: {
  108159. name: string;
  108160. shader: string;
  108161. };
  108162. }
  108163. declare module BABYLON {
  108164. /** @hidden */
  108165. export var clipPlaneFragmentDeclaration2: {
  108166. name: string;
  108167. shader: string;
  108168. };
  108169. }
  108170. declare module BABYLON {
  108171. /** @hidden */
  108172. export var gpuRenderParticlesPixelShader: {
  108173. name: string;
  108174. shader: string;
  108175. };
  108176. }
  108177. declare module BABYLON {
  108178. /** @hidden */
  108179. export var clipPlaneVertexDeclaration2: {
  108180. name: string;
  108181. shader: string;
  108182. };
  108183. }
  108184. declare module BABYLON {
  108185. /** @hidden */
  108186. export var gpuRenderParticlesVertexShader: {
  108187. name: string;
  108188. shader: string;
  108189. };
  108190. }
  108191. declare module BABYLON {
  108192. /**
  108193. * This represents a GPU particle system in Babylon
  108194. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  108195. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  108196. */
  108197. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  108198. /**
  108199. * The layer mask we are rendering the particles through.
  108200. */
  108201. layerMask: number;
  108202. private _capacity;
  108203. private _activeCount;
  108204. private _currentActiveCount;
  108205. private _accumulatedCount;
  108206. private _renderEffect;
  108207. private _updateEffect;
  108208. private _buffer0;
  108209. private _buffer1;
  108210. private _spriteBuffer;
  108211. private _updateVAO;
  108212. private _renderVAO;
  108213. private _targetIndex;
  108214. private _sourceBuffer;
  108215. private _targetBuffer;
  108216. private _engine;
  108217. private _currentRenderId;
  108218. private _started;
  108219. private _stopped;
  108220. private _timeDelta;
  108221. private _randomTexture;
  108222. private _randomTexture2;
  108223. private _attributesStrideSize;
  108224. private _updateEffectOptions;
  108225. private _randomTextureSize;
  108226. private _actualFrame;
  108227. private readonly _rawTextureWidth;
  108228. /**
  108229. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  108230. */
  108231. static readonly IsSupported: boolean;
  108232. /**
  108233. * An event triggered when the system is disposed.
  108234. */
  108235. onDisposeObservable: Observable<GPUParticleSystem>;
  108236. /**
  108237. * Gets the maximum number of particles active at the same time.
  108238. * @returns The max number of active particles.
  108239. */
  108240. getCapacity(): number;
  108241. /**
  108242. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  108243. * to override the particles.
  108244. */
  108245. forceDepthWrite: boolean;
  108246. /**
  108247. * Gets or set the number of active particles
  108248. */
  108249. activeParticleCount: number;
  108250. private _preWarmDone;
  108251. /**
  108252. * Is this system ready to be used/rendered
  108253. * @return true if the system is ready
  108254. */
  108255. isReady(): boolean;
  108256. /**
  108257. * Gets if the system has been started. (Note: this will still be true after stop is called)
  108258. * @returns True if it has been started, otherwise false.
  108259. */
  108260. isStarted(): boolean;
  108261. /**
  108262. * Starts the particle system and begins to emit
  108263. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  108264. */
  108265. start(delay?: number): void;
  108266. /**
  108267. * Stops the particle system.
  108268. */
  108269. stop(): void;
  108270. /**
  108271. * Remove all active particles
  108272. */
  108273. reset(): void;
  108274. /**
  108275. * Returns the string "GPUParticleSystem"
  108276. * @returns a string containing the class name
  108277. */
  108278. getClassName(): string;
  108279. private _colorGradientsTexture;
  108280. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  108281. /**
  108282. * Adds a new color gradient
  108283. * @param gradient defines the gradient to use (between 0 and 1)
  108284. * @param color1 defines the color to affect to the specified gradient
  108285. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  108286. * @returns the current particle system
  108287. */
  108288. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  108289. /**
  108290. * Remove a specific color gradient
  108291. * @param gradient defines the gradient to remove
  108292. * @returns the current particle system
  108293. */
  108294. removeColorGradient(gradient: number): GPUParticleSystem;
  108295. private _angularSpeedGradientsTexture;
  108296. private _sizeGradientsTexture;
  108297. private _velocityGradientsTexture;
  108298. private _limitVelocityGradientsTexture;
  108299. private _dragGradientsTexture;
  108300. private _addFactorGradient;
  108301. /**
  108302. * Adds a new size gradient
  108303. * @param gradient defines the gradient to use (between 0 and 1)
  108304. * @param factor defines the size factor to affect to the specified gradient
  108305. * @returns the current particle system
  108306. */
  108307. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  108308. /**
  108309. * Remove a specific size gradient
  108310. * @param gradient defines the gradient to remove
  108311. * @returns the current particle system
  108312. */
  108313. removeSizeGradient(gradient: number): GPUParticleSystem;
  108314. /**
  108315. * Adds a new angular speed gradient
  108316. * @param gradient defines the gradient to use (between 0 and 1)
  108317. * @param factor defines the angular speed to affect to the specified gradient
  108318. * @returns the current particle system
  108319. */
  108320. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  108321. /**
  108322. * Remove a specific angular speed gradient
  108323. * @param gradient defines the gradient to remove
  108324. * @returns the current particle system
  108325. */
  108326. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  108327. /**
  108328. * Adds a new velocity gradient
  108329. * @param gradient defines the gradient to use (between 0 and 1)
  108330. * @param factor defines the velocity to affect to the specified gradient
  108331. * @returns the current particle system
  108332. */
  108333. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  108334. /**
  108335. * Remove a specific velocity gradient
  108336. * @param gradient defines the gradient to remove
  108337. * @returns the current particle system
  108338. */
  108339. removeVelocityGradient(gradient: number): GPUParticleSystem;
  108340. /**
  108341. * Adds a new limit velocity gradient
  108342. * @param gradient defines the gradient to use (between 0 and 1)
  108343. * @param factor defines the limit velocity value to affect to the specified gradient
  108344. * @returns the current particle system
  108345. */
  108346. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  108347. /**
  108348. * Remove a specific limit velocity gradient
  108349. * @param gradient defines the gradient to remove
  108350. * @returns the current particle system
  108351. */
  108352. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  108353. /**
  108354. * Adds a new drag gradient
  108355. * @param gradient defines the gradient to use (between 0 and 1)
  108356. * @param factor defines the drag value to affect to the specified gradient
  108357. * @returns the current particle system
  108358. */
  108359. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  108360. /**
  108361. * Remove a specific drag gradient
  108362. * @param gradient defines the gradient to remove
  108363. * @returns the current particle system
  108364. */
  108365. removeDragGradient(gradient: number): GPUParticleSystem;
  108366. /**
  108367. * Not supported by GPUParticleSystem
  108368. * @param gradient defines the gradient to use (between 0 and 1)
  108369. * @param factor defines the emit rate value to affect to the specified gradient
  108370. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  108371. * @returns the current particle system
  108372. */
  108373. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  108374. /**
  108375. * Not supported by GPUParticleSystem
  108376. * @param gradient defines the gradient to remove
  108377. * @returns the current particle system
  108378. */
  108379. removeEmitRateGradient(gradient: number): IParticleSystem;
  108380. /**
  108381. * Not supported by GPUParticleSystem
  108382. * @param gradient defines the gradient to use (between 0 and 1)
  108383. * @param factor defines the start size value to affect to the specified gradient
  108384. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  108385. * @returns the current particle system
  108386. */
  108387. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  108388. /**
  108389. * Not supported by GPUParticleSystem
  108390. * @param gradient defines the gradient to remove
  108391. * @returns the current particle system
  108392. */
  108393. removeStartSizeGradient(gradient: number): IParticleSystem;
  108394. /**
  108395. * Not supported by GPUParticleSystem
  108396. * @param gradient defines the gradient to use (between 0 and 1)
  108397. * @param min defines the color remap minimal range
  108398. * @param max defines the color remap maximal range
  108399. * @returns the current particle system
  108400. */
  108401. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  108402. /**
  108403. * Not supported by GPUParticleSystem
  108404. * @param gradient defines the gradient to remove
  108405. * @returns the current particle system
  108406. */
  108407. removeColorRemapGradient(): IParticleSystem;
  108408. /**
  108409. * Not supported by GPUParticleSystem
  108410. * @param gradient defines the gradient to use (between 0 and 1)
  108411. * @param min defines the alpha remap minimal range
  108412. * @param max defines the alpha remap maximal range
  108413. * @returns the current particle system
  108414. */
  108415. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  108416. /**
  108417. * Not supported by GPUParticleSystem
  108418. * @param gradient defines the gradient to remove
  108419. * @returns the current particle system
  108420. */
  108421. removeAlphaRemapGradient(): IParticleSystem;
  108422. /**
  108423. * Not supported by GPUParticleSystem
  108424. * @param gradient defines the gradient to use (between 0 and 1)
  108425. * @param color defines the color to affect to the specified gradient
  108426. * @returns the current particle system
  108427. */
  108428. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  108429. /**
  108430. * Not supported by GPUParticleSystem
  108431. * @param gradient defines the gradient to remove
  108432. * @returns the current particle system
  108433. */
  108434. removeRampGradient(): IParticleSystem;
  108435. /**
  108436. * Not supported by GPUParticleSystem
  108437. * @returns the list of ramp gradients
  108438. */
  108439. getRampGradients(): Nullable<Array<Color3Gradient>>;
  108440. /**
  108441. * Not supported by GPUParticleSystem
  108442. * Gets or sets a boolean indicating that ramp gradients must be used
  108443. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  108444. */
  108445. useRampGradients: boolean;
  108446. /**
  108447. * Not supported by GPUParticleSystem
  108448. * @param gradient defines the gradient to use (between 0 and 1)
  108449. * @param factor defines the life time factor to affect to the specified gradient
  108450. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  108451. * @returns the current particle system
  108452. */
  108453. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  108454. /**
  108455. * Not supported by GPUParticleSystem
  108456. * @param gradient defines the gradient to remove
  108457. * @returns the current particle system
  108458. */
  108459. removeLifeTimeGradient(gradient: number): IParticleSystem;
  108460. /**
  108461. * Instantiates a GPU particle system.
  108462. * 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.
  108463. * @param name The name of the particle system
  108464. * @param options The options used to create the system
  108465. * @param scene The scene the particle system belongs to
  108466. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  108467. */
  108468. constructor(name: string, options: Partial<{
  108469. capacity: number;
  108470. randomTextureSize: number;
  108471. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  108472. protected _reset(): void;
  108473. private _createUpdateVAO;
  108474. private _createRenderVAO;
  108475. private _initialize;
  108476. /** @hidden */
  108477. _recreateUpdateEffect(): void;
  108478. /** @hidden */
  108479. _recreateRenderEffect(): void;
  108480. /**
  108481. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  108482. * @param preWarm defines if we are in the pre-warmimg phase
  108483. */
  108484. animate(preWarm?: boolean): void;
  108485. private _createFactorGradientTexture;
  108486. private _createSizeGradientTexture;
  108487. private _createAngularSpeedGradientTexture;
  108488. private _createVelocityGradientTexture;
  108489. private _createLimitVelocityGradientTexture;
  108490. private _createDragGradientTexture;
  108491. private _createColorGradientTexture;
  108492. /**
  108493. * Renders the particle system in its current state
  108494. * @param preWarm defines if the system should only update the particles but not render them
  108495. * @returns the current number of particles
  108496. */
  108497. render(preWarm?: boolean): number;
  108498. /**
  108499. * Rebuilds the particle system
  108500. */
  108501. rebuild(): void;
  108502. private _releaseBuffers;
  108503. private _releaseVAOs;
  108504. /**
  108505. * Disposes the particle system and free the associated resources
  108506. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  108507. */
  108508. dispose(disposeTexture?: boolean): void;
  108509. /**
  108510. * Clones the particle system.
  108511. * @param name The name of the cloned object
  108512. * @param newEmitter The new emitter to use
  108513. * @returns the cloned particle system
  108514. */
  108515. clone(name: string, newEmitter: any): GPUParticleSystem;
  108516. /**
  108517. * Serializes the particle system to a JSON object.
  108518. * @returns the JSON object
  108519. */
  108520. serialize(): any;
  108521. /**
  108522. * Parses a JSON object to create a GPU particle system.
  108523. * @param parsedParticleSystem The JSON object to parse
  108524. * @param scene The scene to create the particle system in
  108525. * @param rootUrl The root url to use to load external dependencies like texture
  108526. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  108527. * @returns the parsed GPU particle system
  108528. */
  108529. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  108530. }
  108531. }
  108532. declare module BABYLON {
  108533. /**
  108534. * Represents a set of particle systems working together to create a specific effect
  108535. */
  108536. export class ParticleSystemSet implements IDisposable {
  108537. private _emitterCreationOptions;
  108538. private _emitterNode;
  108539. /**
  108540. * Gets the particle system list
  108541. */
  108542. systems: IParticleSystem[];
  108543. /**
  108544. * Gets the emitter node used with this set
  108545. */
  108546. readonly emitterNode: Nullable<TransformNode>;
  108547. /**
  108548. * Creates a new emitter mesh as a sphere
  108549. * @param options defines the options used to create the sphere
  108550. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  108551. * @param scene defines the hosting scene
  108552. */
  108553. setEmitterAsSphere(options: {
  108554. diameter: number;
  108555. segments: number;
  108556. color: Color3;
  108557. }, renderingGroupId: number, scene: Scene): void;
  108558. /**
  108559. * Starts all particle systems of the set
  108560. * @param emitter defines an optional mesh to use as emitter for the particle systems
  108561. */
  108562. start(emitter?: AbstractMesh): void;
  108563. /**
  108564. * Release all associated resources
  108565. */
  108566. dispose(): void;
  108567. /**
  108568. * Serialize the set into a JSON compatible object
  108569. * @returns a JSON compatible representation of the set
  108570. */
  108571. serialize(): any;
  108572. /**
  108573. * Parse a new ParticleSystemSet from a serialized source
  108574. * @param data defines a JSON compatible representation of the set
  108575. * @param scene defines the hosting scene
  108576. * @param gpu defines if we want GPU particles or CPU particles
  108577. * @returns a new ParticleSystemSet
  108578. */
  108579. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  108580. }
  108581. }
  108582. declare module BABYLON {
  108583. /**
  108584. * This class is made for on one-liner static method to help creating particle system set.
  108585. */
  108586. export class ParticleHelper {
  108587. /**
  108588. * Gets or sets base Assets URL
  108589. */
  108590. static BaseAssetsUrl: string;
  108591. /**
  108592. * Create a default particle system that you can tweak
  108593. * @param emitter defines the emitter to use
  108594. * @param capacity defines the system capacity (default is 500 particles)
  108595. * @param scene defines the hosting scene
  108596. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  108597. * @returns the new Particle system
  108598. */
  108599. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  108600. /**
  108601. * This is the main static method (one-liner) of this helper to create different particle systems
  108602. * @param type This string represents the type to the particle system to create
  108603. * @param scene The scene where the particle system should live
  108604. * @param gpu If the system will use gpu
  108605. * @returns the ParticleSystemSet created
  108606. */
  108607. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  108608. /**
  108609. * Static function used to export a particle system to a ParticleSystemSet variable.
  108610. * Please note that the emitter shape is not exported
  108611. * @param systems defines the particle systems to export
  108612. * @returns the created particle system set
  108613. */
  108614. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  108615. }
  108616. }
  108617. declare module BABYLON {
  108618. interface Engine {
  108619. /**
  108620. * Create an effect to use with particle systems.
  108621. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  108622. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  108623. * @param uniformsNames defines a list of attribute names
  108624. * @param samplers defines an array of string used to represent textures
  108625. * @param defines defines the string containing the defines to use to compile the shaders
  108626. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  108627. * @param onCompiled defines a function to call when the effect creation is successful
  108628. * @param onError defines a function to call when the effect creation has failed
  108629. * @returns the new Effect
  108630. */
  108631. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  108632. }
  108633. interface Mesh {
  108634. /**
  108635. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  108636. * @returns an array of IParticleSystem
  108637. */
  108638. getEmittedParticleSystems(): IParticleSystem[];
  108639. /**
  108640. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  108641. * @returns an array of IParticleSystem
  108642. */
  108643. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  108644. }
  108645. /**
  108646. * @hidden
  108647. */
  108648. export var _IDoNeedToBeInTheBuild: number;
  108649. }
  108650. declare module BABYLON {
  108651. interface Scene {
  108652. /** @hidden (Backing field) */
  108653. _physicsEngine: Nullable<IPhysicsEngine>;
  108654. /**
  108655. * Gets the current physics engine
  108656. * @returns a IPhysicsEngine or null if none attached
  108657. */
  108658. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  108659. /**
  108660. * Enables physics to the current scene
  108661. * @param gravity defines the scene's gravity for the physics engine
  108662. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  108663. * @return a boolean indicating if the physics engine was initialized
  108664. */
  108665. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  108666. /**
  108667. * Disables and disposes the physics engine associated with the scene
  108668. */
  108669. disablePhysicsEngine(): void;
  108670. /**
  108671. * Gets a boolean indicating if there is an active physics engine
  108672. * @returns a boolean indicating if there is an active physics engine
  108673. */
  108674. isPhysicsEnabled(): boolean;
  108675. /**
  108676. * Deletes a physics compound impostor
  108677. * @param compound defines the compound to delete
  108678. */
  108679. deleteCompoundImpostor(compound: any): void;
  108680. /**
  108681. * An event triggered when physic simulation is about to be run
  108682. */
  108683. onBeforePhysicsObservable: Observable<Scene>;
  108684. /**
  108685. * An event triggered when physic simulation has been done
  108686. */
  108687. onAfterPhysicsObservable: Observable<Scene>;
  108688. }
  108689. interface AbstractMesh {
  108690. /** @hidden */
  108691. _physicsImpostor: Nullable<PhysicsImpostor>;
  108692. /**
  108693. * Gets or sets impostor used for physic simulation
  108694. * @see http://doc.babylonjs.com/features/physics_engine
  108695. */
  108696. physicsImpostor: Nullable<PhysicsImpostor>;
  108697. /**
  108698. * Gets the current physics impostor
  108699. * @see http://doc.babylonjs.com/features/physics_engine
  108700. * @returns a physics impostor or null
  108701. */
  108702. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  108703. /** Apply a physic impulse to the mesh
  108704. * @param force defines the force to apply
  108705. * @param contactPoint defines where to apply the force
  108706. * @returns the current mesh
  108707. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  108708. */
  108709. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  108710. /**
  108711. * Creates a physic joint between two meshes
  108712. * @param otherMesh defines the other mesh to use
  108713. * @param pivot1 defines the pivot to use on this mesh
  108714. * @param pivot2 defines the pivot to use on the other mesh
  108715. * @param options defines additional options (can be plugin dependent)
  108716. * @returns the current mesh
  108717. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  108718. */
  108719. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  108720. /** @hidden */
  108721. _disposePhysicsObserver: Nullable<Observer<Node>>;
  108722. }
  108723. /**
  108724. * Defines the physics engine scene component responsible to manage a physics engine
  108725. */
  108726. export class PhysicsEngineSceneComponent implements ISceneComponent {
  108727. /**
  108728. * The component name helpful to identify the component in the list of scene components.
  108729. */
  108730. readonly name: string;
  108731. /**
  108732. * The scene the component belongs to.
  108733. */
  108734. scene: Scene;
  108735. /**
  108736. * Creates a new instance of the component for the given scene
  108737. * @param scene Defines the scene to register the component in
  108738. */
  108739. constructor(scene: Scene);
  108740. /**
  108741. * Registers the component in a given scene
  108742. */
  108743. register(): void;
  108744. /**
  108745. * Rebuilds the elements related to this component in case of
  108746. * context lost for instance.
  108747. */
  108748. rebuild(): void;
  108749. /**
  108750. * Disposes the component and the associated ressources
  108751. */
  108752. dispose(): void;
  108753. }
  108754. }
  108755. declare module BABYLON {
  108756. /**
  108757. * A helper for physics simulations
  108758. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  108759. */
  108760. export class PhysicsHelper {
  108761. private _scene;
  108762. private _physicsEngine;
  108763. /**
  108764. * Initializes the Physics helper
  108765. * @param scene Babylon.js scene
  108766. */
  108767. constructor(scene: Scene);
  108768. /**
  108769. * Applies a radial explosion impulse
  108770. * @param origin the origin of the explosion
  108771. * @param radiusOrEventOptions the radius or the options of radial explosion
  108772. * @param strength the explosion strength
  108773. * @param falloff possible options: Constant & Linear. Defaults to Constant
  108774. * @returns A physics radial explosion event, or null
  108775. */
  108776. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  108777. /**
  108778. * Applies a radial explosion force
  108779. * @param origin the origin of the explosion
  108780. * @param radiusOrEventOptions the radius or the options of radial explosion
  108781. * @param strength the explosion strength
  108782. * @param falloff possible options: Constant & Linear. Defaults to Constant
  108783. * @returns A physics radial explosion event, or null
  108784. */
  108785. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  108786. /**
  108787. * Creates a gravitational field
  108788. * @param origin the origin of the explosion
  108789. * @param radiusOrEventOptions the radius or the options of radial explosion
  108790. * @param strength the explosion strength
  108791. * @param falloff possible options: Constant & Linear. Defaults to Constant
  108792. * @returns A physics gravitational field event, or null
  108793. */
  108794. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  108795. /**
  108796. * Creates a physics updraft event
  108797. * @param origin the origin of the updraft
  108798. * @param radiusOrEventOptions the radius or the options of the updraft
  108799. * @param strength the strength of the updraft
  108800. * @param height the height of the updraft
  108801. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  108802. * @returns A physics updraft event, or null
  108803. */
  108804. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  108805. /**
  108806. * Creates a physics vortex event
  108807. * @param origin the of the vortex
  108808. * @param radiusOrEventOptions the radius or the options of the vortex
  108809. * @param strength the strength of the vortex
  108810. * @param height the height of the vortex
  108811. * @returns a Physics vortex event, or null
  108812. * A physics vortex event or null
  108813. */
  108814. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  108815. }
  108816. /**
  108817. * Represents a physics radial explosion event
  108818. */
  108819. class PhysicsRadialExplosionEvent {
  108820. private _scene;
  108821. private _options;
  108822. private _sphere;
  108823. private _dataFetched;
  108824. /**
  108825. * Initializes a radial explosioin event
  108826. * @param _scene BabylonJS scene
  108827. * @param _options The options for the vortex event
  108828. */
  108829. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  108830. /**
  108831. * Returns the data related to the radial explosion event (sphere).
  108832. * @returns The radial explosion event data
  108833. */
  108834. getData(): PhysicsRadialExplosionEventData;
  108835. /**
  108836. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  108837. * @param impostor A physics imposter
  108838. * @param origin the origin of the explosion
  108839. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  108840. */
  108841. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsForceAndContactPoint>;
  108842. /**
  108843. * Disposes the sphere.
  108844. * @param force Specifies if the sphere should be disposed by force
  108845. */
  108846. dispose(force?: boolean): void;
  108847. /*** Helpers ***/
  108848. private _prepareSphere;
  108849. private _intersectsWithSphere;
  108850. }
  108851. /**
  108852. * Represents a gravitational field event
  108853. */
  108854. class PhysicsGravitationalFieldEvent {
  108855. private _physicsHelper;
  108856. private _scene;
  108857. private _origin;
  108858. private _options;
  108859. private _tickCallback;
  108860. private _sphere;
  108861. private _dataFetched;
  108862. /**
  108863. * Initializes the physics gravitational field event
  108864. * @param _physicsHelper A physics helper
  108865. * @param _scene BabylonJS scene
  108866. * @param _origin The origin position of the gravitational field event
  108867. * @param _options The options for the vortex event
  108868. */
  108869. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  108870. /**
  108871. * Returns the data related to the gravitational field event (sphere).
  108872. * @returns A gravitational field event
  108873. */
  108874. getData(): PhysicsGravitationalFieldEventData;
  108875. /**
  108876. * Enables the gravitational field.
  108877. */
  108878. enable(): void;
  108879. /**
  108880. * Disables the gravitational field.
  108881. */
  108882. disable(): void;
  108883. /**
  108884. * Disposes the sphere.
  108885. * @param force The force to dispose from the gravitational field event
  108886. */
  108887. dispose(force?: boolean): void;
  108888. private _tick;
  108889. }
  108890. /**
  108891. * Represents a physics updraft event
  108892. */
  108893. class PhysicsUpdraftEvent {
  108894. private _scene;
  108895. private _origin;
  108896. private _options;
  108897. private _physicsEngine;
  108898. private _originTop;
  108899. private _originDirection;
  108900. private _tickCallback;
  108901. private _cylinder;
  108902. private _cylinderPosition;
  108903. private _dataFetched;
  108904. /**
  108905. * Initializes the physics updraft event
  108906. * @param _scene BabylonJS scene
  108907. * @param _origin The origin position of the updraft
  108908. * @param _options The options for the updraft event
  108909. */
  108910. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  108911. /**
  108912. * Returns the data related to the updraft event (cylinder).
  108913. * @returns A physics updraft event
  108914. */
  108915. getData(): PhysicsUpdraftEventData;
  108916. /**
  108917. * Enables the updraft.
  108918. */
  108919. enable(): void;
  108920. /**
  108921. * Disables the updraft.
  108922. */
  108923. disable(): void;
  108924. /**
  108925. * Disposes the cylinder.
  108926. * @param force Specifies if the updraft should be disposed by force
  108927. */
  108928. dispose(force?: boolean): void;
  108929. private getImpostorForceAndContactPoint;
  108930. private _tick;
  108931. /*** Helpers ***/
  108932. private _prepareCylinder;
  108933. private _intersectsWithCylinder;
  108934. }
  108935. /**
  108936. * Represents a physics vortex event
  108937. */
  108938. class PhysicsVortexEvent {
  108939. private _scene;
  108940. private _origin;
  108941. private _options;
  108942. private _physicsEngine;
  108943. private _originTop;
  108944. private _tickCallback;
  108945. private _cylinder;
  108946. private _cylinderPosition;
  108947. private _dataFetched;
  108948. /**
  108949. * Initializes the physics vortex event
  108950. * @param _scene The BabylonJS scene
  108951. * @param _origin The origin position of the vortex
  108952. * @param _options The options for the vortex event
  108953. */
  108954. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  108955. /**
  108956. * Returns the data related to the vortex event (cylinder).
  108957. * @returns The physics vortex event data
  108958. */
  108959. getData(): PhysicsVortexEventData;
  108960. /**
  108961. * Enables the vortex.
  108962. */
  108963. enable(): void;
  108964. /**
  108965. * Disables the cortex.
  108966. */
  108967. disable(): void;
  108968. /**
  108969. * Disposes the sphere.
  108970. * @param force
  108971. */
  108972. dispose(force?: boolean): void;
  108973. private getImpostorForceAndContactPoint;
  108974. private _tick;
  108975. /*** Helpers ***/
  108976. private _prepareCylinder;
  108977. private _intersectsWithCylinder;
  108978. }
  108979. /**
  108980. * Options fot the radial explosion event
  108981. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  108982. */
  108983. export class PhysicsRadialExplosionEventOptions {
  108984. /**
  108985. * The radius of the sphere for the radial explosion.
  108986. */
  108987. radius: number;
  108988. /**
  108989. * The strenth of the explosion.
  108990. */
  108991. strength: number;
  108992. /**
  108993. * The strenght of the force in correspondence to the distance of the affected object
  108994. */
  108995. falloff: PhysicsRadialImpulseFalloff;
  108996. /**
  108997. * Sphere options for the radial explosion.
  108998. */
  108999. sphere: {
  109000. segments: number;
  109001. diameter: number;
  109002. };
  109003. }
  109004. /**
  109005. * Options fot the updraft event
  109006. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109007. */
  109008. export class PhysicsUpdraftEventOptions {
  109009. /**
  109010. * The radius of the cylinder for the vortex
  109011. */
  109012. radius: number;
  109013. /**
  109014. * The strenth of the updraft.
  109015. */
  109016. strength: number;
  109017. /**
  109018. * The height of the cylinder for the updraft.
  109019. */
  109020. height: number;
  109021. /**
  109022. * The mode for the the updraft.
  109023. */
  109024. updraftMode: PhysicsUpdraftMode;
  109025. }
  109026. /**
  109027. * Options fot the vortex event
  109028. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109029. */
  109030. export class PhysicsVortexEventOptions {
  109031. /**
  109032. * The radius of the cylinder for the vortex
  109033. */
  109034. radius: number;
  109035. /**
  109036. * The strenth of the vortex.
  109037. */
  109038. strength: number;
  109039. /**
  109040. * The height of the cylinder for the vortex.
  109041. */
  109042. height: number;
  109043. /**
  109044. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  109045. */
  109046. centripetalForceThreshold: number;
  109047. /**
  109048. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  109049. */
  109050. centripetalForceMultiplier: number;
  109051. /**
  109052. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  109053. */
  109054. centrifugalForceMultiplier: number;
  109055. /**
  109056. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  109057. */
  109058. updraftForceMultiplier: number;
  109059. }
  109060. /**
  109061. * The strenght of the force in correspondence to the distance of the affected object
  109062. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109063. */
  109064. export enum PhysicsRadialImpulseFalloff {
  109065. /** Defines that impulse is constant in strength across it's whole radius */
  109066. Constant = 0,
  109067. /** Defines that impulse gets weaker if it's further from the origin */
  109068. Linear = 1
  109069. }
  109070. /**
  109071. * The strength of the force in correspondence to the distance of the affected object
  109072. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109073. */
  109074. export enum PhysicsUpdraftMode {
  109075. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  109076. Center = 0,
  109077. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  109078. Perpendicular = 1
  109079. }
  109080. /**
  109081. * Interface for a physics force and contact point
  109082. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109083. */
  109084. export interface PhysicsForceAndContactPoint {
  109085. /**
  109086. * The force applied at the contact point
  109087. */
  109088. force: Vector3;
  109089. /**
  109090. * The contact point
  109091. */
  109092. contactPoint: Vector3;
  109093. }
  109094. /**
  109095. * Interface for radial explosion event data
  109096. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109097. */
  109098. export interface PhysicsRadialExplosionEventData {
  109099. /**
  109100. * A sphere used for the radial explosion event
  109101. */
  109102. sphere: Mesh;
  109103. }
  109104. /**
  109105. * Interface for gravitational field event data
  109106. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109107. */
  109108. export interface PhysicsGravitationalFieldEventData {
  109109. /**
  109110. * A sphere mesh used for the gravitational field event
  109111. */
  109112. sphere: Mesh;
  109113. }
  109114. /**
  109115. * Interface for updraft event data
  109116. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109117. */
  109118. export interface PhysicsUpdraftEventData {
  109119. /**
  109120. * A cylinder used for the updraft event
  109121. */
  109122. cylinder: Mesh;
  109123. }
  109124. /**
  109125. * Interface for vortex event data
  109126. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  109127. */
  109128. export interface PhysicsVortexEventData {
  109129. /**
  109130. * A cylinder used for the vortex event
  109131. */
  109132. cylinder: Mesh;
  109133. }
  109134. }
  109135. declare module BABYLON {
  109136. /**
  109137. * AmmoJS Physics plugin
  109138. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  109139. * @see https://github.com/kripken/ammo.js/
  109140. */
  109141. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  109142. private _useDeltaForWorldStep;
  109143. /**
  109144. * Reference to the Ammo library
  109145. */
  109146. bjsAMMO: any;
  109147. /**
  109148. * Created ammoJS world which physics bodies are added to
  109149. */
  109150. world: any;
  109151. /**
  109152. * Name of the plugin
  109153. */
  109154. name: string;
  109155. private _timeStep;
  109156. private _fixedTimeStep;
  109157. private _maxSteps;
  109158. private _tmpQuaternion;
  109159. private _tmpAmmoTransform;
  109160. private _tmpAmmoQuaternion;
  109161. private _tmpAmmoConcreteContactResultCallback;
  109162. private _collisionConfiguration;
  109163. private _dispatcher;
  109164. private _overlappingPairCache;
  109165. private _solver;
  109166. private _softBodySolver;
  109167. private _tmpAmmoVectorA;
  109168. private _tmpAmmoVectorB;
  109169. private _tmpAmmoVectorC;
  109170. private _tmpAmmoVectorD;
  109171. private _tmpContactCallbackResult;
  109172. private _tmpAmmoVectorRCA;
  109173. private _tmpAmmoVectorRCB;
  109174. private _raycastResult;
  109175. private static readonly DISABLE_COLLISION_FLAG;
  109176. private static readonly KINEMATIC_FLAG;
  109177. private static readonly DISABLE_DEACTIVATION_FLAG;
  109178. /**
  109179. * Initializes the ammoJS plugin
  109180. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  109181. * @param ammoInjection can be used to inject your own ammo reference
  109182. */
  109183. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  109184. /**
  109185. * Sets the gravity of the physics world (m/(s^2))
  109186. * @param gravity Gravity to set
  109187. */
  109188. setGravity(gravity: Vector3): void;
  109189. /**
  109190. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  109191. * @param timeStep timestep to use in seconds
  109192. */
  109193. setTimeStep(timeStep: number): void;
  109194. /**
  109195. * 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)
  109196. * @param fixedTimeStep fixedTimeStep to use in seconds
  109197. */
  109198. setFixedTimeStep(fixedTimeStep: number): void;
  109199. /**
  109200. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  109201. * @param maxSteps the maximum number of steps by the physics engine per frame
  109202. */
  109203. setMaxSteps(maxSteps: number): void;
  109204. /**
  109205. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  109206. * @returns the current timestep in seconds
  109207. */
  109208. getTimeStep(): number;
  109209. private _isImpostorInContact;
  109210. private _isImpostorPairInContact;
  109211. private _stepSimulation;
  109212. /**
  109213. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  109214. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  109215. * After the step the babylon meshes are set to the position of the physics imposters
  109216. * @param delta amount of time to step forward
  109217. * @param impostors array of imposters to update before/after the step
  109218. */
  109219. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  109220. /**
  109221. * Update babylon mesh vertices vertices to match physics world object
  109222. * @param impostor imposter to match
  109223. */
  109224. afterSoftStep(impostor: PhysicsImpostor): void;
  109225. private _tmpVector;
  109226. private _tmpMatrix;
  109227. /**
  109228. * Applies an impulse on the imposter
  109229. * @param impostor imposter to apply impulse to
  109230. * @param force amount of force to be applied to the imposter
  109231. * @param contactPoint the location to apply the impulse on the imposter
  109232. */
  109233. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  109234. /**
  109235. * Applies a force on the imposter
  109236. * @param impostor imposter to apply force
  109237. * @param force amount of force to be applied to the imposter
  109238. * @param contactPoint the location to apply the force on the imposter
  109239. */
  109240. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  109241. /**
  109242. * Creates a physics body using the plugin
  109243. * @param impostor the imposter to create the physics body on
  109244. */
  109245. generatePhysicsBody(impostor: PhysicsImpostor): void;
  109246. /**
  109247. * Removes the physics body from the imposter and disposes of the body's memory
  109248. * @param impostor imposter to remove the physics body from
  109249. */
  109250. removePhysicsBody(impostor: PhysicsImpostor): void;
  109251. /**
  109252. * Generates a joint
  109253. * @param impostorJoint the imposter joint to create the joint with
  109254. */
  109255. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  109256. /**
  109257. * Removes a joint
  109258. * @param impostorJoint the imposter joint to remove the joint from
  109259. */
  109260. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  109261. private _addMeshVerts;
  109262. /**
  109263. * Initialise the soft body vertices to match its object's (mesh) vertices
  109264. * Softbody vertices (nodes) are in world space and to match this
  109265. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  109266. * @param impostor to create the softbody for
  109267. */
  109268. private _softVertexData;
  109269. /**
  109270. * Create an impostor's soft body
  109271. * @param impostor to create the softbody for
  109272. */
  109273. private _createSoftbody;
  109274. /**
  109275. * Create cloth for an impostor
  109276. * @param impostor to create the softbody for
  109277. */
  109278. private _createCloth;
  109279. private _addHullVerts;
  109280. private _createShape;
  109281. /**
  109282. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  109283. * @param impostor imposter containing the physics body and babylon object
  109284. */
  109285. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  109286. /**
  109287. * Sets the babylon object's position/rotation from the physics body's position/rotation
  109288. * @param impostor imposter containing the physics body and babylon object
  109289. * @param newPosition new position
  109290. * @param newRotation new rotation
  109291. */
  109292. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  109293. /**
  109294. * If this plugin is supported
  109295. * @returns true if its supported
  109296. */
  109297. isSupported(): boolean;
  109298. /**
  109299. * Sets the linear velocity of the physics body
  109300. * @param impostor imposter to set the velocity on
  109301. * @param velocity velocity to set
  109302. */
  109303. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  109304. /**
  109305. * Sets the angular velocity of the physics body
  109306. * @param impostor imposter to set the velocity on
  109307. * @param velocity velocity to set
  109308. */
  109309. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  109310. /**
  109311. * gets the linear velocity
  109312. * @param impostor imposter to get linear velocity from
  109313. * @returns linear velocity
  109314. */
  109315. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  109316. /**
  109317. * gets the angular velocity
  109318. * @param impostor imposter to get angular velocity from
  109319. * @returns angular velocity
  109320. */
  109321. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  109322. /**
  109323. * Sets the mass of physics body
  109324. * @param impostor imposter to set the mass on
  109325. * @param mass mass to set
  109326. */
  109327. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  109328. /**
  109329. * Gets the mass of the physics body
  109330. * @param impostor imposter to get the mass from
  109331. * @returns mass
  109332. */
  109333. getBodyMass(impostor: PhysicsImpostor): number;
  109334. /**
  109335. * Gets friction of the impostor
  109336. * @param impostor impostor to get friction from
  109337. * @returns friction value
  109338. */
  109339. getBodyFriction(impostor: PhysicsImpostor): number;
  109340. /**
  109341. * Sets friction of the impostor
  109342. * @param impostor impostor to set friction on
  109343. * @param friction friction value
  109344. */
  109345. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  109346. /**
  109347. * Gets restitution of the impostor
  109348. * @param impostor impostor to get restitution from
  109349. * @returns restitution value
  109350. */
  109351. getBodyRestitution(impostor: PhysicsImpostor): number;
  109352. /**
  109353. * Sets resitution of the impostor
  109354. * @param impostor impostor to set resitution on
  109355. * @param restitution resitution value
  109356. */
  109357. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  109358. /**
  109359. * Gets pressure inside the impostor
  109360. * @param impostor impostor to get pressure from
  109361. * @returns pressure value
  109362. */
  109363. getBodyPressure(impostor: PhysicsImpostor): number;
  109364. /**
  109365. * Sets pressure inside a soft body impostor
  109366. * Cloth and rope must remain 0 pressure
  109367. * @param impostor impostor to set pressure on
  109368. * @param pressure pressure value
  109369. */
  109370. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  109371. /**
  109372. * Gets stiffness of the impostor
  109373. * @param impostor impostor to get stiffness from
  109374. * @returns pressure value
  109375. */
  109376. getBodyStiffness(impostor: PhysicsImpostor): number;
  109377. /**
  109378. * Sets stiffness of the impostor
  109379. * @param impostor impostor to set stiffness on
  109380. * @param stiffness stiffness value from 0 to 1
  109381. */
  109382. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  109383. /**
  109384. * Gets velocityIterations of the impostor
  109385. * @param impostor impostor to get velocity iterations from
  109386. * @returns velocityIterations value
  109387. */
  109388. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  109389. /**
  109390. * Sets velocityIterations of the impostor
  109391. * @param impostor impostor to set velocity iterations on
  109392. * @param velocityIterations velocityIterations value
  109393. */
  109394. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  109395. /**
  109396. * Gets positionIterations of the impostor
  109397. * @param impostor impostor to get position iterations from
  109398. * @returns positionIterations value
  109399. */
  109400. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  109401. /**
  109402. * Sets positionIterations of the impostor
  109403. * @param impostor impostor to set position on
  109404. * @param positionIterations positionIterations value
  109405. */
  109406. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  109407. /**
  109408. * Append an anchor to a soft object
  109409. * @param impostor soft impostor to add anchor to
  109410. * @param otherImpostor rigid impostor as the anchor
  109411. * @param width ratio across width from 0 to 1
  109412. * @param height ratio up height from 0 to 1
  109413. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, no strech
  109414. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  109415. */
  109416. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  109417. /**
  109418. * Sleeps the physics body and stops it from being active
  109419. * @param impostor impostor to sleep
  109420. */
  109421. sleepBody(impostor: PhysicsImpostor): void;
  109422. /**
  109423. * Activates the physics body
  109424. * @param impostor impostor to activate
  109425. */
  109426. wakeUpBody(impostor: PhysicsImpostor): void;
  109427. /**
  109428. * Updates the distance parameters of the joint
  109429. * @param joint joint to update
  109430. * @param maxDistance maximum distance of the joint
  109431. * @param minDistance minimum distance of the joint
  109432. */
  109433. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  109434. /**
  109435. * Sets a motor on the joint
  109436. * @param joint joint to set motor on
  109437. * @param speed speed of the motor
  109438. * @param maxForce maximum force of the motor
  109439. * @param motorIndex index of the motor
  109440. */
  109441. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  109442. /**
  109443. * Sets the motors limit
  109444. * @param joint joint to set limit on
  109445. * @param upperLimit upper limit
  109446. * @param lowerLimit lower limit
  109447. */
  109448. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  109449. /**
  109450. * Syncs the position and rotation of a mesh with the impostor
  109451. * @param mesh mesh to sync
  109452. * @param impostor impostor to update the mesh with
  109453. */
  109454. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  109455. /**
  109456. * Gets the radius of the impostor
  109457. * @param impostor impostor to get radius from
  109458. * @returns the radius
  109459. */
  109460. getRadius(impostor: PhysicsImpostor): number;
  109461. /**
  109462. * Gets the box size of the impostor
  109463. * @param impostor impostor to get box size from
  109464. * @param result the resulting box size
  109465. */
  109466. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  109467. /**
  109468. * Disposes of the impostor
  109469. */
  109470. dispose(): void;
  109471. /**
  109472. * Does a raycast in the physics world
  109473. * @param from when should the ray start?
  109474. * @param to when should the ray end?
  109475. * @returns PhysicsRaycastResult
  109476. */
  109477. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  109478. }
  109479. }
  109480. declare module BABYLON {
  109481. /** @hidden */
  109482. export var blackAndWhitePixelShader: {
  109483. name: string;
  109484. shader: string;
  109485. };
  109486. }
  109487. declare module BABYLON {
  109488. /**
  109489. * Post process used to render in black and white
  109490. */
  109491. export class BlackAndWhitePostProcess extends PostProcess {
  109492. /**
  109493. * Linear about to convert he result to black and white (default: 1)
  109494. */
  109495. degree: number;
  109496. /**
  109497. * Creates a black and white post process
  109498. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  109499. * @param name The name of the effect.
  109500. * @param options The required width/height ratio to downsize to before computing the render pass.
  109501. * @param camera The camera to apply the render pass to.
  109502. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109503. * @param engine The engine which the post process will be applied. (default: current engine)
  109504. * @param reusable If the post process can be reused on the same frame. (default: false)
  109505. */
  109506. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  109507. }
  109508. }
  109509. declare module BABYLON {
  109510. /**
  109511. * This represents a set of one or more post processes in Babylon.
  109512. * A post process can be used to apply a shader to a texture after it is rendered.
  109513. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109514. */
  109515. export class PostProcessRenderEffect {
  109516. private _postProcesses;
  109517. private _getPostProcesses;
  109518. private _singleInstance;
  109519. private _cameras;
  109520. private _indicesForCamera;
  109521. /**
  109522. * Name of the effect
  109523. * @hidden
  109524. */
  109525. _name: string;
  109526. /**
  109527. * Instantiates a post process render effect.
  109528. * A post process can be used to apply a shader to a texture after it is rendered.
  109529. * @param engine The engine the effect is tied to
  109530. * @param name The name of the effect
  109531. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  109532. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  109533. */
  109534. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  109535. /**
  109536. * Checks if all the post processes in the effect are supported.
  109537. */
  109538. readonly isSupported: boolean;
  109539. /**
  109540. * Updates the current state of the effect
  109541. * @hidden
  109542. */
  109543. _update(): void;
  109544. /**
  109545. * Attaches the effect on cameras
  109546. * @param cameras The camera to attach to.
  109547. * @hidden
  109548. */
  109549. _attachCameras(cameras: Camera): void;
  109550. /**
  109551. * Attaches the effect on cameras
  109552. * @param cameras The camera to attach to.
  109553. * @hidden
  109554. */
  109555. _attachCameras(cameras: Camera[]): void;
  109556. /**
  109557. * Detatches the effect on cameras
  109558. * @param cameras The camera to detatch from.
  109559. * @hidden
  109560. */
  109561. _detachCameras(cameras: Camera): void;
  109562. /**
  109563. * Detatches the effect on cameras
  109564. * @param cameras The camera to detatch from.
  109565. * @hidden
  109566. */
  109567. _detachCameras(cameras: Camera[]): void;
  109568. /**
  109569. * Enables the effect on given cameras
  109570. * @param cameras The camera to enable.
  109571. * @hidden
  109572. */
  109573. _enable(cameras: Camera): void;
  109574. /**
  109575. * Enables the effect on given cameras
  109576. * @param cameras The camera to enable.
  109577. * @hidden
  109578. */
  109579. _enable(cameras: Nullable<Camera[]>): void;
  109580. /**
  109581. * Disables the effect on the given cameras
  109582. * @param cameras The camera to disable.
  109583. * @hidden
  109584. */
  109585. _disable(cameras: Camera): void;
  109586. /**
  109587. * Disables the effect on the given cameras
  109588. * @param cameras The camera to disable.
  109589. * @hidden
  109590. */
  109591. _disable(cameras: Nullable<Camera[]>): void;
  109592. /**
  109593. * Gets a list of the post processes contained in the effect.
  109594. * @param camera The camera to get the post processes on.
  109595. * @returns The list of the post processes in the effect.
  109596. */
  109597. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  109598. }
  109599. }
  109600. declare module BABYLON {
  109601. /** @hidden */
  109602. export var extractHighlightsPixelShader: {
  109603. name: string;
  109604. shader: string;
  109605. };
  109606. }
  109607. declare module BABYLON {
  109608. /**
  109609. * 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.
  109610. */
  109611. export class ExtractHighlightsPostProcess extends PostProcess {
  109612. /**
  109613. * The luminance threshold, pixels below this value will be set to black.
  109614. */
  109615. threshold: number;
  109616. /** @hidden */
  109617. _exposure: number;
  109618. /**
  109619. * Post process which has the input texture to be used when performing highlight extraction
  109620. * @hidden
  109621. */
  109622. _inputPostProcess: Nullable<PostProcess>;
  109623. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109624. }
  109625. }
  109626. declare module BABYLON {
  109627. /** @hidden */
  109628. export var bloomMergePixelShader: {
  109629. name: string;
  109630. shader: string;
  109631. };
  109632. }
  109633. declare module BABYLON {
  109634. /**
  109635. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  109636. */
  109637. export class BloomMergePostProcess extends PostProcess {
  109638. /** Weight of the bloom to be added to the original input. */
  109639. weight: number;
  109640. /**
  109641. * Creates a new instance of @see BloomMergePostProcess
  109642. * @param name The name of the effect.
  109643. * @param originalFromInput Post process which's input will be used for the merge.
  109644. * @param blurred Blurred highlights post process which's output will be used.
  109645. * @param weight Weight of the bloom to be added to the original input.
  109646. * @param options The required width/height ratio to downsize to before computing the render pass.
  109647. * @param camera The camera to apply the render pass to.
  109648. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109649. * @param engine The engine which the post process will be applied. (default: current engine)
  109650. * @param reusable If the post process can be reused on the same frame. (default: false)
  109651. * @param textureType Type of textures used when performing the post process. (default: 0)
  109652. * @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)
  109653. */
  109654. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  109655. /** Weight of the bloom to be added to the original input. */
  109656. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109657. }
  109658. }
  109659. declare module BABYLON {
  109660. /**
  109661. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  109662. */
  109663. export class BloomEffect extends PostProcessRenderEffect {
  109664. private bloomScale;
  109665. /**
  109666. * @hidden Internal
  109667. */
  109668. _effects: Array<PostProcess>;
  109669. /**
  109670. * @hidden Internal
  109671. */
  109672. _downscale: ExtractHighlightsPostProcess;
  109673. private _blurX;
  109674. private _blurY;
  109675. private _merge;
  109676. /**
  109677. * The luminance threshold to find bright areas of the image to bloom.
  109678. */
  109679. threshold: number;
  109680. /**
  109681. * The strength of the bloom.
  109682. */
  109683. weight: number;
  109684. /**
  109685. * Specifies the size of the bloom blur kernel, relative to the final output size
  109686. */
  109687. kernel: number;
  109688. /**
  109689. * Creates a new instance of @see BloomEffect
  109690. * @param scene The scene the effect belongs to.
  109691. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  109692. * @param bloomKernel The size of the kernel to be used when applying the blur.
  109693. * @param bloomWeight The the strength of bloom.
  109694. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  109695. * @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)
  109696. */
  109697. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  109698. /**
  109699. * Disposes each of the internal effects for a given camera.
  109700. * @param camera The camera to dispose the effect on.
  109701. */
  109702. disposeEffects(camera: Camera): void;
  109703. /**
  109704. * @hidden Internal
  109705. */
  109706. _updateEffects(): void;
  109707. /**
  109708. * Internal
  109709. * @returns if all the contained post processes are ready.
  109710. * @hidden
  109711. */
  109712. _isReady(): boolean;
  109713. }
  109714. }
  109715. declare module BABYLON {
  109716. /** @hidden */
  109717. export var chromaticAberrationPixelShader: {
  109718. name: string;
  109719. shader: string;
  109720. };
  109721. }
  109722. declare module BABYLON {
  109723. /**
  109724. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  109725. */
  109726. export class ChromaticAberrationPostProcess extends PostProcess {
  109727. /**
  109728. * The amount of seperation of rgb channels (default: 30)
  109729. */
  109730. aberrationAmount: number;
  109731. /**
  109732. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  109733. */
  109734. radialIntensity: number;
  109735. /**
  109736. * 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))
  109737. */
  109738. direction: Vector2;
  109739. /**
  109740. * 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))
  109741. */
  109742. centerPosition: Vector2;
  109743. /**
  109744. * Creates a new instance ChromaticAberrationPostProcess
  109745. * @param name The name of the effect.
  109746. * @param screenWidth The width of the screen to apply the effect on.
  109747. * @param screenHeight The height of the screen to apply the effect on.
  109748. * @param options The required width/height ratio to downsize to before computing the render pass.
  109749. * @param camera The camera to apply the render pass to.
  109750. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109751. * @param engine The engine which the post process will be applied. (default: current engine)
  109752. * @param reusable If the post process can be reused on the same frame. (default: false)
  109753. * @param textureType Type of textures used when performing the post process. (default: 0)
  109754. * @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)
  109755. */
  109756. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109757. }
  109758. }
  109759. declare module BABYLON {
  109760. /** @hidden */
  109761. export var circleOfConfusionPixelShader: {
  109762. name: string;
  109763. shader: string;
  109764. };
  109765. }
  109766. declare module BABYLON {
  109767. /**
  109768. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  109769. */
  109770. export class CircleOfConfusionPostProcess extends PostProcess {
  109771. /**
  109772. * 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.
  109773. */
  109774. lensSize: number;
  109775. /**
  109776. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  109777. */
  109778. fStop: number;
  109779. /**
  109780. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  109781. */
  109782. focusDistance: number;
  109783. /**
  109784. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  109785. */
  109786. focalLength: number;
  109787. private _depthTexture;
  109788. /**
  109789. * Creates a new instance CircleOfConfusionPostProcess
  109790. * @param name The name of the effect.
  109791. * @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.
  109792. * @param options The required width/height ratio to downsize to before computing the render pass.
  109793. * @param camera The camera to apply the render pass to.
  109794. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109795. * @param engine The engine which the post process will be applied. (default: current engine)
  109796. * @param reusable If the post process can be reused on the same frame. (default: false)
  109797. * @param textureType Type of textures used when performing the post process. (default: 0)
  109798. * @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)
  109799. */
  109800. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109801. /**
  109802. * 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.
  109803. */
  109804. depthTexture: RenderTargetTexture;
  109805. }
  109806. }
  109807. declare module BABYLON {
  109808. /** @hidden */
  109809. export var colorCorrectionPixelShader: {
  109810. name: string;
  109811. shader: string;
  109812. };
  109813. }
  109814. declare module BABYLON {
  109815. /**
  109816. *
  109817. * This post-process allows the modification of rendered colors by using
  109818. * a 'look-up table' (LUT). This effect is also called Color Grading.
  109819. *
  109820. * The object needs to be provided an url to a texture containing the color
  109821. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  109822. * Use an image editing software to tweak the LUT to match your needs.
  109823. *
  109824. * For an example of a color LUT, see here:
  109825. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  109826. * For explanations on color grading, see here:
  109827. * @see http://udn.epicgames.com/Three/ColorGrading.html
  109828. *
  109829. */
  109830. export class ColorCorrectionPostProcess extends PostProcess {
  109831. private _colorTableTexture;
  109832. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  109833. }
  109834. }
  109835. declare module BABYLON {
  109836. /** @hidden */
  109837. export var convolutionPixelShader: {
  109838. name: string;
  109839. shader: string;
  109840. };
  109841. }
  109842. declare module BABYLON {
  109843. /**
  109844. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  109845. * input texture to perform effects such as edge detection or sharpening
  109846. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  109847. */
  109848. export class ConvolutionPostProcess extends PostProcess {
  109849. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  109850. kernel: number[];
  109851. /**
  109852. * Creates a new instance ConvolutionPostProcess
  109853. * @param name The name of the effect.
  109854. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  109855. * @param options The required width/height ratio to downsize to before computing the render pass.
  109856. * @param camera The camera to apply the render pass to.
  109857. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109858. * @param engine The engine which the post process will be applied. (default: current engine)
  109859. * @param reusable If the post process can be reused on the same frame. (default: false)
  109860. * @param textureType Type of textures used when performing the post process. (default: 0)
  109861. */
  109862. constructor(name: string,
  109863. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  109864. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  109865. /**
  109866. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  109867. */
  109868. static EdgeDetect0Kernel: number[];
  109869. /**
  109870. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  109871. */
  109872. static EdgeDetect1Kernel: number[];
  109873. /**
  109874. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  109875. */
  109876. static EdgeDetect2Kernel: number[];
  109877. /**
  109878. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  109879. */
  109880. static SharpenKernel: number[];
  109881. /**
  109882. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  109883. */
  109884. static EmbossKernel: number[];
  109885. /**
  109886. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  109887. */
  109888. static GaussianKernel: number[];
  109889. }
  109890. }
  109891. declare module BABYLON {
  109892. /**
  109893. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  109894. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  109895. * based on samples that have a large difference in distance than the center pixel.
  109896. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  109897. */
  109898. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  109899. direction: Vector2;
  109900. /**
  109901. * Creates a new instance CircleOfConfusionPostProcess
  109902. * @param name The name of the effect.
  109903. * @param scene The scene the effect belongs to.
  109904. * @param direction The direction the blur should be applied.
  109905. * @param kernel The size of the kernel used to blur.
  109906. * @param options The required width/height ratio to downsize to before computing the render pass.
  109907. * @param camera The camera to apply the render pass to.
  109908. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  109909. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  109910. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109911. * @param engine The engine which the post process will be applied. (default: current engine)
  109912. * @param reusable If the post process can be reused on the same frame. (default: false)
  109913. * @param textureType Type of textures used when performing the post process. (default: 0)
  109914. * @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)
  109915. */
  109916. 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);
  109917. }
  109918. }
  109919. declare module BABYLON {
  109920. /** @hidden */
  109921. export var depthOfFieldMergePixelShader: {
  109922. name: string;
  109923. shader: string;
  109924. };
  109925. }
  109926. declare module BABYLON {
  109927. /**
  109928. * Options to be set when merging outputs from the default pipeline.
  109929. */
  109930. export class DepthOfFieldMergePostProcessOptions {
  109931. /**
  109932. * The original image to merge on top of
  109933. */
  109934. originalFromInput: PostProcess;
  109935. /**
  109936. * Parameters to perform the merge of the depth of field effect
  109937. */
  109938. depthOfField?: {
  109939. circleOfConfusion: PostProcess;
  109940. blurSteps: Array<PostProcess>;
  109941. };
  109942. /**
  109943. * Parameters to perform the merge of bloom effect
  109944. */
  109945. bloom?: {
  109946. blurred: PostProcess;
  109947. weight: number;
  109948. };
  109949. }
  109950. /**
  109951. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  109952. */
  109953. export class DepthOfFieldMergePostProcess extends PostProcess {
  109954. private blurSteps;
  109955. /**
  109956. * Creates a new instance of DepthOfFieldMergePostProcess
  109957. * @param name The name of the effect.
  109958. * @param originalFromInput Post process which's input will be used for the merge.
  109959. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  109960. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  109961. * @param options The required width/height ratio to downsize to before computing the render pass.
  109962. * @param camera The camera to apply the render pass to.
  109963. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109964. * @param engine The engine which the post process will be applied. (default: current engine)
  109965. * @param reusable If the post process can be reused on the same frame. (default: false)
  109966. * @param textureType Type of textures used when performing the post process. (default: 0)
  109967. * @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)
  109968. */
  109969. 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);
  109970. /**
  109971. * Updates the effect with the current post process compile time values and recompiles the shader.
  109972. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  109973. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  109974. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  109975. * @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
  109976. * @param onCompiled Called when the shader has been compiled.
  109977. * @param onError Called if there is an error when compiling a shader.
  109978. */
  109979. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  109980. }
  109981. }
  109982. declare module BABYLON {
  109983. /**
  109984. * Specifies the level of max blur that should be applied when using the depth of field effect
  109985. */
  109986. export enum DepthOfFieldEffectBlurLevel {
  109987. /**
  109988. * Subtle blur
  109989. */
  109990. Low = 0,
  109991. /**
  109992. * Medium blur
  109993. */
  109994. Medium = 1,
  109995. /**
  109996. * Large blur
  109997. */
  109998. High = 2
  109999. }
  110000. /**
  110001. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  110002. */
  110003. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  110004. private _circleOfConfusion;
  110005. /**
  110006. * @hidden Internal, blurs from high to low
  110007. */
  110008. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  110009. private _depthOfFieldBlurY;
  110010. private _dofMerge;
  110011. /**
  110012. * @hidden Internal post processes in depth of field effect
  110013. */
  110014. _effects: Array<PostProcess>;
  110015. /**
  110016. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  110017. */
  110018. focalLength: number;
  110019. /**
  110020. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  110021. */
  110022. fStop: number;
  110023. /**
  110024. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  110025. */
  110026. focusDistance: number;
  110027. /**
  110028. * 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.
  110029. */
  110030. lensSize: number;
  110031. /**
  110032. * Creates a new instance DepthOfFieldEffect
  110033. * @param scene The scene the effect belongs to.
  110034. * @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.
  110035. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  110036. * @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)
  110037. */
  110038. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  110039. /**
  110040. * 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.
  110041. */
  110042. depthTexture: RenderTargetTexture;
  110043. /**
  110044. * Disposes each of the internal effects for a given camera.
  110045. * @param camera The camera to dispose the effect on.
  110046. */
  110047. disposeEffects(camera: Camera): void;
  110048. /**
  110049. * @hidden Internal
  110050. */
  110051. _updateEffects(): void;
  110052. /**
  110053. * Internal
  110054. * @returns if all the contained post processes are ready.
  110055. * @hidden
  110056. */
  110057. _isReady(): boolean;
  110058. }
  110059. }
  110060. declare module BABYLON {
  110061. /** @hidden */
  110062. export var displayPassPixelShader: {
  110063. name: string;
  110064. shader: string;
  110065. };
  110066. }
  110067. declare module BABYLON {
  110068. /**
  110069. * DisplayPassPostProcess which produces an output the same as it's input
  110070. */
  110071. export class DisplayPassPostProcess extends PostProcess {
  110072. /**
  110073. * Creates the DisplayPassPostProcess
  110074. * @param name The name of the effect.
  110075. * @param options The required width/height ratio to downsize to before computing the render pass.
  110076. * @param camera The camera to apply the render pass to.
  110077. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110078. * @param engine The engine which the post process will be applied. (default: current engine)
  110079. * @param reusable If the post process can be reused on the same frame. (default: false)
  110080. */
  110081. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  110082. }
  110083. }
  110084. declare module BABYLON {
  110085. /** @hidden */
  110086. export var filterPixelShader: {
  110087. name: string;
  110088. shader: string;
  110089. };
  110090. }
  110091. declare module BABYLON {
  110092. /**
  110093. * Applies a kernel filter to the image
  110094. */
  110095. export class FilterPostProcess extends PostProcess {
  110096. /** The matrix to be applied to the image */
  110097. kernelMatrix: Matrix;
  110098. /**
  110099. *
  110100. * @param name The name of the effect.
  110101. * @param kernelMatrix The matrix to be applied to the image
  110102. * @param options The required width/height ratio to downsize to before computing the render pass.
  110103. * @param camera The camera to apply the render pass to.
  110104. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110105. * @param engine The engine which the post process will be applied. (default: current engine)
  110106. * @param reusable If the post process can be reused on the same frame. (default: false)
  110107. */
  110108. constructor(name: string,
  110109. /** The matrix to be applied to the image */
  110110. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  110111. }
  110112. }
  110113. declare module BABYLON {
  110114. /** @hidden */
  110115. export var fxaaPixelShader: {
  110116. name: string;
  110117. shader: string;
  110118. };
  110119. }
  110120. declare module BABYLON {
  110121. /** @hidden */
  110122. export var fxaaVertexShader: {
  110123. name: string;
  110124. shader: string;
  110125. };
  110126. }
  110127. declare module BABYLON {
  110128. /**
  110129. * Fxaa post process
  110130. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  110131. */
  110132. export class FxaaPostProcess extends PostProcess {
  110133. /** @hidden */
  110134. texelWidth: number;
  110135. /** @hidden */
  110136. texelHeight: number;
  110137. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  110138. private _getDefines;
  110139. }
  110140. }
  110141. declare module BABYLON {
  110142. /** @hidden */
  110143. export var grainPixelShader: {
  110144. name: string;
  110145. shader: string;
  110146. };
  110147. }
  110148. declare module BABYLON {
  110149. /**
  110150. * The GrainPostProcess adds noise to the image at mid luminance levels
  110151. */
  110152. export class GrainPostProcess extends PostProcess {
  110153. /**
  110154. * The intensity of the grain added (default: 30)
  110155. */
  110156. intensity: number;
  110157. /**
  110158. * If the grain should be randomized on every frame
  110159. */
  110160. animated: boolean;
  110161. /**
  110162. * Creates a new instance of @see GrainPostProcess
  110163. * @param name The name of the effect.
  110164. * @param options The required width/height ratio to downsize to before computing the render pass.
  110165. * @param camera The camera to apply the render pass to.
  110166. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110167. * @param engine The engine which the post process will be applied. (default: current engine)
  110168. * @param reusable If the post process can be reused on the same frame. (default: false)
  110169. * @param textureType Type of textures used when performing the post process. (default: 0)
  110170. * @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)
  110171. */
  110172. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  110173. }
  110174. }
  110175. declare module BABYLON {
  110176. /** @hidden */
  110177. export var highlightsPixelShader: {
  110178. name: string;
  110179. shader: string;
  110180. };
  110181. }
  110182. declare module BABYLON {
  110183. /**
  110184. * Extracts highlights from the image
  110185. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  110186. */
  110187. export class HighlightsPostProcess extends PostProcess {
  110188. /**
  110189. * Extracts highlights from the image
  110190. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  110191. * @param name The name of the effect.
  110192. * @param options The required width/height ratio to downsize to before computing the render pass.
  110193. * @param camera The camera to apply the render pass to.
  110194. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110195. * @param engine The engine which the post process will be applied. (default: current engine)
  110196. * @param reusable If the post process can be reused on the same frame. (default: false)
  110197. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  110198. */
  110199. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  110200. }
  110201. }
  110202. declare module BABYLON {
  110203. /** @hidden */
  110204. export var mrtFragmentDeclaration: {
  110205. name: string;
  110206. shader: string;
  110207. };
  110208. }
  110209. declare module BABYLON {
  110210. /** @hidden */
  110211. export var geometryPixelShader: {
  110212. name: string;
  110213. shader: string;
  110214. };
  110215. }
  110216. declare module BABYLON {
  110217. /** @hidden */
  110218. export var geometryVertexShader: {
  110219. name: string;
  110220. shader: string;
  110221. };
  110222. }
  110223. declare module BABYLON {
  110224. /**
  110225. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  110226. */
  110227. export class GeometryBufferRenderer {
  110228. /**
  110229. * Constant used to retrieve the position texture index in the G-Buffer textures array
  110230. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  110231. */
  110232. static readonly POSITION_TEXTURE_TYPE: number;
  110233. /**
  110234. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  110235. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  110236. */
  110237. static readonly VELOCITY_TEXTURE_TYPE: number;
  110238. /**
  110239. * Dictionary used to store the previous transformation matrices of each rendered mesh
  110240. * in order to compute objects velocities when enableVelocity is set to "true"
  110241. * @hidden
  110242. */
  110243. _previousTransformationMatrices: {
  110244. [index: number]: Matrix;
  110245. };
  110246. private _scene;
  110247. private _multiRenderTarget;
  110248. private _ratio;
  110249. private _enablePosition;
  110250. private _enableVelocity;
  110251. private _positionIndex;
  110252. private _velocityIndex;
  110253. protected _effect: Effect;
  110254. protected _cachedDefines: string;
  110255. /**
  110256. * Set the render list (meshes to be rendered) used in the G buffer.
  110257. */
  110258. renderList: Mesh[];
  110259. /**
  110260. * Gets wether or not G buffer are supported by the running hardware.
  110261. * This requires draw buffer supports
  110262. */
  110263. readonly isSupported: boolean;
  110264. /**
  110265. * Returns the index of the given texture type in the G-Buffer textures array
  110266. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  110267. * @returns the index of the given texture type in the G-Buffer textures array
  110268. */
  110269. getTextureIndex(textureType: number): number;
  110270. /**
  110271. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  110272. */
  110273. /**
  110274. * Sets whether or not objects positions are enabled for the G buffer.
  110275. */
  110276. enablePosition: boolean;
  110277. /**
  110278. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  110279. */
  110280. /**
  110281. * Sets wether or not objects velocities are enabled for the G buffer.
  110282. */
  110283. enableVelocity: boolean;
  110284. /**
  110285. * Gets the scene associated with the buffer.
  110286. */
  110287. readonly scene: Scene;
  110288. /**
  110289. * Gets the ratio used by the buffer during its creation.
  110290. * How big is the buffer related to the main canvas.
  110291. */
  110292. readonly ratio: number;
  110293. /** @hidden */
  110294. static _SceneComponentInitialization: (scene: Scene) => void;
  110295. /**
  110296. * Creates a new G Buffer for the scene
  110297. * @param scene The scene the buffer belongs to
  110298. * @param ratio How big is the buffer related to the main canvas.
  110299. */
  110300. constructor(scene: Scene, ratio?: number);
  110301. /**
  110302. * Checks wether everything is ready to render a submesh to the G buffer.
  110303. * @param subMesh the submesh to check readiness for
  110304. * @param useInstances is the mesh drawn using instance or not
  110305. * @returns true if ready otherwise false
  110306. */
  110307. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110308. /**
  110309. * Gets the current underlying G Buffer.
  110310. * @returns the buffer
  110311. */
  110312. getGBuffer(): MultiRenderTarget;
  110313. /**
  110314. * Gets the number of samples used to render the buffer (anti aliasing).
  110315. */
  110316. /**
  110317. * Sets the number of samples used to render the buffer (anti aliasing).
  110318. */
  110319. samples: number;
  110320. /**
  110321. * Disposes the renderer and frees up associated resources.
  110322. */
  110323. dispose(): void;
  110324. protected _createRenderTargets(): void;
  110325. }
  110326. }
  110327. declare module BABYLON {
  110328. interface Scene {
  110329. /** @hidden (Backing field) */
  110330. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  110331. /**
  110332. * Gets or Sets the current geometry buffer associated to the scene.
  110333. */
  110334. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  110335. /**
  110336. * Enables a GeometryBufferRender and associates it with the scene
  110337. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  110338. * @returns the GeometryBufferRenderer
  110339. */
  110340. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  110341. /**
  110342. * Disables the GeometryBufferRender associated with the scene
  110343. */
  110344. disableGeometryBufferRenderer(): void;
  110345. }
  110346. /**
  110347. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  110348. * in several rendering techniques.
  110349. */
  110350. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  110351. /**
  110352. * The component name helpful to identify the component in the list of scene components.
  110353. */
  110354. readonly name: string;
  110355. /**
  110356. * The scene the component belongs to.
  110357. */
  110358. scene: Scene;
  110359. /**
  110360. * Creates a new instance of the component for the given scene
  110361. * @param scene Defines the scene to register the component in
  110362. */
  110363. constructor(scene: Scene);
  110364. /**
  110365. * Registers the component in a given scene
  110366. */
  110367. register(): void;
  110368. /**
  110369. * Rebuilds the elements related to this component in case of
  110370. * context lost for instance.
  110371. */
  110372. rebuild(): void;
  110373. /**
  110374. * Disposes the component and the associated ressources
  110375. */
  110376. dispose(): void;
  110377. private _gatherRenderTargets;
  110378. }
  110379. }
  110380. declare module BABYLON {
  110381. /** @hidden */
  110382. export var motionBlurPixelShader: {
  110383. name: string;
  110384. shader: string;
  110385. };
  110386. }
  110387. declare module BABYLON {
  110388. /**
  110389. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  110390. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  110391. * As an example, all you have to do is to create the post-process:
  110392. * var mb = new BABYLON.MotionBlurPostProcess(
  110393. * 'mb', // The name of the effect.
  110394. * scene, // The scene containing the objects to blur according to their velocity.
  110395. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  110396. * camera // The camera to apply the render pass to.
  110397. * );
  110398. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  110399. */
  110400. export class MotionBlurPostProcess extends PostProcess {
  110401. /**
  110402. * Defines how much the image is blurred by the movement. Default value is equal to 1
  110403. */
  110404. motionStrength: number;
  110405. /**
  110406. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  110407. */
  110408. /**
  110409. * Sets the number of iterations to be used for motion blur quality
  110410. */
  110411. motionBlurSamples: number;
  110412. private _motionBlurSamples;
  110413. private _geometryBufferRenderer;
  110414. /**
  110415. * Creates a new instance MotionBlurPostProcess
  110416. * @param name The name of the effect.
  110417. * @param scene The scene containing the objects to blur according to their velocity.
  110418. * @param options The required width/height ratio to downsize to before computing the render pass.
  110419. * @param camera The camera to apply the render pass to.
  110420. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110421. * @param engine The engine which the post process will be applied. (default: current engine)
  110422. * @param reusable If the post process can be reused on the same frame. (default: false)
  110423. * @param textureType Type of textures used when performing the post process. (default: 0)
  110424. * @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)
  110425. */
  110426. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  110427. /**
  110428. * Disposes the post process.
  110429. * @param camera The camera to dispose the post process on.
  110430. */
  110431. dispose(camera?: Camera): void;
  110432. }
  110433. }
  110434. declare module BABYLON {
  110435. /** @hidden */
  110436. export var refractionPixelShader: {
  110437. name: string;
  110438. shader: string;
  110439. };
  110440. }
  110441. declare module BABYLON {
  110442. /**
  110443. * Post process which applies a refractin texture
  110444. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  110445. */
  110446. export class RefractionPostProcess extends PostProcess {
  110447. /** the base color of the refraction (used to taint the rendering) */
  110448. color: Color3;
  110449. /** simulated refraction depth */
  110450. depth: number;
  110451. /** the coefficient of the base color (0 to remove base color tainting) */
  110452. colorLevel: number;
  110453. private _refTexture;
  110454. private _ownRefractionTexture;
  110455. /**
  110456. * Gets or sets the refraction texture
  110457. * Please note that you are responsible for disposing the texture if you set it manually
  110458. */
  110459. refractionTexture: Texture;
  110460. /**
  110461. * Initializes the RefractionPostProcess
  110462. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  110463. * @param name The name of the effect.
  110464. * @param refractionTextureUrl Url of the refraction texture to use
  110465. * @param color the base color of the refraction (used to taint the rendering)
  110466. * @param depth simulated refraction depth
  110467. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  110468. * @param camera The camera to apply the render pass to.
  110469. * @param options The required width/height ratio to downsize to before computing the render pass.
  110470. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110471. * @param engine The engine which the post process will be applied. (default: current engine)
  110472. * @param reusable If the post process can be reused on the same frame. (default: false)
  110473. */
  110474. constructor(name: string, refractionTextureUrl: string,
  110475. /** the base color of the refraction (used to taint the rendering) */
  110476. color: Color3,
  110477. /** simulated refraction depth */
  110478. depth: number,
  110479. /** the coefficient of the base color (0 to remove base color tainting) */
  110480. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  110481. /**
  110482. * Disposes of the post process
  110483. * @param camera Camera to dispose post process on
  110484. */
  110485. dispose(camera: Camera): void;
  110486. }
  110487. }
  110488. declare module BABYLON {
  110489. /** @hidden */
  110490. export var sharpenPixelShader: {
  110491. name: string;
  110492. shader: string;
  110493. };
  110494. }
  110495. declare module BABYLON {
  110496. /**
  110497. * The SharpenPostProcess applies a sharpen kernel to every pixel
  110498. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  110499. */
  110500. export class SharpenPostProcess extends PostProcess {
  110501. /**
  110502. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  110503. */
  110504. colorAmount: number;
  110505. /**
  110506. * How much sharpness should be applied (default: 0.3)
  110507. */
  110508. edgeAmount: number;
  110509. /**
  110510. * Creates a new instance ConvolutionPostProcess
  110511. * @param name The name of the effect.
  110512. * @param options The required width/height ratio to downsize to before computing the render pass.
  110513. * @param camera The camera to apply the render pass to.
  110514. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110515. * @param engine The engine which the post process will be applied. (default: current engine)
  110516. * @param reusable If the post process can be reused on the same frame. (default: false)
  110517. * @param textureType Type of textures used when performing the post process. (default: 0)
  110518. * @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)
  110519. */
  110520. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  110521. }
  110522. }
  110523. declare module BABYLON {
  110524. /**
  110525. * PostProcessRenderPipeline
  110526. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  110527. */
  110528. export class PostProcessRenderPipeline {
  110529. private engine;
  110530. private _renderEffects;
  110531. private _renderEffectsForIsolatedPass;
  110532. /**
  110533. * List of inspectable custom properties (used by the Inspector)
  110534. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  110535. */
  110536. inspectableCustomProperties: IInspectable[];
  110537. /**
  110538. * @hidden
  110539. */
  110540. protected _cameras: Camera[];
  110541. /** @hidden */
  110542. _name: string;
  110543. /**
  110544. * Gets pipeline name
  110545. */
  110546. readonly name: string;
  110547. /**
  110548. * Initializes a PostProcessRenderPipeline
  110549. * @param engine engine to add the pipeline to
  110550. * @param name name of the pipeline
  110551. */
  110552. constructor(engine: Engine, name: string);
  110553. /**
  110554. * Gets the class name
  110555. * @returns "PostProcessRenderPipeline"
  110556. */
  110557. getClassName(): string;
  110558. /**
  110559. * If all the render effects in the pipeline are supported
  110560. */
  110561. readonly isSupported: boolean;
  110562. /**
  110563. * Adds an effect to the pipeline
  110564. * @param renderEffect the effect to add
  110565. */
  110566. addEffect(renderEffect: PostProcessRenderEffect): void;
  110567. /** @hidden */
  110568. _rebuild(): void;
  110569. /** @hidden */
  110570. _enableEffect(renderEffectName: string, cameras: Camera): void;
  110571. /** @hidden */
  110572. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  110573. /** @hidden */
  110574. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  110575. /** @hidden */
  110576. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  110577. /** @hidden */
  110578. _attachCameras(cameras: Camera, unique: boolean): void;
  110579. /** @hidden */
  110580. _attachCameras(cameras: Camera[], unique: boolean): void;
  110581. /** @hidden */
  110582. _detachCameras(cameras: Camera): void;
  110583. /** @hidden */
  110584. _detachCameras(cameras: Nullable<Camera[]>): void;
  110585. /** @hidden */
  110586. _update(): void;
  110587. /** @hidden */
  110588. _reset(): void;
  110589. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  110590. /**
  110591. * Disposes of the pipeline
  110592. */
  110593. dispose(): void;
  110594. }
  110595. }
  110596. declare module BABYLON {
  110597. /**
  110598. * PostProcessRenderPipelineManager class
  110599. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  110600. */
  110601. export class PostProcessRenderPipelineManager {
  110602. private _renderPipelines;
  110603. /**
  110604. * Initializes a PostProcessRenderPipelineManager
  110605. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  110606. */
  110607. constructor();
  110608. /**
  110609. * Gets the list of supported render pipelines
  110610. */
  110611. readonly supportedPipelines: PostProcessRenderPipeline[];
  110612. /**
  110613. * Adds a pipeline to the manager
  110614. * @param renderPipeline The pipeline to add
  110615. */
  110616. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  110617. /**
  110618. * Attaches a camera to the pipeline
  110619. * @param renderPipelineName The name of the pipeline to attach to
  110620. * @param cameras the camera to attach
  110621. * @param unique if the camera can be attached multiple times to the pipeline
  110622. */
  110623. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  110624. /**
  110625. * Detaches a camera from the pipeline
  110626. * @param renderPipelineName The name of the pipeline to detach from
  110627. * @param cameras the camera to detach
  110628. */
  110629. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  110630. /**
  110631. * Enables an effect by name on a pipeline
  110632. * @param renderPipelineName the name of the pipeline to enable the effect in
  110633. * @param renderEffectName the name of the effect to enable
  110634. * @param cameras the cameras that the effect should be enabled on
  110635. */
  110636. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  110637. /**
  110638. * Disables an effect by name on a pipeline
  110639. * @param renderPipelineName the name of the pipeline to disable the effect in
  110640. * @param renderEffectName the name of the effect to disable
  110641. * @param cameras the cameras that the effect should be disabled on
  110642. */
  110643. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  110644. /**
  110645. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  110646. */
  110647. update(): void;
  110648. /** @hidden */
  110649. _rebuild(): void;
  110650. /**
  110651. * Disposes of the manager and pipelines
  110652. */
  110653. dispose(): void;
  110654. }
  110655. }
  110656. declare module BABYLON {
  110657. interface Scene {
  110658. /** @hidden (Backing field) */
  110659. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  110660. /**
  110661. * Gets the postprocess render pipeline manager
  110662. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  110663. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  110664. */
  110665. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  110666. }
  110667. /**
  110668. * Defines the Render Pipeline scene component responsible to rendering pipelines
  110669. */
  110670. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  110671. /**
  110672. * The component name helpfull to identify the component in the list of scene components.
  110673. */
  110674. readonly name: string;
  110675. /**
  110676. * The scene the component belongs to.
  110677. */
  110678. scene: Scene;
  110679. /**
  110680. * Creates a new instance of the component for the given scene
  110681. * @param scene Defines the scene to register the component in
  110682. */
  110683. constructor(scene: Scene);
  110684. /**
  110685. * Registers the component in a given scene
  110686. */
  110687. register(): void;
  110688. /**
  110689. * Rebuilds the elements related to this component in case of
  110690. * context lost for instance.
  110691. */
  110692. rebuild(): void;
  110693. /**
  110694. * Disposes the component and the associated ressources
  110695. */
  110696. dispose(): void;
  110697. private _gatherRenderTargets;
  110698. }
  110699. }
  110700. declare module BABYLON {
  110701. /**
  110702. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  110703. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  110704. */
  110705. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  110706. private _scene;
  110707. private _camerasToBeAttached;
  110708. /**
  110709. * ID of the sharpen post process,
  110710. */
  110711. private readonly SharpenPostProcessId;
  110712. /**
  110713. * @ignore
  110714. * ID of the image processing post process;
  110715. */
  110716. readonly ImageProcessingPostProcessId: string;
  110717. /**
  110718. * @ignore
  110719. * ID of the Fast Approximate Anti-Aliasing post process;
  110720. */
  110721. readonly FxaaPostProcessId: string;
  110722. /**
  110723. * ID of the chromatic aberration post process,
  110724. */
  110725. private readonly ChromaticAberrationPostProcessId;
  110726. /**
  110727. * ID of the grain post process
  110728. */
  110729. private readonly GrainPostProcessId;
  110730. /**
  110731. * Sharpen post process which will apply a sharpen convolution to enhance edges
  110732. */
  110733. sharpen: SharpenPostProcess;
  110734. private _sharpenEffect;
  110735. private bloom;
  110736. /**
  110737. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  110738. */
  110739. depthOfField: DepthOfFieldEffect;
  110740. /**
  110741. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  110742. */
  110743. fxaa: FxaaPostProcess;
  110744. /**
  110745. * Image post processing pass used to perform operations such as tone mapping or color grading.
  110746. */
  110747. imageProcessing: ImageProcessingPostProcess;
  110748. /**
  110749. * Chromatic aberration post process which will shift rgb colors in the image
  110750. */
  110751. chromaticAberration: ChromaticAberrationPostProcess;
  110752. private _chromaticAberrationEffect;
  110753. /**
  110754. * Grain post process which add noise to the image
  110755. */
  110756. grain: GrainPostProcess;
  110757. private _grainEffect;
  110758. /**
  110759. * Glow post process which adds a glow to emissive areas of the image
  110760. */
  110761. private _glowLayer;
  110762. /**
  110763. * Animations which can be used to tweak settings over a period of time
  110764. */
  110765. animations: Animation[];
  110766. private _imageProcessingConfigurationObserver;
  110767. private _sharpenEnabled;
  110768. private _bloomEnabled;
  110769. private _depthOfFieldEnabled;
  110770. private _depthOfFieldBlurLevel;
  110771. private _fxaaEnabled;
  110772. private _imageProcessingEnabled;
  110773. private _defaultPipelineTextureType;
  110774. private _bloomScale;
  110775. private _chromaticAberrationEnabled;
  110776. private _grainEnabled;
  110777. private _buildAllowed;
  110778. /**
  110779. * Gets active scene
  110780. */
  110781. readonly scene: Scene;
  110782. /**
  110783. * Enable or disable the sharpen process from the pipeline
  110784. */
  110785. sharpenEnabled: boolean;
  110786. private _resizeObserver;
  110787. private _hardwareScaleLevel;
  110788. private _bloomKernel;
  110789. /**
  110790. * Specifies the size of the bloom blur kernel, relative to the final output size
  110791. */
  110792. bloomKernel: number;
  110793. /**
  110794. * Specifies the weight of the bloom in the final rendering
  110795. */
  110796. private _bloomWeight;
  110797. /**
  110798. * Specifies the luma threshold for the area that will be blurred by the bloom
  110799. */
  110800. private _bloomThreshold;
  110801. private _hdr;
  110802. /**
  110803. * The strength of the bloom.
  110804. */
  110805. bloomWeight: number;
  110806. /**
  110807. * The strength of the bloom.
  110808. */
  110809. bloomThreshold: number;
  110810. /**
  110811. * The scale of the bloom, lower value will provide better performance.
  110812. */
  110813. bloomScale: number;
  110814. /**
  110815. * Enable or disable the bloom from the pipeline
  110816. */
  110817. bloomEnabled: boolean;
  110818. private _rebuildBloom;
  110819. /**
  110820. * If the depth of field is enabled.
  110821. */
  110822. depthOfFieldEnabled: boolean;
  110823. /**
  110824. * Blur level of the depth of field effect. (Higher blur will effect performance)
  110825. */
  110826. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  110827. /**
  110828. * If the anti aliasing is enabled.
  110829. */
  110830. fxaaEnabled: boolean;
  110831. private _samples;
  110832. /**
  110833. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  110834. */
  110835. samples: number;
  110836. /**
  110837. * If image processing is enabled.
  110838. */
  110839. imageProcessingEnabled: boolean;
  110840. /**
  110841. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  110842. */
  110843. glowLayerEnabled: boolean;
  110844. /**
  110845. * Enable or disable the chromaticAberration process from the pipeline
  110846. */
  110847. chromaticAberrationEnabled: boolean;
  110848. /**
  110849. * Enable or disable the grain process from the pipeline
  110850. */
  110851. grainEnabled: boolean;
  110852. /**
  110853. * @constructor
  110854. * @param name - The rendering pipeline name (default: "")
  110855. * @param hdr - If high dynamic range textures should be used (default: true)
  110856. * @param scene - The scene linked to this pipeline (default: the last created scene)
  110857. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  110858. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  110859. */
  110860. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  110861. /**
  110862. * Get the class name
  110863. * @returns "DefaultRenderingPipeline"
  110864. */
  110865. getClassName(): string;
  110866. /**
  110867. * Force the compilation of the entire pipeline.
  110868. */
  110869. prepare(): void;
  110870. private _hasCleared;
  110871. private _prevPostProcess;
  110872. private _prevPrevPostProcess;
  110873. private _setAutoClearAndTextureSharing;
  110874. private _depthOfFieldSceneObserver;
  110875. private _buildPipeline;
  110876. private _disposePostProcesses;
  110877. /**
  110878. * Adds a camera to the pipeline
  110879. * @param camera the camera to be added
  110880. */
  110881. addCamera(camera: Camera): void;
  110882. /**
  110883. * Removes a camera from the pipeline
  110884. * @param camera the camera to remove
  110885. */
  110886. removeCamera(camera: Camera): void;
  110887. /**
  110888. * Dispose of the pipeline and stop all post processes
  110889. */
  110890. dispose(): void;
  110891. /**
  110892. * Serialize the rendering pipeline (Used when exporting)
  110893. * @returns the serialized object
  110894. */
  110895. serialize(): any;
  110896. /**
  110897. * Parse the serialized pipeline
  110898. * @param source Source pipeline.
  110899. * @param scene The scene to load the pipeline to.
  110900. * @param rootUrl The URL of the serialized pipeline.
  110901. * @returns An instantiated pipeline from the serialized object.
  110902. */
  110903. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  110904. }
  110905. }
  110906. declare module BABYLON {
  110907. /** @hidden */
  110908. export var lensHighlightsPixelShader: {
  110909. name: string;
  110910. shader: string;
  110911. };
  110912. }
  110913. declare module BABYLON {
  110914. /** @hidden */
  110915. export var depthOfFieldPixelShader: {
  110916. name: string;
  110917. shader: string;
  110918. };
  110919. }
  110920. declare module BABYLON {
  110921. /**
  110922. * BABYLON.JS Chromatic Aberration GLSL Shader
  110923. * Author: Olivier Guyot
  110924. * Separates very slightly R, G and B colors on the edges of the screen
  110925. * Inspired by Francois Tarlier & Martins Upitis
  110926. */
  110927. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  110928. /**
  110929. * @ignore
  110930. * The chromatic aberration PostProcess id in the pipeline
  110931. */
  110932. LensChromaticAberrationEffect: string;
  110933. /**
  110934. * @ignore
  110935. * The highlights enhancing PostProcess id in the pipeline
  110936. */
  110937. HighlightsEnhancingEffect: string;
  110938. /**
  110939. * @ignore
  110940. * The depth-of-field PostProcess id in the pipeline
  110941. */
  110942. LensDepthOfFieldEffect: string;
  110943. private _scene;
  110944. private _depthTexture;
  110945. private _grainTexture;
  110946. private _chromaticAberrationPostProcess;
  110947. private _highlightsPostProcess;
  110948. private _depthOfFieldPostProcess;
  110949. private _edgeBlur;
  110950. private _grainAmount;
  110951. private _chromaticAberration;
  110952. private _distortion;
  110953. private _highlightsGain;
  110954. private _highlightsThreshold;
  110955. private _dofDistance;
  110956. private _dofAperture;
  110957. private _dofDarken;
  110958. private _dofPentagon;
  110959. private _blurNoise;
  110960. /**
  110961. * @constructor
  110962. *
  110963. * Effect parameters are as follow:
  110964. * {
  110965. * chromatic_aberration: number; // from 0 to x (1 for realism)
  110966. * edge_blur: number; // from 0 to x (1 for realism)
  110967. * distortion: number; // from 0 to x (1 for realism)
  110968. * grain_amount: number; // from 0 to 1
  110969. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  110970. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  110971. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  110972. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  110973. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  110974. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  110975. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  110976. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  110977. * }
  110978. * Note: if an effect parameter is unset, effect is disabled
  110979. *
  110980. * @param name The rendering pipeline name
  110981. * @param parameters - An object containing all parameters (see above)
  110982. * @param scene The scene linked to this pipeline
  110983. * @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)
  110984. * @param cameras The array of cameras that the rendering pipeline will be attached to
  110985. */
  110986. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  110987. /**
  110988. * Get the class name
  110989. * @returns "LensRenderingPipeline"
  110990. */
  110991. getClassName(): string;
  110992. /**
  110993. * Gets associated scene
  110994. */
  110995. readonly scene: Scene;
  110996. /**
  110997. * Gets or sets the edge blur
  110998. */
  110999. edgeBlur: number;
  111000. /**
  111001. * Gets or sets the grain amount
  111002. */
  111003. grainAmount: number;
  111004. /**
  111005. * Gets or sets the chromatic aberration amount
  111006. */
  111007. chromaticAberration: number;
  111008. /**
  111009. * Gets or sets the depth of field aperture
  111010. */
  111011. dofAperture: number;
  111012. /**
  111013. * Gets or sets the edge distortion
  111014. */
  111015. edgeDistortion: number;
  111016. /**
  111017. * Gets or sets the depth of field distortion
  111018. */
  111019. dofDistortion: number;
  111020. /**
  111021. * Gets or sets the darken out of focus amount
  111022. */
  111023. darkenOutOfFocus: number;
  111024. /**
  111025. * Gets or sets a boolean indicating if blur noise is enabled
  111026. */
  111027. blurNoise: boolean;
  111028. /**
  111029. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  111030. */
  111031. pentagonBokeh: boolean;
  111032. /**
  111033. * Gets or sets the highlight grain amount
  111034. */
  111035. highlightsGain: number;
  111036. /**
  111037. * Gets or sets the highlight threshold
  111038. */
  111039. highlightsThreshold: number;
  111040. /**
  111041. * Sets the amount of blur at the edges
  111042. * @param amount blur amount
  111043. */
  111044. setEdgeBlur(amount: number): void;
  111045. /**
  111046. * Sets edge blur to 0
  111047. */
  111048. disableEdgeBlur(): void;
  111049. /**
  111050. * Sets the amout of grain
  111051. * @param amount Amount of grain
  111052. */
  111053. setGrainAmount(amount: number): void;
  111054. /**
  111055. * Set grain amount to 0
  111056. */
  111057. disableGrain(): void;
  111058. /**
  111059. * Sets the chromatic aberration amount
  111060. * @param amount amount of chromatic aberration
  111061. */
  111062. setChromaticAberration(amount: number): void;
  111063. /**
  111064. * Sets chromatic aberration amount to 0
  111065. */
  111066. disableChromaticAberration(): void;
  111067. /**
  111068. * Sets the EdgeDistortion amount
  111069. * @param amount amount of EdgeDistortion
  111070. */
  111071. setEdgeDistortion(amount: number): void;
  111072. /**
  111073. * Sets edge distortion to 0
  111074. */
  111075. disableEdgeDistortion(): void;
  111076. /**
  111077. * Sets the FocusDistance amount
  111078. * @param amount amount of FocusDistance
  111079. */
  111080. setFocusDistance(amount: number): void;
  111081. /**
  111082. * Disables depth of field
  111083. */
  111084. disableDepthOfField(): void;
  111085. /**
  111086. * Sets the Aperture amount
  111087. * @param amount amount of Aperture
  111088. */
  111089. setAperture(amount: number): void;
  111090. /**
  111091. * Sets the DarkenOutOfFocus amount
  111092. * @param amount amount of DarkenOutOfFocus
  111093. */
  111094. setDarkenOutOfFocus(amount: number): void;
  111095. private _pentagonBokehIsEnabled;
  111096. /**
  111097. * Creates a pentagon bokeh effect
  111098. */
  111099. enablePentagonBokeh(): void;
  111100. /**
  111101. * Disables the pentagon bokeh effect
  111102. */
  111103. disablePentagonBokeh(): void;
  111104. /**
  111105. * Enables noise blur
  111106. */
  111107. enableNoiseBlur(): void;
  111108. /**
  111109. * Disables noise blur
  111110. */
  111111. disableNoiseBlur(): void;
  111112. /**
  111113. * Sets the HighlightsGain amount
  111114. * @param amount amount of HighlightsGain
  111115. */
  111116. setHighlightsGain(amount: number): void;
  111117. /**
  111118. * Sets the HighlightsThreshold amount
  111119. * @param amount amount of HighlightsThreshold
  111120. */
  111121. setHighlightsThreshold(amount: number): void;
  111122. /**
  111123. * Disables highlights
  111124. */
  111125. disableHighlights(): void;
  111126. /**
  111127. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  111128. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  111129. */
  111130. dispose(disableDepthRender?: boolean): void;
  111131. private _createChromaticAberrationPostProcess;
  111132. private _createHighlightsPostProcess;
  111133. private _createDepthOfFieldPostProcess;
  111134. private _createGrainTexture;
  111135. }
  111136. }
  111137. declare module BABYLON {
  111138. /** @hidden */
  111139. export var ssao2PixelShader: {
  111140. name: string;
  111141. shader: string;
  111142. };
  111143. }
  111144. declare module BABYLON {
  111145. /** @hidden */
  111146. export var ssaoCombinePixelShader: {
  111147. name: string;
  111148. shader: string;
  111149. };
  111150. }
  111151. declare module BABYLON {
  111152. /**
  111153. * Render pipeline to produce ssao effect
  111154. */
  111155. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  111156. /**
  111157. * @ignore
  111158. * The PassPostProcess id in the pipeline that contains the original scene color
  111159. */
  111160. SSAOOriginalSceneColorEffect: string;
  111161. /**
  111162. * @ignore
  111163. * The SSAO PostProcess id in the pipeline
  111164. */
  111165. SSAORenderEffect: string;
  111166. /**
  111167. * @ignore
  111168. * The horizontal blur PostProcess id in the pipeline
  111169. */
  111170. SSAOBlurHRenderEffect: string;
  111171. /**
  111172. * @ignore
  111173. * The vertical blur PostProcess id in the pipeline
  111174. */
  111175. SSAOBlurVRenderEffect: string;
  111176. /**
  111177. * @ignore
  111178. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  111179. */
  111180. SSAOCombineRenderEffect: string;
  111181. /**
  111182. * The output strength of the SSAO post-process. Default value is 1.0.
  111183. */
  111184. totalStrength: number;
  111185. /**
  111186. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  111187. */
  111188. maxZ: number;
  111189. /**
  111190. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  111191. */
  111192. minZAspect: number;
  111193. private _samples;
  111194. /**
  111195. * Number of samples used for the SSAO calculations. Default value is 8
  111196. */
  111197. samples: number;
  111198. private _textureSamples;
  111199. /**
  111200. * Number of samples to use for antialiasing
  111201. */
  111202. textureSamples: number;
  111203. /**
  111204. * Ratio object used for SSAO ratio and blur ratio
  111205. */
  111206. private _ratio;
  111207. /**
  111208. * Dynamically generated sphere sampler.
  111209. */
  111210. private _sampleSphere;
  111211. /**
  111212. * Blur filter offsets
  111213. */
  111214. private _samplerOffsets;
  111215. private _expensiveBlur;
  111216. /**
  111217. * If bilateral blur should be used
  111218. */
  111219. expensiveBlur: boolean;
  111220. /**
  111221. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  111222. */
  111223. radius: number;
  111224. /**
  111225. * The base color of the SSAO post-process
  111226. * The final result is "base + ssao" between [0, 1]
  111227. */
  111228. base: number;
  111229. /**
  111230. * Support test.
  111231. */
  111232. static readonly IsSupported: boolean;
  111233. private _scene;
  111234. private _depthTexture;
  111235. private _normalTexture;
  111236. private _randomTexture;
  111237. private _originalColorPostProcess;
  111238. private _ssaoPostProcess;
  111239. private _blurHPostProcess;
  111240. private _blurVPostProcess;
  111241. private _ssaoCombinePostProcess;
  111242. private _firstUpdate;
  111243. /**
  111244. * Gets active scene
  111245. */
  111246. readonly scene: Scene;
  111247. /**
  111248. * @constructor
  111249. * @param name The rendering pipeline name
  111250. * @param scene The scene linked to this pipeline
  111251. * @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 }
  111252. * @param cameras The array of cameras that the rendering pipeline will be attached to
  111253. */
  111254. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  111255. /**
  111256. * Get the class name
  111257. * @returns "SSAO2RenderingPipeline"
  111258. */
  111259. getClassName(): string;
  111260. /**
  111261. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  111262. */
  111263. dispose(disableGeometryBufferRenderer?: boolean): void;
  111264. private _createBlurPostProcess;
  111265. /** @hidden */
  111266. _rebuild(): void;
  111267. private _bits;
  111268. private _radicalInverse_VdC;
  111269. private _hammersley;
  111270. private _hemisphereSample_uniform;
  111271. private _generateHemisphere;
  111272. private _createSSAOPostProcess;
  111273. private _createSSAOCombinePostProcess;
  111274. private _createRandomTexture;
  111275. /**
  111276. * Serialize the rendering pipeline (Used when exporting)
  111277. * @returns the serialized object
  111278. */
  111279. serialize(): any;
  111280. /**
  111281. * Parse the serialized pipeline
  111282. * @param source Source pipeline.
  111283. * @param scene The scene to load the pipeline to.
  111284. * @param rootUrl The URL of the serialized pipeline.
  111285. * @returns An instantiated pipeline from the serialized object.
  111286. */
  111287. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  111288. }
  111289. }
  111290. declare module BABYLON {
  111291. /** @hidden */
  111292. export var ssaoPixelShader: {
  111293. name: string;
  111294. shader: string;
  111295. };
  111296. }
  111297. declare module BABYLON {
  111298. /**
  111299. * Render pipeline to produce ssao effect
  111300. */
  111301. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  111302. /**
  111303. * @ignore
  111304. * The PassPostProcess id in the pipeline that contains the original scene color
  111305. */
  111306. SSAOOriginalSceneColorEffect: string;
  111307. /**
  111308. * @ignore
  111309. * The SSAO PostProcess id in the pipeline
  111310. */
  111311. SSAORenderEffect: string;
  111312. /**
  111313. * @ignore
  111314. * The horizontal blur PostProcess id in the pipeline
  111315. */
  111316. SSAOBlurHRenderEffect: string;
  111317. /**
  111318. * @ignore
  111319. * The vertical blur PostProcess id in the pipeline
  111320. */
  111321. SSAOBlurVRenderEffect: string;
  111322. /**
  111323. * @ignore
  111324. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  111325. */
  111326. SSAOCombineRenderEffect: string;
  111327. /**
  111328. * The output strength of the SSAO post-process. Default value is 1.0.
  111329. */
  111330. totalStrength: number;
  111331. /**
  111332. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  111333. */
  111334. radius: number;
  111335. /**
  111336. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  111337. * Must not be equal to fallOff and superior to fallOff.
  111338. * Default value is 0.0075
  111339. */
  111340. area: number;
  111341. /**
  111342. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  111343. * Must not be equal to area and inferior to area.
  111344. * Default value is 0.000001
  111345. */
  111346. fallOff: number;
  111347. /**
  111348. * The base color of the SSAO post-process
  111349. * The final result is "base + ssao" between [0, 1]
  111350. */
  111351. base: number;
  111352. private _scene;
  111353. private _depthTexture;
  111354. private _randomTexture;
  111355. private _originalColorPostProcess;
  111356. private _ssaoPostProcess;
  111357. private _blurHPostProcess;
  111358. private _blurVPostProcess;
  111359. private _ssaoCombinePostProcess;
  111360. private _firstUpdate;
  111361. /**
  111362. * Gets active scene
  111363. */
  111364. readonly scene: Scene;
  111365. /**
  111366. * @constructor
  111367. * @param name - The rendering pipeline name
  111368. * @param scene - The scene linked to this pipeline
  111369. * @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 }
  111370. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  111371. */
  111372. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  111373. /**
  111374. * Get the class name
  111375. * @returns "SSAORenderingPipeline"
  111376. */
  111377. getClassName(): string;
  111378. /**
  111379. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  111380. */
  111381. dispose(disableDepthRender?: boolean): void;
  111382. private _createBlurPostProcess;
  111383. /** @hidden */
  111384. _rebuild(): void;
  111385. private _createSSAOPostProcess;
  111386. private _createSSAOCombinePostProcess;
  111387. private _createRandomTexture;
  111388. }
  111389. }
  111390. declare module BABYLON {
  111391. /** @hidden */
  111392. export var standardPixelShader: {
  111393. name: string;
  111394. shader: string;
  111395. };
  111396. }
  111397. declare module BABYLON {
  111398. /**
  111399. * Standard rendering pipeline
  111400. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  111401. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  111402. */
  111403. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  111404. /**
  111405. * Public members
  111406. */
  111407. /**
  111408. * Post-process which contains the original scene color before the pipeline applies all the effects
  111409. */
  111410. originalPostProcess: Nullable<PostProcess>;
  111411. /**
  111412. * Post-process used to down scale an image x4
  111413. */
  111414. downSampleX4PostProcess: Nullable<PostProcess>;
  111415. /**
  111416. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  111417. */
  111418. brightPassPostProcess: Nullable<PostProcess>;
  111419. /**
  111420. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  111421. */
  111422. blurHPostProcesses: PostProcess[];
  111423. /**
  111424. * Post-process array storing all the vertical blur post-processes used by the pipeline
  111425. */
  111426. blurVPostProcesses: PostProcess[];
  111427. /**
  111428. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  111429. */
  111430. textureAdderPostProcess: Nullable<PostProcess>;
  111431. /**
  111432. * Post-process used to create volumetric lighting effect
  111433. */
  111434. volumetricLightPostProcess: Nullable<PostProcess>;
  111435. /**
  111436. * Post-process used to smooth the previous volumetric light post-process on the X axis
  111437. */
  111438. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  111439. /**
  111440. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  111441. */
  111442. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  111443. /**
  111444. * Post-process used to merge the volumetric light effect and the real scene color
  111445. */
  111446. volumetricLightMergePostProces: Nullable<PostProcess>;
  111447. /**
  111448. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  111449. */
  111450. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  111451. /**
  111452. * Base post-process used to calculate the average luminance of the final image for HDR
  111453. */
  111454. luminancePostProcess: Nullable<PostProcess>;
  111455. /**
  111456. * Post-processes used to create down sample post-processes in order to get
  111457. * the average luminance of the final image for HDR
  111458. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  111459. */
  111460. luminanceDownSamplePostProcesses: PostProcess[];
  111461. /**
  111462. * Post-process used to create a HDR effect (light adaptation)
  111463. */
  111464. hdrPostProcess: Nullable<PostProcess>;
  111465. /**
  111466. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  111467. */
  111468. textureAdderFinalPostProcess: Nullable<PostProcess>;
  111469. /**
  111470. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  111471. */
  111472. lensFlareFinalPostProcess: Nullable<PostProcess>;
  111473. /**
  111474. * Post-process used to merge the final HDR post-process and the real scene color
  111475. */
  111476. hdrFinalPostProcess: Nullable<PostProcess>;
  111477. /**
  111478. * Post-process used to create a lens flare effect
  111479. */
  111480. lensFlarePostProcess: Nullable<PostProcess>;
  111481. /**
  111482. * Post-process that merges the result of the lens flare post-process and the real scene color
  111483. */
  111484. lensFlareComposePostProcess: Nullable<PostProcess>;
  111485. /**
  111486. * Post-process used to create a motion blur effect
  111487. */
  111488. motionBlurPostProcess: Nullable<PostProcess>;
  111489. /**
  111490. * Post-process used to create a depth of field effect
  111491. */
  111492. depthOfFieldPostProcess: Nullable<PostProcess>;
  111493. /**
  111494. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  111495. */
  111496. fxaaPostProcess: Nullable<FxaaPostProcess>;
  111497. /**
  111498. * Represents the brightness threshold in order to configure the illuminated surfaces
  111499. */
  111500. brightThreshold: number;
  111501. /**
  111502. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  111503. */
  111504. blurWidth: number;
  111505. /**
  111506. * Sets if the blur for highlighted surfaces must be only horizontal
  111507. */
  111508. horizontalBlur: boolean;
  111509. /**
  111510. * Sets the overall exposure used by the pipeline
  111511. */
  111512. exposure: number;
  111513. /**
  111514. * Texture used typically to simulate "dirty" on camera lens
  111515. */
  111516. lensTexture: Nullable<Texture>;
  111517. /**
  111518. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  111519. */
  111520. volumetricLightCoefficient: number;
  111521. /**
  111522. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  111523. */
  111524. volumetricLightPower: number;
  111525. /**
  111526. * Used the set the blur intensity to smooth the volumetric lights
  111527. */
  111528. volumetricLightBlurScale: number;
  111529. /**
  111530. * Light (spot or directional) used to generate the volumetric lights rays
  111531. * The source light must have a shadow generate so the pipeline can get its
  111532. * depth map
  111533. */
  111534. sourceLight: Nullable<SpotLight | DirectionalLight>;
  111535. /**
  111536. * For eye adaptation, represents the minimum luminance the eye can see
  111537. */
  111538. hdrMinimumLuminance: number;
  111539. /**
  111540. * For eye adaptation, represents the decrease luminance speed
  111541. */
  111542. hdrDecreaseRate: number;
  111543. /**
  111544. * For eye adaptation, represents the increase luminance speed
  111545. */
  111546. hdrIncreaseRate: number;
  111547. /**
  111548. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  111549. */
  111550. lensColorTexture: Nullable<Texture>;
  111551. /**
  111552. * The overall strengh for the lens flare effect
  111553. */
  111554. lensFlareStrength: number;
  111555. /**
  111556. * Dispersion coefficient for lens flare ghosts
  111557. */
  111558. lensFlareGhostDispersal: number;
  111559. /**
  111560. * Main lens flare halo width
  111561. */
  111562. lensFlareHaloWidth: number;
  111563. /**
  111564. * Based on the lens distortion effect, defines how much the lens flare result
  111565. * is distorted
  111566. */
  111567. lensFlareDistortionStrength: number;
  111568. /**
  111569. * Lens star texture must be used to simulate rays on the flares and is available
  111570. * in the documentation
  111571. */
  111572. lensStarTexture: Nullable<Texture>;
  111573. /**
  111574. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  111575. * flare effect by taking account of the dirt texture
  111576. */
  111577. lensFlareDirtTexture: Nullable<Texture>;
  111578. /**
  111579. * Represents the focal length for the depth of field effect
  111580. */
  111581. depthOfFieldDistance: number;
  111582. /**
  111583. * Represents the blur intensity for the blurred part of the depth of field effect
  111584. */
  111585. depthOfFieldBlurWidth: number;
  111586. /**
  111587. * For motion blur, defines how much the image is blurred by the movement
  111588. */
  111589. motionStrength: number;
  111590. /**
  111591. * List of animations for the pipeline (IAnimatable implementation)
  111592. */
  111593. animations: Animation[];
  111594. /**
  111595. * Private members
  111596. */
  111597. private _scene;
  111598. private _currentDepthOfFieldSource;
  111599. private _basePostProcess;
  111600. private _hdrCurrentLuminance;
  111601. private _floatTextureType;
  111602. private _ratio;
  111603. private _bloomEnabled;
  111604. private _depthOfFieldEnabled;
  111605. private _vlsEnabled;
  111606. private _lensFlareEnabled;
  111607. private _hdrEnabled;
  111608. private _motionBlurEnabled;
  111609. private _fxaaEnabled;
  111610. private _motionBlurSamples;
  111611. private _volumetricLightStepsCount;
  111612. private _samples;
  111613. /**
  111614. * @ignore
  111615. * Specifies if the bloom pipeline is enabled
  111616. */
  111617. BloomEnabled: boolean;
  111618. /**
  111619. * @ignore
  111620. * Specifies if the depth of field pipeline is enabed
  111621. */
  111622. DepthOfFieldEnabled: boolean;
  111623. /**
  111624. * @ignore
  111625. * Specifies if the lens flare pipeline is enabed
  111626. */
  111627. LensFlareEnabled: boolean;
  111628. /**
  111629. * @ignore
  111630. * Specifies if the HDR pipeline is enabled
  111631. */
  111632. HDREnabled: boolean;
  111633. /**
  111634. * @ignore
  111635. * Specifies if the volumetric lights scattering effect is enabled
  111636. */
  111637. VLSEnabled: boolean;
  111638. /**
  111639. * @ignore
  111640. * Specifies if the motion blur effect is enabled
  111641. */
  111642. MotionBlurEnabled: boolean;
  111643. /**
  111644. * Specifies if anti-aliasing is enabled
  111645. */
  111646. fxaaEnabled: boolean;
  111647. /**
  111648. * Specifies the number of steps used to calculate the volumetric lights
  111649. * Typically in interval [50, 200]
  111650. */
  111651. volumetricLightStepsCount: number;
  111652. /**
  111653. * Specifies the number of samples used for the motion blur effect
  111654. * Typically in interval [16, 64]
  111655. */
  111656. motionBlurSamples: number;
  111657. /**
  111658. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  111659. */
  111660. samples: number;
  111661. /**
  111662. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  111663. * @constructor
  111664. * @param name The rendering pipeline name
  111665. * @param scene The scene linked to this pipeline
  111666. * @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)
  111667. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  111668. * @param cameras The array of cameras that the rendering pipeline will be attached to
  111669. */
  111670. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  111671. private _buildPipeline;
  111672. private _createDownSampleX4PostProcess;
  111673. private _createBrightPassPostProcess;
  111674. private _createBlurPostProcesses;
  111675. private _createTextureAdderPostProcess;
  111676. private _createVolumetricLightPostProcess;
  111677. private _createLuminancePostProcesses;
  111678. private _createHdrPostProcess;
  111679. private _createLensFlarePostProcess;
  111680. private _createDepthOfFieldPostProcess;
  111681. private _createMotionBlurPostProcess;
  111682. private _getDepthTexture;
  111683. private _disposePostProcesses;
  111684. /**
  111685. * Dispose of the pipeline and stop all post processes
  111686. */
  111687. dispose(): void;
  111688. /**
  111689. * Serialize the rendering pipeline (Used when exporting)
  111690. * @returns the serialized object
  111691. */
  111692. serialize(): any;
  111693. /**
  111694. * Parse the serialized pipeline
  111695. * @param source Source pipeline.
  111696. * @param scene The scene to load the pipeline to.
  111697. * @param rootUrl The URL of the serialized pipeline.
  111698. * @returns An instantiated pipeline from the serialized object.
  111699. */
  111700. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  111701. /**
  111702. * Luminance steps
  111703. */
  111704. static LuminanceSteps: number;
  111705. }
  111706. }
  111707. declare module BABYLON {
  111708. /** @hidden */
  111709. export var tonemapPixelShader: {
  111710. name: string;
  111711. shader: string;
  111712. };
  111713. }
  111714. declare module BABYLON {
  111715. /** Defines operator used for tonemapping */
  111716. export enum TonemappingOperator {
  111717. /** Hable */
  111718. Hable = 0,
  111719. /** Reinhard */
  111720. Reinhard = 1,
  111721. /** HejiDawson */
  111722. HejiDawson = 2,
  111723. /** Photographic */
  111724. Photographic = 3
  111725. }
  111726. /**
  111727. * Defines a post process to apply tone mapping
  111728. */
  111729. export class TonemapPostProcess extends PostProcess {
  111730. private _operator;
  111731. /** Defines the required exposure adjustement */
  111732. exposureAdjustment: number;
  111733. /**
  111734. * Creates a new TonemapPostProcess
  111735. * @param name defines the name of the postprocess
  111736. * @param _operator defines the operator to use
  111737. * @param exposureAdjustment defines the required exposure adjustement
  111738. * @param camera defines the camera to use (can be null)
  111739. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  111740. * @param engine defines the hosting engine (can be ignore if camera is set)
  111741. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  111742. */
  111743. constructor(name: string, _operator: TonemappingOperator,
  111744. /** Defines the required exposure adjustement */
  111745. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  111746. }
  111747. }
  111748. declare module BABYLON {
  111749. /** @hidden */
  111750. export var depthVertexShader: {
  111751. name: string;
  111752. shader: string;
  111753. };
  111754. }
  111755. declare module BABYLON {
  111756. /** @hidden */
  111757. export var volumetricLightScatteringPixelShader: {
  111758. name: string;
  111759. shader: string;
  111760. };
  111761. }
  111762. declare module BABYLON {
  111763. /** @hidden */
  111764. export var volumetricLightScatteringPassPixelShader: {
  111765. name: string;
  111766. shader: string;
  111767. };
  111768. }
  111769. declare module BABYLON {
  111770. /**
  111771. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  111772. */
  111773. export class VolumetricLightScatteringPostProcess extends PostProcess {
  111774. private _volumetricLightScatteringPass;
  111775. private _volumetricLightScatteringRTT;
  111776. private _viewPort;
  111777. private _screenCoordinates;
  111778. private _cachedDefines;
  111779. /**
  111780. * If not undefined, the mesh position is computed from the attached node position
  111781. */
  111782. attachedNode: {
  111783. position: Vector3;
  111784. };
  111785. /**
  111786. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  111787. */
  111788. customMeshPosition: Vector3;
  111789. /**
  111790. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  111791. */
  111792. useCustomMeshPosition: boolean;
  111793. /**
  111794. * If the post-process should inverse the light scattering direction
  111795. */
  111796. invert: boolean;
  111797. /**
  111798. * The internal mesh used by the post-process
  111799. */
  111800. mesh: Mesh;
  111801. /**
  111802. * @hidden
  111803. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  111804. */
  111805. useDiffuseColor: boolean;
  111806. /**
  111807. * Array containing the excluded meshes not rendered in the internal pass
  111808. */
  111809. excludedMeshes: AbstractMesh[];
  111810. /**
  111811. * Controls the overall intensity of the post-process
  111812. */
  111813. exposure: number;
  111814. /**
  111815. * Dissipates each sample's contribution in range [0, 1]
  111816. */
  111817. decay: number;
  111818. /**
  111819. * Controls the overall intensity of each sample
  111820. */
  111821. weight: number;
  111822. /**
  111823. * Controls the density of each sample
  111824. */
  111825. density: number;
  111826. /**
  111827. * @constructor
  111828. * @param name The post-process name
  111829. * @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)
  111830. * @param camera The camera that the post-process will be attached to
  111831. * @param mesh The mesh used to create the light scattering
  111832. * @param samples The post-process quality, default 100
  111833. * @param samplingModeThe post-process filtering mode
  111834. * @param engine The babylon engine
  111835. * @param reusable If the post-process is reusable
  111836. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  111837. */
  111838. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  111839. /**
  111840. * Returns the string "VolumetricLightScatteringPostProcess"
  111841. * @returns "VolumetricLightScatteringPostProcess"
  111842. */
  111843. getClassName(): string;
  111844. private _isReady;
  111845. /**
  111846. * Sets the new light position for light scattering effect
  111847. * @param position The new custom light position
  111848. */
  111849. setCustomMeshPosition(position: Vector3): void;
  111850. /**
  111851. * Returns the light position for light scattering effect
  111852. * @return Vector3 The custom light position
  111853. */
  111854. getCustomMeshPosition(): Vector3;
  111855. /**
  111856. * Disposes the internal assets and detaches the post-process from the camera
  111857. */
  111858. dispose(camera: Camera): void;
  111859. /**
  111860. * Returns the render target texture used by the post-process
  111861. * @return the render target texture used by the post-process
  111862. */
  111863. getPass(): RenderTargetTexture;
  111864. private _meshExcluded;
  111865. private _createPass;
  111866. private _updateMeshScreenCoordinates;
  111867. /**
  111868. * Creates a default mesh for the Volumeric Light Scattering post-process
  111869. * @param name The mesh name
  111870. * @param scene The scene where to create the mesh
  111871. * @return the default mesh
  111872. */
  111873. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  111874. }
  111875. }
  111876. declare module BABYLON {
  111877. interface Scene {
  111878. /** @hidden (Backing field) */
  111879. _boundingBoxRenderer: BoundingBoxRenderer;
  111880. /** @hidden (Backing field) */
  111881. _forceShowBoundingBoxes: boolean;
  111882. /**
  111883. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  111884. */
  111885. forceShowBoundingBoxes: boolean;
  111886. /**
  111887. * Gets the bounding box renderer associated with the scene
  111888. * @returns a BoundingBoxRenderer
  111889. */
  111890. getBoundingBoxRenderer(): BoundingBoxRenderer;
  111891. }
  111892. interface AbstractMesh {
  111893. /** @hidden (Backing field) */
  111894. _showBoundingBox: boolean;
  111895. /**
  111896. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  111897. */
  111898. showBoundingBox: boolean;
  111899. }
  111900. /**
  111901. * Component responsible of rendering the bounding box of the meshes in a scene.
  111902. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  111903. */
  111904. export class BoundingBoxRenderer implements ISceneComponent {
  111905. /**
  111906. * The component name helpfull to identify the component in the list of scene components.
  111907. */
  111908. readonly name: string;
  111909. /**
  111910. * The scene the component belongs to.
  111911. */
  111912. scene: Scene;
  111913. /**
  111914. * Color of the bounding box lines placed in front of an object
  111915. */
  111916. frontColor: Color3;
  111917. /**
  111918. * Color of the bounding box lines placed behind an object
  111919. */
  111920. backColor: Color3;
  111921. /**
  111922. * Defines if the renderer should show the back lines or not
  111923. */
  111924. showBackLines: boolean;
  111925. /**
  111926. * @hidden
  111927. */
  111928. renderList: SmartArray<BoundingBox>;
  111929. private _colorShader;
  111930. private _vertexBuffers;
  111931. private _indexBuffer;
  111932. /**
  111933. * Instantiates a new bounding box renderer in a scene.
  111934. * @param scene the scene the renderer renders in
  111935. */
  111936. constructor(scene: Scene);
  111937. /**
  111938. * Registers the component in a given scene
  111939. */
  111940. register(): void;
  111941. private _evaluateSubMesh;
  111942. private _activeMesh;
  111943. private _prepareRessources;
  111944. private _createIndexBuffer;
  111945. /**
  111946. * Rebuilds the elements related to this component in case of
  111947. * context lost for instance.
  111948. */
  111949. rebuild(): void;
  111950. /**
  111951. * @hidden
  111952. */
  111953. reset(): void;
  111954. /**
  111955. * Render the bounding boxes of a specific rendering group
  111956. * @param renderingGroupId defines the rendering group to render
  111957. */
  111958. render(renderingGroupId: number): void;
  111959. /**
  111960. * In case of occlusion queries, we can render the occlusion bounding box through this method
  111961. * @param mesh Define the mesh to render the occlusion bounding box for
  111962. */
  111963. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  111964. /**
  111965. * Dispose and release the resources attached to this renderer.
  111966. */
  111967. dispose(): void;
  111968. }
  111969. }
  111970. declare module BABYLON {
  111971. /** @hidden */
  111972. export var depthPixelShader: {
  111973. name: string;
  111974. shader: string;
  111975. };
  111976. }
  111977. declare module BABYLON {
  111978. /**
  111979. * This represents a depth renderer in Babylon.
  111980. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  111981. */
  111982. export class DepthRenderer {
  111983. private _scene;
  111984. private _depthMap;
  111985. private _effect;
  111986. private _cachedDefines;
  111987. private _camera;
  111988. /**
  111989. * Specifiess that the depth renderer will only be used within
  111990. * the camera it is created for.
  111991. * This can help forcing its rendering during the camera processing.
  111992. */
  111993. useOnlyInActiveCamera: boolean;
  111994. /** @hidden */
  111995. static _SceneComponentInitialization: (scene: Scene) => void;
  111996. /**
  111997. * Instantiates a depth renderer
  111998. * @param scene The scene the renderer belongs to
  111999. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  112000. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  112001. */
  112002. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  112003. /**
  112004. * Creates the depth rendering effect and checks if the effect is ready.
  112005. * @param subMesh The submesh to be used to render the depth map of
  112006. * @param useInstances If multiple world instances should be used
  112007. * @returns if the depth renderer is ready to render the depth map
  112008. */
  112009. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  112010. /**
  112011. * Gets the texture which the depth map will be written to.
  112012. * @returns The depth map texture
  112013. */
  112014. getDepthMap(): RenderTargetTexture;
  112015. /**
  112016. * Disposes of the depth renderer.
  112017. */
  112018. dispose(): void;
  112019. }
  112020. }
  112021. declare module BABYLON {
  112022. interface Scene {
  112023. /** @hidden (Backing field) */
  112024. _depthRenderer: {
  112025. [id: string]: DepthRenderer;
  112026. };
  112027. /**
  112028. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  112029. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  112030. * @returns the created depth renderer
  112031. */
  112032. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  112033. /**
  112034. * Disables a depth renderer for a given camera
  112035. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  112036. */
  112037. disableDepthRenderer(camera?: Nullable<Camera>): void;
  112038. }
  112039. /**
  112040. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  112041. * in several rendering techniques.
  112042. */
  112043. export class DepthRendererSceneComponent implements ISceneComponent {
  112044. /**
  112045. * The component name helpfull to identify the component in the list of scene components.
  112046. */
  112047. readonly name: string;
  112048. /**
  112049. * The scene the component belongs to.
  112050. */
  112051. scene: Scene;
  112052. /**
  112053. * Creates a new instance of the component for the given scene
  112054. * @param scene Defines the scene to register the component in
  112055. */
  112056. constructor(scene: Scene);
  112057. /**
  112058. * Registers the component in a given scene
  112059. */
  112060. register(): void;
  112061. /**
  112062. * Rebuilds the elements related to this component in case of
  112063. * context lost for instance.
  112064. */
  112065. rebuild(): void;
  112066. /**
  112067. * Disposes the component and the associated ressources
  112068. */
  112069. dispose(): void;
  112070. private _gatherRenderTargets;
  112071. private _gatherActiveCameraRenderTargets;
  112072. }
  112073. }
  112074. declare module BABYLON {
  112075. /** @hidden */
  112076. export var outlinePixelShader: {
  112077. name: string;
  112078. shader: string;
  112079. };
  112080. }
  112081. declare module BABYLON {
  112082. /** @hidden */
  112083. export var outlineVertexShader: {
  112084. name: string;
  112085. shader: string;
  112086. };
  112087. }
  112088. declare module BABYLON {
  112089. interface Scene {
  112090. /** @hidden */
  112091. _outlineRenderer: OutlineRenderer;
  112092. /**
  112093. * Gets the outline renderer associated with the scene
  112094. * @returns a OutlineRenderer
  112095. */
  112096. getOutlineRenderer(): OutlineRenderer;
  112097. }
  112098. interface AbstractMesh {
  112099. /** @hidden (Backing field) */
  112100. _renderOutline: boolean;
  112101. /**
  112102. * Gets or sets a boolean indicating if the outline must be rendered as well
  112103. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  112104. */
  112105. renderOutline: boolean;
  112106. /** @hidden (Backing field) */
  112107. _renderOverlay: boolean;
  112108. /**
  112109. * Gets or sets a boolean indicating if the overlay must be rendered as well
  112110. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  112111. */
  112112. renderOverlay: boolean;
  112113. }
  112114. /**
  112115. * This class is responsible to draw bothe outline/overlay of meshes.
  112116. * It should not be used directly but through the available method on mesh.
  112117. */
  112118. export class OutlineRenderer implements ISceneComponent {
  112119. /**
  112120. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  112121. */
  112122. private static _StencilReference;
  112123. /**
  112124. * The name of the component. Each component must have a unique name.
  112125. */
  112126. name: string;
  112127. /**
  112128. * The scene the component belongs to.
  112129. */
  112130. scene: Scene;
  112131. /**
  112132. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  112133. */
  112134. zOffset: number;
  112135. private _engine;
  112136. private _effect;
  112137. private _cachedDefines;
  112138. private _savedDepthWrite;
  112139. /**
  112140. * Instantiates a new outline renderer. (There could be only one per scene).
  112141. * @param scene Defines the scene it belongs to
  112142. */
  112143. constructor(scene: Scene);
  112144. /**
  112145. * Register the component to one instance of a scene.
  112146. */
  112147. register(): void;
  112148. /**
  112149. * Rebuilds the elements related to this component in case of
  112150. * context lost for instance.
  112151. */
  112152. rebuild(): void;
  112153. /**
  112154. * Disposes the component and the associated ressources.
  112155. */
  112156. dispose(): void;
  112157. /**
  112158. * Renders the outline in the canvas.
  112159. * @param subMesh Defines the sumesh to render
  112160. * @param batch Defines the batch of meshes in case of instances
  112161. * @param useOverlay Defines if the rendering is for the overlay or the outline
  112162. */
  112163. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  112164. /**
  112165. * Returns whether or not the outline renderer is ready for a given submesh.
  112166. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  112167. * @param subMesh Defines the submesh to check readyness for
  112168. * @param useInstances Defines wheter wee are trying to render instances or not
  112169. * @returns true if ready otherwise false
  112170. */
  112171. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  112172. private _beforeRenderingMesh;
  112173. private _afterRenderingMesh;
  112174. }
  112175. }
  112176. declare module BABYLON {
  112177. /**
  112178. * Defines the list of states available for a task inside a AssetsManager
  112179. */
  112180. export enum AssetTaskState {
  112181. /**
  112182. * Initialization
  112183. */
  112184. INIT = 0,
  112185. /**
  112186. * Running
  112187. */
  112188. RUNNING = 1,
  112189. /**
  112190. * Done
  112191. */
  112192. DONE = 2,
  112193. /**
  112194. * Error
  112195. */
  112196. ERROR = 3
  112197. }
  112198. /**
  112199. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  112200. */
  112201. export abstract class AbstractAssetTask {
  112202. /**
  112203. * Task name
  112204. */ name: string;
  112205. /**
  112206. * Callback called when the task is successful
  112207. */
  112208. onSuccess: (task: any) => void;
  112209. /**
  112210. * Callback called when the task is not successful
  112211. */
  112212. onError: (task: any, message?: string, exception?: any) => void;
  112213. /**
  112214. * Creates a new AssetsManager
  112215. * @param name defines the name of the task
  112216. */
  112217. constructor(
  112218. /**
  112219. * Task name
  112220. */ name: string);
  112221. private _isCompleted;
  112222. private _taskState;
  112223. private _errorObject;
  112224. /**
  112225. * Get if the task is completed
  112226. */
  112227. readonly isCompleted: boolean;
  112228. /**
  112229. * Gets the current state of the task
  112230. */
  112231. readonly taskState: AssetTaskState;
  112232. /**
  112233. * Gets the current error object (if task is in error)
  112234. */
  112235. readonly errorObject: {
  112236. message?: string;
  112237. exception?: any;
  112238. };
  112239. /**
  112240. * Internal only
  112241. * @hidden
  112242. */
  112243. _setErrorObject(message?: string, exception?: any): void;
  112244. /**
  112245. * Execute the current task
  112246. * @param scene defines the scene where you want your assets to be loaded
  112247. * @param onSuccess is a callback called when the task is successfully executed
  112248. * @param onError is a callback called if an error occurs
  112249. */
  112250. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112251. /**
  112252. * Execute the current task
  112253. * @param scene defines the scene where you want your assets to be loaded
  112254. * @param onSuccess is a callback called when the task is successfully executed
  112255. * @param onError is a callback called if an error occurs
  112256. */
  112257. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112258. /**
  112259. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  112260. * This can be used with failed tasks that have the reason for failure fixed.
  112261. */
  112262. reset(): void;
  112263. private onErrorCallback;
  112264. private onDoneCallback;
  112265. }
  112266. /**
  112267. * Define the interface used by progress events raised during assets loading
  112268. */
  112269. export interface IAssetsProgressEvent {
  112270. /**
  112271. * Defines the number of remaining tasks to process
  112272. */
  112273. remainingCount: number;
  112274. /**
  112275. * Defines the total number of tasks
  112276. */
  112277. totalCount: number;
  112278. /**
  112279. * Defines the task that was just processed
  112280. */
  112281. task: AbstractAssetTask;
  112282. }
  112283. /**
  112284. * Class used to share progress information about assets loading
  112285. */
  112286. export class AssetsProgressEvent implements IAssetsProgressEvent {
  112287. /**
  112288. * Defines the number of remaining tasks to process
  112289. */
  112290. remainingCount: number;
  112291. /**
  112292. * Defines the total number of tasks
  112293. */
  112294. totalCount: number;
  112295. /**
  112296. * Defines the task that was just processed
  112297. */
  112298. task: AbstractAssetTask;
  112299. /**
  112300. * Creates a AssetsProgressEvent
  112301. * @param remainingCount defines the number of remaining tasks to process
  112302. * @param totalCount defines the total number of tasks
  112303. * @param task defines the task that was just processed
  112304. */
  112305. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  112306. }
  112307. /**
  112308. * Define a task used by AssetsManager to load meshes
  112309. */
  112310. export class MeshAssetTask extends AbstractAssetTask {
  112311. /**
  112312. * Defines the name of the task
  112313. */
  112314. name: string;
  112315. /**
  112316. * Defines the list of mesh's names you want to load
  112317. */
  112318. meshesNames: any;
  112319. /**
  112320. * Defines the root url to use as a base to load your meshes and associated resources
  112321. */
  112322. rootUrl: string;
  112323. /**
  112324. * Defines the filename of the scene to load from
  112325. */
  112326. sceneFilename: string;
  112327. /**
  112328. * Gets the list of loaded meshes
  112329. */
  112330. loadedMeshes: Array<AbstractMesh>;
  112331. /**
  112332. * Gets the list of loaded particle systems
  112333. */
  112334. loadedParticleSystems: Array<IParticleSystem>;
  112335. /**
  112336. * Gets the list of loaded skeletons
  112337. */
  112338. loadedSkeletons: Array<Skeleton>;
  112339. /**
  112340. * Gets the list of loaded animation groups
  112341. */
  112342. loadedAnimationGroups: Array<AnimationGroup>;
  112343. /**
  112344. * Callback called when the task is successful
  112345. */
  112346. onSuccess: (task: MeshAssetTask) => void;
  112347. /**
  112348. * Callback called when the task is successful
  112349. */
  112350. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  112351. /**
  112352. * Creates a new MeshAssetTask
  112353. * @param name defines the name of the task
  112354. * @param meshesNames defines the list of mesh's names you want to load
  112355. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  112356. * @param sceneFilename defines the filename of the scene to load from
  112357. */
  112358. constructor(
  112359. /**
  112360. * Defines the name of the task
  112361. */
  112362. name: string,
  112363. /**
  112364. * Defines the list of mesh's names you want to load
  112365. */
  112366. meshesNames: any,
  112367. /**
  112368. * Defines the root url to use as a base to load your meshes and associated resources
  112369. */
  112370. rootUrl: string,
  112371. /**
  112372. * Defines the filename of the scene to load from
  112373. */
  112374. sceneFilename: string);
  112375. /**
  112376. * Execute the current task
  112377. * @param scene defines the scene where you want your assets to be loaded
  112378. * @param onSuccess is a callback called when the task is successfully executed
  112379. * @param onError is a callback called if an error occurs
  112380. */
  112381. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112382. }
  112383. /**
  112384. * Define a task used by AssetsManager to load text content
  112385. */
  112386. export class TextFileAssetTask extends AbstractAssetTask {
  112387. /**
  112388. * Defines the name of the task
  112389. */
  112390. name: string;
  112391. /**
  112392. * Defines the location of the file to load
  112393. */
  112394. url: string;
  112395. /**
  112396. * Gets the loaded text string
  112397. */
  112398. text: string;
  112399. /**
  112400. * Callback called when the task is successful
  112401. */
  112402. onSuccess: (task: TextFileAssetTask) => void;
  112403. /**
  112404. * Callback called when the task is successful
  112405. */
  112406. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  112407. /**
  112408. * Creates a new TextFileAssetTask object
  112409. * @param name defines the name of the task
  112410. * @param url defines the location of the file to load
  112411. */
  112412. constructor(
  112413. /**
  112414. * Defines the name of the task
  112415. */
  112416. name: string,
  112417. /**
  112418. * Defines the location of the file to load
  112419. */
  112420. url: string);
  112421. /**
  112422. * Execute the current task
  112423. * @param scene defines the scene where you want your assets to be loaded
  112424. * @param onSuccess is a callback called when the task is successfully executed
  112425. * @param onError is a callback called if an error occurs
  112426. */
  112427. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112428. }
  112429. /**
  112430. * Define a task used by AssetsManager to load binary data
  112431. */
  112432. export class BinaryFileAssetTask extends AbstractAssetTask {
  112433. /**
  112434. * Defines the name of the task
  112435. */
  112436. name: string;
  112437. /**
  112438. * Defines the location of the file to load
  112439. */
  112440. url: string;
  112441. /**
  112442. * Gets the lodaded data (as an array buffer)
  112443. */
  112444. data: ArrayBuffer;
  112445. /**
  112446. * Callback called when the task is successful
  112447. */
  112448. onSuccess: (task: BinaryFileAssetTask) => void;
  112449. /**
  112450. * Callback called when the task is successful
  112451. */
  112452. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  112453. /**
  112454. * Creates a new BinaryFileAssetTask object
  112455. * @param name defines the name of the new task
  112456. * @param url defines the location of the file to load
  112457. */
  112458. constructor(
  112459. /**
  112460. * Defines the name of the task
  112461. */
  112462. name: string,
  112463. /**
  112464. * Defines the location of the file to load
  112465. */
  112466. url: string);
  112467. /**
  112468. * Execute the current task
  112469. * @param scene defines the scene where you want your assets to be loaded
  112470. * @param onSuccess is a callback called when the task is successfully executed
  112471. * @param onError is a callback called if an error occurs
  112472. */
  112473. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112474. }
  112475. /**
  112476. * Define a task used by AssetsManager to load images
  112477. */
  112478. export class ImageAssetTask extends AbstractAssetTask {
  112479. /**
  112480. * Defines the name of the task
  112481. */
  112482. name: string;
  112483. /**
  112484. * Defines the location of the image to load
  112485. */
  112486. url: string;
  112487. /**
  112488. * Gets the loaded images
  112489. */
  112490. image: HTMLImageElement;
  112491. /**
  112492. * Callback called when the task is successful
  112493. */
  112494. onSuccess: (task: ImageAssetTask) => void;
  112495. /**
  112496. * Callback called when the task is successful
  112497. */
  112498. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  112499. /**
  112500. * Creates a new ImageAssetTask
  112501. * @param name defines the name of the task
  112502. * @param url defines the location of the image to load
  112503. */
  112504. constructor(
  112505. /**
  112506. * Defines the name of the task
  112507. */
  112508. name: string,
  112509. /**
  112510. * Defines the location of the image to load
  112511. */
  112512. url: string);
  112513. /**
  112514. * Execute the current task
  112515. * @param scene defines the scene where you want your assets to be loaded
  112516. * @param onSuccess is a callback called when the task is successfully executed
  112517. * @param onError is a callback called if an error occurs
  112518. */
  112519. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112520. }
  112521. /**
  112522. * Defines the interface used by texture loading tasks
  112523. */
  112524. export interface ITextureAssetTask<TEX extends BaseTexture> {
  112525. /**
  112526. * Gets the loaded texture
  112527. */
  112528. texture: TEX;
  112529. }
  112530. /**
  112531. * Define a task used by AssetsManager to load 2D textures
  112532. */
  112533. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  112534. /**
  112535. * Defines the name of the task
  112536. */
  112537. name: string;
  112538. /**
  112539. * Defines the location of the file to load
  112540. */
  112541. url: string;
  112542. /**
  112543. * Defines if mipmap should not be generated (default is false)
  112544. */
  112545. noMipmap?: boolean | undefined;
  112546. /**
  112547. * Defines if texture must be inverted on Y axis (default is false)
  112548. */
  112549. invertY?: boolean | undefined;
  112550. /**
  112551. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  112552. */
  112553. samplingMode: number;
  112554. /**
  112555. * Gets the loaded texture
  112556. */
  112557. texture: Texture;
  112558. /**
  112559. * Callback called when the task is successful
  112560. */
  112561. onSuccess: (task: TextureAssetTask) => void;
  112562. /**
  112563. * Callback called when the task is successful
  112564. */
  112565. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  112566. /**
  112567. * Creates a new TextureAssetTask object
  112568. * @param name defines the name of the task
  112569. * @param url defines the location of the file to load
  112570. * @param noMipmap defines if mipmap should not be generated (default is false)
  112571. * @param invertY defines if texture must be inverted on Y axis (default is false)
  112572. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  112573. */
  112574. constructor(
  112575. /**
  112576. * Defines the name of the task
  112577. */
  112578. name: string,
  112579. /**
  112580. * Defines the location of the file to load
  112581. */
  112582. url: string,
  112583. /**
  112584. * Defines if mipmap should not be generated (default is false)
  112585. */
  112586. noMipmap?: boolean | undefined,
  112587. /**
  112588. * Defines if texture must be inverted on Y axis (default is false)
  112589. */
  112590. invertY?: boolean | undefined,
  112591. /**
  112592. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  112593. */
  112594. samplingMode?: number);
  112595. /**
  112596. * Execute the current task
  112597. * @param scene defines the scene where you want your assets to be loaded
  112598. * @param onSuccess is a callback called when the task is successfully executed
  112599. * @param onError is a callback called if an error occurs
  112600. */
  112601. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112602. }
  112603. /**
  112604. * Define a task used by AssetsManager to load cube textures
  112605. */
  112606. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  112607. /**
  112608. * Defines the name of the task
  112609. */
  112610. name: string;
  112611. /**
  112612. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  112613. */
  112614. url: string;
  112615. /**
  112616. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  112617. */
  112618. extensions?: string[] | undefined;
  112619. /**
  112620. * Defines if mipmaps should not be generated (default is false)
  112621. */
  112622. noMipmap?: boolean | undefined;
  112623. /**
  112624. * Defines the explicit list of files (undefined by default)
  112625. */
  112626. files?: string[] | undefined;
  112627. /**
  112628. * Gets the loaded texture
  112629. */
  112630. texture: CubeTexture;
  112631. /**
  112632. * Callback called when the task is successful
  112633. */
  112634. onSuccess: (task: CubeTextureAssetTask) => void;
  112635. /**
  112636. * Callback called when the task is successful
  112637. */
  112638. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  112639. /**
  112640. * Creates a new CubeTextureAssetTask
  112641. * @param name defines the name of the task
  112642. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  112643. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  112644. * @param noMipmap defines if mipmaps should not be generated (default is false)
  112645. * @param files defines the explicit list of files (undefined by default)
  112646. */
  112647. constructor(
  112648. /**
  112649. * Defines the name of the task
  112650. */
  112651. name: string,
  112652. /**
  112653. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  112654. */
  112655. url: string,
  112656. /**
  112657. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  112658. */
  112659. extensions?: string[] | undefined,
  112660. /**
  112661. * Defines if mipmaps should not be generated (default is false)
  112662. */
  112663. noMipmap?: boolean | undefined,
  112664. /**
  112665. * Defines the explicit list of files (undefined by default)
  112666. */
  112667. files?: string[] | undefined);
  112668. /**
  112669. * Execute the current task
  112670. * @param scene defines the scene where you want your assets to be loaded
  112671. * @param onSuccess is a callback called when the task is successfully executed
  112672. * @param onError is a callback called if an error occurs
  112673. */
  112674. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112675. }
  112676. /**
  112677. * Define a task used by AssetsManager to load HDR cube textures
  112678. */
  112679. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  112680. /**
  112681. * Defines the name of the task
  112682. */
  112683. name: string;
  112684. /**
  112685. * Defines the location of the file to load
  112686. */
  112687. url: string;
  112688. /**
  112689. * Defines the desired size (the more it increases the longer the generation will be)
  112690. */
  112691. size: number;
  112692. /**
  112693. * Defines if mipmaps should not be generated (default is false)
  112694. */
  112695. noMipmap: boolean;
  112696. /**
  112697. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  112698. */
  112699. generateHarmonics: boolean;
  112700. /**
  112701. * 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)
  112702. */
  112703. gammaSpace: boolean;
  112704. /**
  112705. * Internal Use Only
  112706. */
  112707. reserved: boolean;
  112708. /**
  112709. * Gets the loaded texture
  112710. */
  112711. texture: HDRCubeTexture;
  112712. /**
  112713. * Callback called when the task is successful
  112714. */
  112715. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  112716. /**
  112717. * Callback called when the task is successful
  112718. */
  112719. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  112720. /**
  112721. * Creates a new HDRCubeTextureAssetTask object
  112722. * @param name defines the name of the task
  112723. * @param url defines the location of the file to load
  112724. * @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.
  112725. * @param noMipmap defines if mipmaps should not be generated (default is false)
  112726. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  112727. * @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)
  112728. * @param reserved Internal use only
  112729. */
  112730. constructor(
  112731. /**
  112732. * Defines the name of the task
  112733. */
  112734. name: string,
  112735. /**
  112736. * Defines the location of the file to load
  112737. */
  112738. url: string,
  112739. /**
  112740. * Defines the desired size (the more it increases the longer the generation will be)
  112741. */
  112742. size: number,
  112743. /**
  112744. * Defines if mipmaps should not be generated (default is false)
  112745. */
  112746. noMipmap?: boolean,
  112747. /**
  112748. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  112749. */
  112750. generateHarmonics?: boolean,
  112751. /**
  112752. * 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)
  112753. */
  112754. gammaSpace?: boolean,
  112755. /**
  112756. * Internal Use Only
  112757. */
  112758. reserved?: boolean);
  112759. /**
  112760. * Execute the current task
  112761. * @param scene defines the scene where you want your assets to be loaded
  112762. * @param onSuccess is a callback called when the task is successfully executed
  112763. * @param onError is a callback called if an error occurs
  112764. */
  112765. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112766. }
  112767. /**
  112768. * This class can be used to easily import assets into a scene
  112769. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  112770. */
  112771. export class AssetsManager {
  112772. private _scene;
  112773. private _isLoading;
  112774. protected _tasks: AbstractAssetTask[];
  112775. protected _waitingTasksCount: number;
  112776. protected _totalTasksCount: number;
  112777. /**
  112778. * Callback called when all tasks are processed
  112779. */
  112780. onFinish: (tasks: AbstractAssetTask[]) => void;
  112781. /**
  112782. * Callback called when a task is successful
  112783. */
  112784. onTaskSuccess: (task: AbstractAssetTask) => void;
  112785. /**
  112786. * Callback called when a task had an error
  112787. */
  112788. onTaskError: (task: AbstractAssetTask) => void;
  112789. /**
  112790. * Callback called when a task is done (whatever the result is)
  112791. */
  112792. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  112793. /**
  112794. * Observable called when all tasks are processed
  112795. */
  112796. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  112797. /**
  112798. * Observable called when a task had an error
  112799. */
  112800. onTaskErrorObservable: Observable<AbstractAssetTask>;
  112801. /**
  112802. * Observable called when all tasks were executed
  112803. */
  112804. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  112805. /**
  112806. * Observable called when a task is done (whatever the result is)
  112807. */
  112808. onProgressObservable: Observable<IAssetsProgressEvent>;
  112809. /**
  112810. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  112811. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  112812. */
  112813. useDefaultLoadingScreen: boolean;
  112814. /**
  112815. * Creates a new AssetsManager
  112816. * @param scene defines the scene to work on
  112817. */
  112818. constructor(scene: Scene);
  112819. /**
  112820. * Add a MeshAssetTask to the list of active tasks
  112821. * @param taskName defines the name of the new task
  112822. * @param meshesNames defines the name of meshes to load
  112823. * @param rootUrl defines the root url to use to locate files
  112824. * @param sceneFilename defines the filename of the scene file
  112825. * @returns a new MeshAssetTask object
  112826. */
  112827. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  112828. /**
  112829. * Add a TextFileAssetTask to the list of active tasks
  112830. * @param taskName defines the name of the new task
  112831. * @param url defines the url of the file to load
  112832. * @returns a new TextFileAssetTask object
  112833. */
  112834. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  112835. /**
  112836. * Add a BinaryFileAssetTask to the list of active tasks
  112837. * @param taskName defines the name of the new task
  112838. * @param url defines the url of the file to load
  112839. * @returns a new BinaryFileAssetTask object
  112840. */
  112841. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  112842. /**
  112843. * Add a ImageAssetTask to the list of active tasks
  112844. * @param taskName defines the name of the new task
  112845. * @param url defines the url of the file to load
  112846. * @returns a new ImageAssetTask object
  112847. */
  112848. addImageTask(taskName: string, url: string): ImageAssetTask;
  112849. /**
  112850. * Add a TextureAssetTask to the list of active tasks
  112851. * @param taskName defines the name of the new task
  112852. * @param url defines the url of the file to load
  112853. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  112854. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  112855. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  112856. * @returns a new TextureAssetTask object
  112857. */
  112858. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  112859. /**
  112860. * Add a CubeTextureAssetTask to the list of active tasks
  112861. * @param taskName defines the name of the new task
  112862. * @param url defines the url of the file to load
  112863. * @param extensions defines the extension to use to load the cube map (can be null)
  112864. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  112865. * @param files defines the list of files to load (can be null)
  112866. * @returns a new CubeTextureAssetTask object
  112867. */
  112868. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  112869. /**
  112870. *
  112871. * Add a HDRCubeTextureAssetTask to the list of active tasks
  112872. * @param taskName defines the name of the new task
  112873. * @param url defines the url of the file to load
  112874. * @param size defines the size you want for the cubemap (can be null)
  112875. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  112876. * @param generateHarmonics defines if you want to automatically generate (true by default)
  112877. * @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)
  112878. * @param reserved Internal use only
  112879. * @returns a new HDRCubeTextureAssetTask object
  112880. */
  112881. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  112882. /**
  112883. * Remove a task from the assets manager.
  112884. * @param task the task to remove
  112885. */
  112886. removeTask(task: AbstractAssetTask): void;
  112887. private _decreaseWaitingTasksCount;
  112888. private _runTask;
  112889. /**
  112890. * Reset the AssetsManager and remove all tasks
  112891. * @return the current instance of the AssetsManager
  112892. */
  112893. reset(): AssetsManager;
  112894. /**
  112895. * Start the loading process
  112896. * @return the current instance of the AssetsManager
  112897. */
  112898. load(): AssetsManager;
  112899. /**
  112900. * Start the loading process as an async operation
  112901. * @return a promise returning the list of failed tasks
  112902. */
  112903. loadAsync(): Promise<void>;
  112904. }
  112905. }
  112906. declare module BABYLON {
  112907. /**
  112908. * Wrapper class for promise with external resolve and reject.
  112909. */
  112910. export class Deferred<T> {
  112911. /**
  112912. * The promise associated with this deferred object.
  112913. */
  112914. readonly promise: Promise<T>;
  112915. private _resolve;
  112916. private _reject;
  112917. /**
  112918. * The resolve method of the promise associated with this deferred object.
  112919. */
  112920. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  112921. /**
  112922. * The reject method of the promise associated with this deferred object.
  112923. */
  112924. readonly reject: (reason?: any) => void;
  112925. /**
  112926. * Constructor for this deferred object.
  112927. */
  112928. constructor();
  112929. }
  112930. }
  112931. declare module BABYLON {
  112932. /**
  112933. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  112934. */
  112935. export class MeshExploder {
  112936. private _centerMesh;
  112937. private _meshes;
  112938. private _meshesOrigins;
  112939. private _toCenterVectors;
  112940. private _scaledDirection;
  112941. private _newPosition;
  112942. private _centerPosition;
  112943. /**
  112944. * Explodes meshes from a center mesh.
  112945. * @param meshes The meshes to explode.
  112946. * @param centerMesh The mesh to be center of explosion.
  112947. */
  112948. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  112949. private _setCenterMesh;
  112950. /**
  112951. * Get class name
  112952. * @returns "MeshExploder"
  112953. */
  112954. getClassName(): string;
  112955. /**
  112956. * "Exploded meshes"
  112957. * @returns Array of meshes with the centerMesh at index 0.
  112958. */
  112959. getMeshes(): Array<Mesh>;
  112960. /**
  112961. * Explodes meshes giving a specific direction
  112962. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  112963. */
  112964. explode(direction?: number): void;
  112965. }
  112966. }
  112967. declare module BABYLON {
  112968. /**
  112969. * Class used to help managing file picking and drag'n'drop
  112970. */
  112971. export class FilesInput {
  112972. /**
  112973. * List of files ready to be loaded
  112974. */
  112975. static readonly FilesToLoad: {
  112976. [key: string]: File;
  112977. };
  112978. /**
  112979. * Callback called when a file is processed
  112980. */
  112981. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  112982. private _engine;
  112983. private _currentScene;
  112984. private _sceneLoadedCallback;
  112985. private _progressCallback;
  112986. private _additionalRenderLoopLogicCallback;
  112987. private _textureLoadingCallback;
  112988. private _startingProcessingFilesCallback;
  112989. private _onReloadCallback;
  112990. private _errorCallback;
  112991. private _elementToMonitor;
  112992. private _sceneFileToLoad;
  112993. private _filesToLoad;
  112994. /**
  112995. * Creates a new FilesInput
  112996. * @param engine defines the rendering engine
  112997. * @param scene defines the hosting scene
  112998. * @param sceneLoadedCallback callback called when scene is loaded
  112999. * @param progressCallback callback called to track progress
  113000. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  113001. * @param textureLoadingCallback callback called when a texture is loading
  113002. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  113003. * @param onReloadCallback callback called when a reload is requested
  113004. * @param errorCallback callback call if an error occurs
  113005. */
  113006. 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);
  113007. private _dragEnterHandler;
  113008. private _dragOverHandler;
  113009. private _dropHandler;
  113010. /**
  113011. * Calls this function to listen to drag'n'drop events on a specific DOM element
  113012. * @param elementToMonitor defines the DOM element to track
  113013. */
  113014. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  113015. /**
  113016. * Release all associated resources
  113017. */
  113018. dispose(): void;
  113019. private renderFunction;
  113020. private drag;
  113021. private drop;
  113022. private _traverseFolder;
  113023. private _processFiles;
  113024. /**
  113025. * Load files from a drop event
  113026. * @param event defines the drop event to use as source
  113027. */
  113028. loadFiles(event: any): void;
  113029. private _processReload;
  113030. /**
  113031. * Reload the current scene from the loaded files
  113032. */
  113033. reload(): void;
  113034. }
  113035. }
  113036. declare module BABYLON {
  113037. /**
  113038. * Defines the root class used to create scene optimization to use with SceneOptimizer
  113039. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113040. */
  113041. export class SceneOptimization {
  113042. /**
  113043. * Defines the priority of this optimization (0 by default which means first in the list)
  113044. */
  113045. priority: number;
  113046. /**
  113047. * Gets a string describing the action executed by the current optimization
  113048. * @returns description string
  113049. */
  113050. getDescription(): string;
  113051. /**
  113052. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113053. * @param scene defines the current scene where to apply this optimization
  113054. * @param optimizer defines the current optimizer
  113055. * @returns true if everything that can be done was applied
  113056. */
  113057. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113058. /**
  113059. * Creates the SceneOptimization object
  113060. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  113061. * @param desc defines the description associated with the optimization
  113062. */
  113063. constructor(
  113064. /**
  113065. * Defines the priority of this optimization (0 by default which means first in the list)
  113066. */
  113067. priority?: number);
  113068. }
  113069. /**
  113070. * Defines an optimization used to reduce the size of render target textures
  113071. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113072. */
  113073. export class TextureOptimization extends SceneOptimization {
  113074. /**
  113075. * Defines the priority of this optimization (0 by default which means first in the list)
  113076. */
  113077. priority: number;
  113078. /**
  113079. * 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
  113080. */
  113081. maximumSize: number;
  113082. /**
  113083. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  113084. */
  113085. step: number;
  113086. /**
  113087. * Gets a string describing the action executed by the current optimization
  113088. * @returns description string
  113089. */
  113090. getDescription(): string;
  113091. /**
  113092. * Creates the TextureOptimization object
  113093. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  113094. * @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
  113095. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  113096. */
  113097. constructor(
  113098. /**
  113099. * Defines the priority of this optimization (0 by default which means first in the list)
  113100. */
  113101. priority?: number,
  113102. /**
  113103. * 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
  113104. */
  113105. maximumSize?: number,
  113106. /**
  113107. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  113108. */
  113109. step?: number);
  113110. /**
  113111. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113112. * @param scene defines the current scene where to apply this optimization
  113113. * @param optimizer defines the current optimizer
  113114. * @returns true if everything that can be done was applied
  113115. */
  113116. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113117. }
  113118. /**
  113119. * Defines an optimization used to increase or decrease the rendering resolution
  113120. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113121. */
  113122. export class HardwareScalingOptimization extends SceneOptimization {
  113123. /**
  113124. * Defines the priority of this optimization (0 by default which means first in the list)
  113125. */
  113126. priority: number;
  113127. /**
  113128. * Defines the maximum scale to use (2 by default)
  113129. */
  113130. maximumScale: number;
  113131. /**
  113132. * Defines the step to use between two passes (0.5 by default)
  113133. */
  113134. step: number;
  113135. private _currentScale;
  113136. private _directionOffset;
  113137. /**
  113138. * Gets a string describing the action executed by the current optimization
  113139. * @return description string
  113140. */
  113141. getDescription(): string;
  113142. /**
  113143. * Creates the HardwareScalingOptimization object
  113144. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  113145. * @param maximumScale defines the maximum scale to use (2 by default)
  113146. * @param step defines the step to use between two passes (0.5 by default)
  113147. */
  113148. constructor(
  113149. /**
  113150. * Defines the priority of this optimization (0 by default which means first in the list)
  113151. */
  113152. priority?: number,
  113153. /**
  113154. * Defines the maximum scale to use (2 by default)
  113155. */
  113156. maximumScale?: number,
  113157. /**
  113158. * Defines the step to use between two passes (0.5 by default)
  113159. */
  113160. step?: number);
  113161. /**
  113162. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113163. * @param scene defines the current scene where to apply this optimization
  113164. * @param optimizer defines the current optimizer
  113165. * @returns true if everything that can be done was applied
  113166. */
  113167. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113168. }
  113169. /**
  113170. * Defines an optimization used to remove shadows
  113171. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113172. */
  113173. export class ShadowsOptimization extends SceneOptimization {
  113174. /**
  113175. * Gets a string describing the action executed by the current optimization
  113176. * @return description string
  113177. */
  113178. getDescription(): string;
  113179. /**
  113180. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113181. * @param scene defines the current scene where to apply this optimization
  113182. * @param optimizer defines the current optimizer
  113183. * @returns true if everything that can be done was applied
  113184. */
  113185. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113186. }
  113187. /**
  113188. * Defines an optimization used to turn post-processes off
  113189. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113190. */
  113191. export class PostProcessesOptimization extends SceneOptimization {
  113192. /**
  113193. * Gets a string describing the action executed by the current optimization
  113194. * @return description string
  113195. */
  113196. getDescription(): string;
  113197. /**
  113198. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113199. * @param scene defines the current scene where to apply this optimization
  113200. * @param optimizer defines the current optimizer
  113201. * @returns true if everything that can be done was applied
  113202. */
  113203. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113204. }
  113205. /**
  113206. * Defines an optimization used to turn lens flares off
  113207. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113208. */
  113209. export class LensFlaresOptimization extends SceneOptimization {
  113210. /**
  113211. * Gets a string describing the action executed by the current optimization
  113212. * @return description string
  113213. */
  113214. getDescription(): string;
  113215. /**
  113216. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113217. * @param scene defines the current scene where to apply this optimization
  113218. * @param optimizer defines the current optimizer
  113219. * @returns true if everything that can be done was applied
  113220. */
  113221. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113222. }
  113223. /**
  113224. * Defines an optimization based on user defined callback.
  113225. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113226. */
  113227. export class CustomOptimization extends SceneOptimization {
  113228. /**
  113229. * Callback called to apply the custom optimization.
  113230. */
  113231. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  113232. /**
  113233. * Callback called to get custom description
  113234. */
  113235. onGetDescription: () => string;
  113236. /**
  113237. * Gets a string describing the action executed by the current optimization
  113238. * @returns description string
  113239. */
  113240. getDescription(): string;
  113241. /**
  113242. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113243. * @param scene defines the current scene where to apply this optimization
  113244. * @param optimizer defines the current optimizer
  113245. * @returns true if everything that can be done was applied
  113246. */
  113247. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113248. }
  113249. /**
  113250. * Defines an optimization used to turn particles off
  113251. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113252. */
  113253. export class ParticlesOptimization extends SceneOptimization {
  113254. /**
  113255. * Gets a string describing the action executed by the current optimization
  113256. * @return description string
  113257. */
  113258. getDescription(): string;
  113259. /**
  113260. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113261. * @param scene defines the current scene where to apply this optimization
  113262. * @param optimizer defines the current optimizer
  113263. * @returns true if everything that can be done was applied
  113264. */
  113265. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113266. }
  113267. /**
  113268. * Defines an optimization used to turn render targets off
  113269. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113270. */
  113271. export class RenderTargetsOptimization extends SceneOptimization {
  113272. /**
  113273. * Gets a string describing the action executed by the current optimization
  113274. * @return description string
  113275. */
  113276. getDescription(): string;
  113277. /**
  113278. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113279. * @param scene defines the current scene where to apply this optimization
  113280. * @param optimizer defines the current optimizer
  113281. * @returns true if everything that can be done was applied
  113282. */
  113283. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113284. }
  113285. /**
  113286. * Defines an optimization used to merge meshes with compatible materials
  113287. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113288. */
  113289. export class MergeMeshesOptimization extends SceneOptimization {
  113290. private static _UpdateSelectionTree;
  113291. /**
  113292. * Gets or sets a boolean which defines if optimization octree has to be updated
  113293. */
  113294. /**
  113295. * Gets or sets a boolean which defines if optimization octree has to be updated
  113296. */
  113297. static UpdateSelectionTree: boolean;
  113298. /**
  113299. * Gets a string describing the action executed by the current optimization
  113300. * @return description string
  113301. */
  113302. getDescription(): string;
  113303. private _canBeMerged;
  113304. /**
  113305. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113306. * @param scene defines the current scene where to apply this optimization
  113307. * @param optimizer defines the current optimizer
  113308. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  113309. * @returns true if everything that can be done was applied
  113310. */
  113311. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  113312. }
  113313. /**
  113314. * Defines a list of options used by SceneOptimizer
  113315. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113316. */
  113317. export class SceneOptimizerOptions {
  113318. /**
  113319. * Defines the target frame rate to reach (60 by default)
  113320. */
  113321. targetFrameRate: number;
  113322. /**
  113323. * Defines the interval between two checkes (2000ms by default)
  113324. */
  113325. trackerDuration: number;
  113326. /**
  113327. * Gets the list of optimizations to apply
  113328. */
  113329. optimizations: SceneOptimization[];
  113330. /**
  113331. * Creates a new list of options used by SceneOptimizer
  113332. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  113333. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  113334. */
  113335. constructor(
  113336. /**
  113337. * Defines the target frame rate to reach (60 by default)
  113338. */
  113339. targetFrameRate?: number,
  113340. /**
  113341. * Defines the interval between two checkes (2000ms by default)
  113342. */
  113343. trackerDuration?: number);
  113344. /**
  113345. * Add a new optimization
  113346. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  113347. * @returns the current SceneOptimizerOptions
  113348. */
  113349. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  113350. /**
  113351. * Add a new custom optimization
  113352. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  113353. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  113354. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  113355. * @returns the current SceneOptimizerOptions
  113356. */
  113357. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  113358. /**
  113359. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  113360. * @param targetFrameRate defines the target frame rate (60 by default)
  113361. * @returns a SceneOptimizerOptions object
  113362. */
  113363. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  113364. /**
  113365. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  113366. * @param targetFrameRate defines the target frame rate (60 by default)
  113367. * @returns a SceneOptimizerOptions object
  113368. */
  113369. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  113370. /**
  113371. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  113372. * @param targetFrameRate defines the target frame rate (60 by default)
  113373. * @returns a SceneOptimizerOptions object
  113374. */
  113375. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  113376. }
  113377. /**
  113378. * Class used to run optimizations in order to reach a target frame rate
  113379. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113380. */
  113381. export class SceneOptimizer implements IDisposable {
  113382. private _isRunning;
  113383. private _options;
  113384. private _scene;
  113385. private _currentPriorityLevel;
  113386. private _targetFrameRate;
  113387. private _trackerDuration;
  113388. private _currentFrameRate;
  113389. private _sceneDisposeObserver;
  113390. private _improvementMode;
  113391. /**
  113392. * Defines an observable called when the optimizer reaches the target frame rate
  113393. */
  113394. onSuccessObservable: Observable<SceneOptimizer>;
  113395. /**
  113396. * Defines an observable called when the optimizer enables an optimization
  113397. */
  113398. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  113399. /**
  113400. * Defines an observable called when the optimizer is not able to reach the target frame rate
  113401. */
  113402. onFailureObservable: Observable<SceneOptimizer>;
  113403. /**
  113404. * Gets a boolean indicating if the optimizer is in improvement mode
  113405. */
  113406. readonly isInImprovementMode: boolean;
  113407. /**
  113408. * Gets the current priority level (0 at start)
  113409. */
  113410. readonly currentPriorityLevel: number;
  113411. /**
  113412. * Gets the current frame rate checked by the SceneOptimizer
  113413. */
  113414. readonly currentFrameRate: number;
  113415. /**
  113416. * Gets or sets the current target frame rate (60 by default)
  113417. */
  113418. /**
  113419. * Gets or sets the current target frame rate (60 by default)
  113420. */
  113421. targetFrameRate: number;
  113422. /**
  113423. * Gets or sets the current interval between two checks (every 2000ms by default)
  113424. */
  113425. /**
  113426. * Gets or sets the current interval between two checks (every 2000ms by default)
  113427. */
  113428. trackerDuration: number;
  113429. /**
  113430. * Gets the list of active optimizations
  113431. */
  113432. readonly optimizations: SceneOptimization[];
  113433. /**
  113434. * Creates a new SceneOptimizer
  113435. * @param scene defines the scene to work on
  113436. * @param options defines the options to use with the SceneOptimizer
  113437. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  113438. * @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)
  113439. */
  113440. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  113441. /**
  113442. * Stops the current optimizer
  113443. */
  113444. stop(): void;
  113445. /**
  113446. * Reset the optimizer to initial step (current priority level = 0)
  113447. */
  113448. reset(): void;
  113449. /**
  113450. * Start the optimizer. By default it will try to reach a specific framerate
  113451. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  113452. */
  113453. start(): void;
  113454. private _checkCurrentState;
  113455. /**
  113456. * Release all resources
  113457. */
  113458. dispose(): void;
  113459. /**
  113460. * Helper function to create a SceneOptimizer with one single line of code
  113461. * @param scene defines the scene to work on
  113462. * @param options defines the options to use with the SceneOptimizer
  113463. * @param onSuccess defines a callback to call on success
  113464. * @param onFailure defines a callback to call on failure
  113465. * @returns the new SceneOptimizer object
  113466. */
  113467. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  113468. }
  113469. }
  113470. declare module BABYLON {
  113471. /**
  113472. * Class used to serialize a scene into a string
  113473. */
  113474. export class SceneSerializer {
  113475. /**
  113476. * Clear cache used by a previous serialization
  113477. */
  113478. static ClearCache(): void;
  113479. /**
  113480. * Serialize a scene into a JSON compatible object
  113481. * @param scene defines the scene to serialize
  113482. * @returns a JSON compatible object
  113483. */
  113484. static Serialize(scene: Scene): any;
  113485. /**
  113486. * Serialize a mesh into a JSON compatible object
  113487. * @param toSerialize defines the mesh to serialize
  113488. * @param withParents defines if parents must be serialized as well
  113489. * @param withChildren defines if children must be serialized as well
  113490. * @returns a JSON compatible object
  113491. */
  113492. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  113493. }
  113494. }
  113495. declare module BABYLON {
  113496. /**
  113497. * This represents the different options avilable for the video capture.
  113498. */
  113499. export interface VideoRecorderOptions {
  113500. /** Defines the mime type of the video */
  113501. mimeType: string;
  113502. /** Defines the video the video should be recorded at */
  113503. fps: number;
  113504. /** Defines the chunk size for the recording data */
  113505. recordChunckSize: number;
  113506. /** The audio tracks to attach to the record */
  113507. audioTracks?: MediaStreamTrack[];
  113508. }
  113509. /**
  113510. * This can helps recording videos from BabylonJS.
  113511. * This is based on the available WebRTC functionalities of the browser.
  113512. *
  113513. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  113514. */
  113515. export class VideoRecorder {
  113516. private static readonly _defaultOptions;
  113517. /**
  113518. * Returns wehther or not the VideoRecorder is available in your browser.
  113519. * @param engine Defines the Babylon Engine to check the support for
  113520. * @returns true if supported otherwise false
  113521. */
  113522. static IsSupported(engine: Engine): boolean;
  113523. private readonly _options;
  113524. private _canvas;
  113525. private _mediaRecorder;
  113526. private _recordedChunks;
  113527. private _fileName;
  113528. private _resolve;
  113529. private _reject;
  113530. /**
  113531. * True wether a recording is already in progress.
  113532. */
  113533. readonly isRecording: boolean;
  113534. /**
  113535. * Create a new VideoCapture object which can help converting what you see in Babylon to
  113536. * a video file.
  113537. * @param engine Defines the BabylonJS Engine you wish to record
  113538. * @param options Defines options that can be used to customized the capture
  113539. */
  113540. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  113541. /**
  113542. * Stops the current recording before the default capture timeout passed in the startRecording
  113543. * functions.
  113544. */
  113545. stopRecording(): void;
  113546. /**
  113547. * Starts recording the canvas for a max duration specified in parameters.
  113548. * @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.
  113549. * @param maxDuration Defines the maximum recording time in seconds.
  113550. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  113551. * @return a promise callback at the end of the recording with the video data in Blob.
  113552. */
  113553. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  113554. /**
  113555. * Releases internal resources used during the recording.
  113556. */
  113557. dispose(): void;
  113558. private _handleDataAvailable;
  113559. private _handleError;
  113560. private _handleStop;
  113561. }
  113562. }
  113563. declare module BABYLON {
  113564. /**
  113565. * Helper class to push actions to a pool of workers.
  113566. */
  113567. export class WorkerPool implements IDisposable {
  113568. private _workerInfos;
  113569. private _pendingActions;
  113570. /**
  113571. * Constructor
  113572. * @param workers Array of workers to use for actions
  113573. */
  113574. constructor(workers: Array<Worker>);
  113575. /**
  113576. * Terminates all workers and clears any pending actions.
  113577. */
  113578. dispose(): void;
  113579. /**
  113580. * Pushes an action to the worker pool. If all the workers are active, the action will be
  113581. * pended until a worker has completed its action.
  113582. * @param action The action to perform. Call onComplete when the action is complete.
  113583. */
  113584. push(action: (worker: Worker, onComplete: () => void) => void): void;
  113585. private _execute;
  113586. }
  113587. }
  113588. declare module BABYLON {
  113589. /**
  113590. * Class containing a set of static utilities functions for screenshots
  113591. */
  113592. export class ScreenshotTools {
  113593. /**
  113594. * Captures a screenshot of the current rendering
  113595. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  113596. * @param engine defines the rendering engine
  113597. * @param camera defines the source camera
  113598. * @param size This parameter can be set to a single number or to an object with the
  113599. * following (optional) properties: precision, width, height. If a single number is passed,
  113600. * it will be used for both width and height. If an object is passed, the screenshot size
  113601. * will be derived from the parameters. The precision property is a multiplier allowing
  113602. * rendering at a higher or lower resolution
  113603. * @param successCallback defines the callback receives a single parameter which contains the
  113604. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  113605. * src parameter of an <img> to display it
  113606. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  113607. * Check your browser for supported MIME types
  113608. */
  113609. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  113610. /**
  113611. * Generates an image screenshot from the specified camera.
  113612. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  113613. * @param engine The engine to use for rendering
  113614. * @param camera The camera to use for rendering
  113615. * @param size This parameter can be set to a single number or to an object with the
  113616. * following (optional) properties: precision, width, height. If a single number is passed,
  113617. * it will be used for both width and height. If an object is passed, the screenshot size
  113618. * will be derived from the parameters. The precision property is a multiplier allowing
  113619. * rendering at a higher or lower resolution
  113620. * @param successCallback The callback receives a single parameter which contains the
  113621. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  113622. * src parameter of an <img> to display it
  113623. * @param mimeType The MIME type of the screenshot image (default: image/png).
  113624. * Check your browser for supported MIME types
  113625. * @param samples Texture samples (default: 1)
  113626. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  113627. * @param fileName A name for for the downloaded file.
  113628. */
  113629. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  113630. }
  113631. }
  113632. declare module BABYLON {
  113633. /**
  113634. * A cursor which tracks a point on a path
  113635. */
  113636. export class PathCursor {
  113637. private path;
  113638. /**
  113639. * Stores path cursor callbacks for when an onchange event is triggered
  113640. */
  113641. private _onchange;
  113642. /**
  113643. * The value of the path cursor
  113644. */
  113645. value: number;
  113646. /**
  113647. * The animation array of the path cursor
  113648. */
  113649. animations: Animation[];
  113650. /**
  113651. * Initializes the path cursor
  113652. * @param path The path to track
  113653. */
  113654. constructor(path: Path2);
  113655. /**
  113656. * Gets the cursor point on the path
  113657. * @returns A point on the path cursor at the cursor location
  113658. */
  113659. getPoint(): Vector3;
  113660. /**
  113661. * Moves the cursor ahead by the step amount
  113662. * @param step The amount to move the cursor forward
  113663. * @returns This path cursor
  113664. */
  113665. moveAhead(step?: number): PathCursor;
  113666. /**
  113667. * Moves the cursor behind by the step amount
  113668. * @param step The amount to move the cursor back
  113669. * @returns This path cursor
  113670. */
  113671. moveBack(step?: number): PathCursor;
  113672. /**
  113673. * Moves the cursor by the step amount
  113674. * If the step amount is greater than one, an exception is thrown
  113675. * @param step The amount to move the cursor
  113676. * @returns This path cursor
  113677. */
  113678. move(step: number): PathCursor;
  113679. /**
  113680. * Ensures that the value is limited between zero and one
  113681. * @returns This path cursor
  113682. */
  113683. private ensureLimits;
  113684. /**
  113685. * Runs onchange callbacks on change (used by the animation engine)
  113686. * @returns This path cursor
  113687. */
  113688. private raiseOnChange;
  113689. /**
  113690. * Executes a function on change
  113691. * @param f A path cursor onchange callback
  113692. * @returns This path cursor
  113693. */
  113694. onchange(f: (cursor: PathCursor) => void): PathCursor;
  113695. }
  113696. }
  113697. declare module BABYLON {
  113698. /** @hidden */
  113699. export var blurPixelShader: {
  113700. name: string;
  113701. shader: string;
  113702. };
  113703. }
  113704. declare module BABYLON {
  113705. /** @hidden */
  113706. export var bones300Declaration: {
  113707. name: string;
  113708. shader: string;
  113709. };
  113710. }
  113711. declare module BABYLON {
  113712. /** @hidden */
  113713. export var instances300Declaration: {
  113714. name: string;
  113715. shader: string;
  113716. };
  113717. }
  113718. declare module BABYLON {
  113719. /** @hidden */
  113720. export var pointCloudVertexDeclaration: {
  113721. name: string;
  113722. shader: string;
  113723. };
  113724. }
  113725. // Mixins
  113726. interface Window {
  113727. mozIndexedDB: IDBFactory;
  113728. webkitIndexedDB: IDBFactory;
  113729. msIndexedDB: IDBFactory;
  113730. webkitURL: typeof URL;
  113731. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  113732. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  113733. WebGLRenderingContext: WebGLRenderingContext;
  113734. MSGesture: MSGesture;
  113735. CANNON: any;
  113736. AudioContext: AudioContext;
  113737. webkitAudioContext: AudioContext;
  113738. PointerEvent: any;
  113739. Math: Math;
  113740. Uint8Array: Uint8ArrayConstructor;
  113741. Float32Array: Float32ArrayConstructor;
  113742. mozURL: typeof URL;
  113743. msURL: typeof URL;
  113744. VRFrameData: any; // WebVR, from specs 1.1
  113745. DracoDecoderModule: any;
  113746. setImmediate(handler: (...args: any[]) => void): number;
  113747. }
  113748. interface HTMLCanvasElement {
  113749. requestPointerLock(): void;
  113750. msRequestPointerLock?(): void;
  113751. mozRequestPointerLock?(): void;
  113752. webkitRequestPointerLock?(): void;
  113753. /** Track wether a record is in progress */
  113754. isRecording: boolean;
  113755. /** Capture Stream method defined by some browsers */
  113756. captureStream(fps?: number): MediaStream;
  113757. }
  113758. interface CanvasRenderingContext2D {
  113759. msImageSmoothingEnabled: boolean;
  113760. }
  113761. interface MouseEvent {
  113762. mozMovementX: number;
  113763. mozMovementY: number;
  113764. webkitMovementX: number;
  113765. webkitMovementY: number;
  113766. msMovementX: number;
  113767. msMovementY: number;
  113768. }
  113769. interface Navigator {
  113770. mozGetVRDevices: (any: any) => any;
  113771. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  113772. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  113773. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  113774. webkitGetGamepads(): Gamepad[];
  113775. msGetGamepads(): Gamepad[];
  113776. webkitGamepads(): Gamepad[];
  113777. }
  113778. interface HTMLVideoElement {
  113779. mozSrcObject: any;
  113780. }
  113781. interface Math {
  113782. fround(x: number): number;
  113783. imul(a: number, b: number): number;
  113784. }
  113785. interface WebGLProgram {
  113786. context?: WebGLRenderingContext;
  113787. vertexShader?: WebGLShader;
  113788. fragmentShader?: WebGLShader;
  113789. isParallelCompiled: boolean;
  113790. onCompiled?: () => void;
  113791. }
  113792. interface WebGLRenderingContext {
  113793. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  113794. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  113795. vertexAttribDivisor(index: number, divisor: number): void;
  113796. createVertexArray(): any;
  113797. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  113798. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  113799. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  113800. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  113801. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  113802. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  113803. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  113804. // Queries
  113805. createQuery(): WebGLQuery;
  113806. deleteQuery(query: WebGLQuery): void;
  113807. beginQuery(target: number, query: WebGLQuery): void;
  113808. endQuery(target: number): void;
  113809. getQueryParameter(query: WebGLQuery, pname: number): any;
  113810. getQuery(target: number, pname: number): any;
  113811. MAX_SAMPLES: number;
  113812. RGBA8: number;
  113813. READ_FRAMEBUFFER: number;
  113814. DRAW_FRAMEBUFFER: number;
  113815. UNIFORM_BUFFER: number;
  113816. HALF_FLOAT_OES: number;
  113817. RGBA16F: number;
  113818. RGBA32F: number;
  113819. R32F: number;
  113820. RG32F: number;
  113821. RGB32F: number;
  113822. R16F: number;
  113823. RG16F: number;
  113824. RGB16F: number;
  113825. RED: number;
  113826. RG: number;
  113827. R8: number;
  113828. RG8: number;
  113829. UNSIGNED_INT_24_8: number;
  113830. DEPTH24_STENCIL8: number;
  113831. /* Multiple Render Targets */
  113832. drawBuffers(buffers: number[]): void;
  113833. readBuffer(src: number): void;
  113834. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  113835. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  113836. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  113837. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  113838. // Occlusion Query
  113839. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  113840. ANY_SAMPLES_PASSED: number;
  113841. QUERY_RESULT_AVAILABLE: number;
  113842. QUERY_RESULT: number;
  113843. }
  113844. interface WebGLBuffer {
  113845. references: number;
  113846. capacity: number;
  113847. is32Bits: boolean;
  113848. }
  113849. interface WebGLProgram {
  113850. transformFeedback?: WebGLTransformFeedback | null;
  113851. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  113852. }
  113853. interface EXT_disjoint_timer_query {
  113854. QUERY_COUNTER_BITS_EXT: number;
  113855. TIME_ELAPSED_EXT: number;
  113856. TIMESTAMP_EXT: number;
  113857. GPU_DISJOINT_EXT: number;
  113858. QUERY_RESULT_EXT: number;
  113859. QUERY_RESULT_AVAILABLE_EXT: number;
  113860. queryCounterEXT(query: WebGLQuery, target: number): void;
  113861. createQueryEXT(): WebGLQuery;
  113862. beginQueryEXT(target: number, query: WebGLQuery): void;
  113863. endQueryEXT(target: number): void;
  113864. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  113865. deleteQueryEXT(query: WebGLQuery): void;
  113866. }
  113867. interface WebGLUniformLocation {
  113868. _currentState: any;
  113869. }
  113870. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  113871. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  113872. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  113873. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  113874. interface WebGLRenderingContext {
  113875. readonly RASTERIZER_DISCARD: number;
  113876. readonly DEPTH_COMPONENT24: number;
  113877. readonly TEXTURE_3D: number;
  113878. readonly TEXTURE_2D_ARRAY: number;
  113879. readonly TEXTURE_COMPARE_FUNC: number;
  113880. readonly TEXTURE_COMPARE_MODE: number;
  113881. readonly COMPARE_REF_TO_TEXTURE: number;
  113882. readonly TEXTURE_WRAP_R: number;
  113883. readonly HALF_FLOAT: number;
  113884. readonly RGB8: number;
  113885. readonly RED_INTEGER: number;
  113886. readonly RG_INTEGER: number;
  113887. readonly RGB_INTEGER: number;
  113888. readonly RGBA_INTEGER: number;
  113889. readonly R8_SNORM: number;
  113890. readonly RG8_SNORM: number;
  113891. readonly RGB8_SNORM: number;
  113892. readonly RGBA8_SNORM: number;
  113893. readonly R8I: number;
  113894. readonly RG8I: number;
  113895. readonly RGB8I: number;
  113896. readonly RGBA8I: number;
  113897. readonly R8UI: number;
  113898. readonly RG8UI: number;
  113899. readonly RGB8UI: number;
  113900. readonly RGBA8UI: number;
  113901. readonly R16I: number;
  113902. readonly RG16I: number;
  113903. readonly RGB16I: number;
  113904. readonly RGBA16I: number;
  113905. readonly R16UI: number;
  113906. readonly RG16UI: number;
  113907. readonly RGB16UI: number;
  113908. readonly RGBA16UI: number;
  113909. readonly R32I: number;
  113910. readonly RG32I: number;
  113911. readonly RGB32I: number;
  113912. readonly RGBA32I: number;
  113913. readonly R32UI: number;
  113914. readonly RG32UI: number;
  113915. readonly RGB32UI: number;
  113916. readonly RGBA32UI: number;
  113917. readonly RGB10_A2UI: number;
  113918. readonly R11F_G11F_B10F: number;
  113919. readonly RGB9_E5: number;
  113920. readonly RGB10_A2: number;
  113921. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  113922. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  113923. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  113924. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  113925. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  113926. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  113927. 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;
  113928. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  113929. readonly TRANSFORM_FEEDBACK: number;
  113930. readonly INTERLEAVED_ATTRIBS: number;
  113931. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  113932. createTransformFeedback(): WebGLTransformFeedback;
  113933. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  113934. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  113935. beginTransformFeedback(primitiveMode: number): void;
  113936. endTransformFeedback(): void;
  113937. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  113938. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  113939. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  113940. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  113941. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  113942. }
  113943. interface ImageBitmap {
  113944. readonly width: number;
  113945. readonly height: number;
  113946. close(): void;
  113947. }
  113948. interface WebGLQuery extends WebGLObject {
  113949. }
  113950. declare var WebGLQuery: {
  113951. prototype: WebGLQuery;
  113952. new(): WebGLQuery;
  113953. };
  113954. interface WebGLSampler extends WebGLObject {
  113955. }
  113956. declare var WebGLSampler: {
  113957. prototype: WebGLSampler;
  113958. new(): WebGLSampler;
  113959. };
  113960. interface WebGLSync extends WebGLObject {
  113961. }
  113962. declare var WebGLSync: {
  113963. prototype: WebGLSync;
  113964. new(): WebGLSync;
  113965. };
  113966. interface WebGLTransformFeedback extends WebGLObject {
  113967. }
  113968. declare var WebGLTransformFeedback: {
  113969. prototype: WebGLTransformFeedback;
  113970. new(): WebGLTransformFeedback;
  113971. };
  113972. interface WebGLVertexArrayObject extends WebGLObject {
  113973. }
  113974. declare var WebGLVertexArrayObject: {
  113975. prototype: WebGLVertexArrayObject;
  113976. new(): WebGLVertexArrayObject;
  113977. };
  113978. // Type definitions for WebVR API
  113979. // Project: https://w3c.github.io/webvr/
  113980. // Definitions by: six a <https://github.com/lostfictions>
  113981. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  113982. interface VRDisplay extends EventTarget {
  113983. /**
  113984. * Dictionary of capabilities describing the VRDisplay.
  113985. */
  113986. readonly capabilities: VRDisplayCapabilities;
  113987. /**
  113988. * z-depth defining the far plane of the eye view frustum
  113989. * enables mapping of values in the render target depth
  113990. * attachment to scene coordinates. Initially set to 10000.0.
  113991. */
  113992. depthFar: number;
  113993. /**
  113994. * z-depth defining the near plane of the eye view frustum
  113995. * enables mapping of values in the render target depth
  113996. * attachment to scene coordinates. Initially set to 0.01.
  113997. */
  113998. depthNear: number;
  113999. /**
  114000. * An identifier for this distinct VRDisplay. Used as an
  114001. * association point in the Gamepad API.
  114002. */
  114003. readonly displayId: number;
  114004. /**
  114005. * A display name, a user-readable name identifying it.
  114006. */
  114007. readonly displayName: string;
  114008. readonly isConnected: boolean;
  114009. readonly isPresenting: boolean;
  114010. /**
  114011. * If this VRDisplay supports room-scale experiences, the optional
  114012. * stage attribute contains details on the room-scale parameters.
  114013. */
  114014. readonly stageParameters: VRStageParameters | null;
  114015. /**
  114016. * Passing the value returned by `requestAnimationFrame` to
  114017. * `cancelAnimationFrame` will unregister the callback.
  114018. * @param handle Define the hanle of the request to cancel
  114019. */
  114020. cancelAnimationFrame(handle: number): void;
  114021. /**
  114022. * Stops presenting to the VRDisplay.
  114023. * @returns a promise to know when it stopped
  114024. */
  114025. exitPresent(): Promise<void>;
  114026. /**
  114027. * Return the current VREyeParameters for the given eye.
  114028. * @param whichEye Define the eye we want the parameter for
  114029. * @returns the eye parameters
  114030. */
  114031. getEyeParameters(whichEye: string): VREyeParameters;
  114032. /**
  114033. * Populates the passed VRFrameData with the information required to render
  114034. * the current frame.
  114035. * @param frameData Define the data structure to populate
  114036. * @returns true if ok otherwise false
  114037. */
  114038. getFrameData(frameData: VRFrameData): boolean;
  114039. /**
  114040. * Get the layers currently being presented.
  114041. * @returns the list of VR layers
  114042. */
  114043. getLayers(): VRLayer[];
  114044. /**
  114045. * Return a VRPose containing the future predicted pose of the VRDisplay
  114046. * when the current frame will be presented. The value returned will not
  114047. * change until JavaScript has returned control to the browser.
  114048. *
  114049. * The VRPose will contain the position, orientation, velocity,
  114050. * and acceleration of each of these properties.
  114051. * @returns the pose object
  114052. */
  114053. getPose(): VRPose;
  114054. /**
  114055. * Return the current instantaneous pose of the VRDisplay, with no
  114056. * prediction applied.
  114057. * @returns the current instantaneous pose
  114058. */
  114059. getImmediatePose(): VRPose;
  114060. /**
  114061. * The callback passed to `requestAnimationFrame` will be called
  114062. * any time a new frame should be rendered. When the VRDisplay is
  114063. * presenting the callback will be called at the native refresh
  114064. * rate of the HMD. When not presenting this function acts
  114065. * identically to how window.requestAnimationFrame acts. Content should
  114066. * make no assumptions of frame rate or vsync behavior as the HMD runs
  114067. * asynchronously from other displays and at differing refresh rates.
  114068. * @param callback Define the eaction to run next frame
  114069. * @returns the request handle it
  114070. */
  114071. requestAnimationFrame(callback: FrameRequestCallback): number;
  114072. /**
  114073. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  114074. * Repeat calls while already presenting will update the VRLayers being displayed.
  114075. * @param layers Define the list of layer to present
  114076. * @returns a promise to know when the request has been fulfilled
  114077. */
  114078. requestPresent(layers: VRLayer[]): Promise<void>;
  114079. /**
  114080. * Reset the pose for this display, treating its current position and
  114081. * orientation as the "origin/zero" values. VRPose.position,
  114082. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  114083. * updated when calling resetPose(). This should be called in only
  114084. * sitting-space experiences.
  114085. */
  114086. resetPose(): void;
  114087. /**
  114088. * The VRLayer provided to the VRDisplay will be captured and presented
  114089. * in the HMD. Calling this function has the same effect on the source
  114090. * canvas as any other operation that uses its source image, and canvases
  114091. * created without preserveDrawingBuffer set to true will be cleared.
  114092. * @param pose Define the pose to submit
  114093. */
  114094. submitFrame(pose?: VRPose): void;
  114095. }
  114096. declare var VRDisplay: {
  114097. prototype: VRDisplay;
  114098. new(): VRDisplay;
  114099. };
  114100. interface VRLayer {
  114101. leftBounds?: number[] | Float32Array | null;
  114102. rightBounds?: number[] | Float32Array | null;
  114103. source?: HTMLCanvasElement | null;
  114104. }
  114105. interface VRDisplayCapabilities {
  114106. readonly canPresent: boolean;
  114107. readonly hasExternalDisplay: boolean;
  114108. readonly hasOrientation: boolean;
  114109. readonly hasPosition: boolean;
  114110. readonly maxLayers: number;
  114111. }
  114112. interface VREyeParameters {
  114113. /** @deprecated */
  114114. readonly fieldOfView: VRFieldOfView;
  114115. readonly offset: Float32Array;
  114116. readonly renderHeight: number;
  114117. readonly renderWidth: number;
  114118. }
  114119. interface VRFieldOfView {
  114120. readonly downDegrees: number;
  114121. readonly leftDegrees: number;
  114122. readonly rightDegrees: number;
  114123. readonly upDegrees: number;
  114124. }
  114125. interface VRFrameData {
  114126. readonly leftProjectionMatrix: Float32Array;
  114127. readonly leftViewMatrix: Float32Array;
  114128. readonly pose: VRPose;
  114129. readonly rightProjectionMatrix: Float32Array;
  114130. readonly rightViewMatrix: Float32Array;
  114131. readonly timestamp: number;
  114132. }
  114133. interface VRPose {
  114134. readonly angularAcceleration: Float32Array | null;
  114135. readonly angularVelocity: Float32Array | null;
  114136. readonly linearAcceleration: Float32Array | null;
  114137. readonly linearVelocity: Float32Array | null;
  114138. readonly orientation: Float32Array | null;
  114139. readonly position: Float32Array | null;
  114140. readonly timestamp: number;
  114141. }
  114142. interface VRStageParameters {
  114143. sittingToStandingTransform?: Float32Array;
  114144. sizeX?: number;
  114145. sizeY?: number;
  114146. }
  114147. interface Navigator {
  114148. getVRDisplays(): Promise<VRDisplay[]>;
  114149. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  114150. }
  114151. interface Window {
  114152. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  114153. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  114154. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  114155. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  114156. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  114157. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  114158. }
  114159. interface Gamepad {
  114160. readonly displayId: number;
  114161. }
  114162. interface XRDevice {
  114163. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  114164. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  114165. }
  114166. interface XRSession {
  114167. getInputSources(): Array<any>;
  114168. baseLayer: XRWebGLLayer;
  114169. requestFrameOfReference(type: string): Promise<void>;
  114170. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  114171. end(): Promise<void>;
  114172. requestAnimationFrame: Function;
  114173. addEventListener: Function;
  114174. }
  114175. interface XRSessionCreationOptions {
  114176. outputContext?: WebGLRenderingContext | null;
  114177. immersive?: boolean;
  114178. environmentIntegration?: boolean;
  114179. }
  114180. interface XRLayer {
  114181. getViewport: Function;
  114182. framebufferWidth: number;
  114183. framebufferHeight: number;
  114184. }
  114185. interface XRView {
  114186. projectionMatrix: Float32Array;
  114187. }
  114188. interface XRFrame {
  114189. getDevicePose: Function;
  114190. getInputPose: Function;
  114191. views: Array<XRView>;
  114192. baseLayer: XRLayer;
  114193. }
  114194. interface XRFrameOfReference {
  114195. }
  114196. interface XRWebGLLayer extends XRLayer {
  114197. framebuffer: WebGLFramebuffer;
  114198. }
  114199. declare var XRWebGLLayer: {
  114200. prototype: XRWebGLLayer;
  114201. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  114202. };